Guest User

my syntax for lupe

a guest
Apr 19th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. //<LUPESYNTAX version="1.0"/>
  2. //Last updated: 19/04/14
  3.  
  4. //--BUILT-IN TYPES
  5. //int Integer
  6. //char Character
  7. //string String (of characters)/text
  8. //bool Boolean /on/off true/false
  9.  
  10. //--COMPILER INSTRUCTIONS a.k.a Pre-processor Directives -denoted by preceding "#"
  11.  
  12. //'#auto'
  13. //Put in front of declarations, functions, classes etc., and if they aren't
  14. //being used in the program, they'll not be compiled
  15.  
  16. //'#skip'
  17. //Can be used to skip compilation (inclusion) of declared element for debugging/
  18. //quick testing etc. (compiler ignores it)
  19.  
  20. //'#use'
  21. //Includes a code file with the current code (adds it in)
  22. //e.g. >>use "other_code.lupe"
  23.  
  24. //--KEYWORD MODIFIERS
  25.  
  26. //'active'
  27. //Modifier: modifies the function to make it an 'active' function i.e. it
  28. returns something e.g. active int add(...)...{..return ? ..}...
  29. //'readonly' Only allows data to be read from it
  30.  
  31. //'writeonly' Only allows something to be written to it
  32.  
  33.  
  34. //--MAIN KEYWORDS
  35. //'func'
  36. // Function, does not return a value unless preceeded with modifier 'active'.
  37. //Otherwise, just does job,or works with data
  38.  
  39. //--PARSE TAG MODIFIERS
  40. //¬NOT: (not), before syntax word e.g. "¬NOT:12"
  41. //* any number (none, one, or more than one), after syntax word e.g. <word>*
  42. //+ one or more, after syntax word
  43.  
  44. //--PARSE TAGS [note: '|' meaning or/alternatively]
  45.  
  46. <obrkt> := {
  47. <cbrkt> := }
  48.  
  49. //OPERATORS
  50. //between two operands
  51. <op_equ> := =
  52. <op_add> := +
  53. <op_sub> := -
  54. <op_mul> := *
  55. <op_div> := / | \
  56. <op> := <op_equ> | <op_add> | <op_sub> | <op_mul> | <op_div>
  57.  
  58. //SPECIAL OPERATORS
  59. //between two operands (will yield result, will not affect either operand)
  60. <op_cnv> := >>
  61. //after first/only operand
  62. <op_inc> := ++
  63. <op_dec> := --
  64.  
  65. <letter> := a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z
  66. | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
  67.  
  68. <digit> := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  69.  
  70. <int> := <digit>+
  71.  
  72. <non_quote_char> := ¬NOT:"
  73.  
  74. <char> := <non_quote_char>
  75.  
  76. <string> := "<char>*"
  77.  
  78. <comment> := // <char>*
  79.  
  80. <bool> := true | false | 1 | 0
  81.  
  82. <type> := <int> | <string> | <char> | <bool>
  83.  
  84. <identifier_first_char> := <letter> | _
  85. <identifier_rest> := <letter> | <digit> | _
  86. <identifier> := <identifier_first_char> <identifier_rest>*
  87.  
  88. <expression> := <string>
  89. | <int>
  90. | <arith_expression>
  91. | <identifier>
  92. | <expression> <op> <expression>
  93.  
  94. <var_decl> := <type> <identifier> ;
  95. | <type> <identifier> <op_equ> <expression> ;
  96. | <type> <identifier> , <identifier> ;
  97. | <type> <identifier> , <identifier> <op_equ> <expression> ;
  98. | readonly <type> <identifier> , <identifier> <op_equ> <expression> ;
  99. | writeonly <type> <identifier> , <identifier> <op_equ> <expression> ;
  100. | private <var_decl>
  101. | public <var_decl>
  102.  
  103. <statement> := <variable_decl>
  104. | <identifier> <op_equ> <expression> ;
  105. | call <identifier> ( <expression>* ) ;
  106. | <identifier> <op_cnv> <type> ;
  107. | print <expression>
  108. | <op_cnv> <expression> , <type> ;
  109. | <conditional>
  110. | <statement> ; <statement>
  111.  
  112. <conditional> := if <expression> <op_equ> <expression> <obrkt> <statement> <cbrkt>
  113. | if <expression> <obrkt> <statement> <cbrkt>
  114. | for <expression> to <expression> <obrkt> <statement> <cbrkt>
  115. | for <expression> in <expression> <obrkt> <statement> <cbrkt>
  116.  
  117. <exmpty_ret> := return ;
  118. <return> := return <expression> ;
  119.  
  120. <function_decl> := func <identifier> ( <var_decl>* ) <obrkt> <exmpty_ret>* <statement> <exmpty_ret>* <cbrkt>
  121. | active <type> <identifier> ( <var_decl>* ) <obrkt> <statement>* <return> <statement>* <cbrkt>
  122.  
  123. <any_decl> := <func_decl> | <var_decl>
  124.  
  125. <class_decl> := class <identifier> <obrkt> <any_decl>* <cbrkt>
Advertisement
Add Comment
Please, Sign In to add comment