Advertisement
tomdodd4598

Untitled

Oct 19th, 2021
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. Package dssl;
  2.  
  3. Helpers
  4. all = [0 .. 127];
  5. digit = ['0' .. '9'];
  6. letter = [['a' .. 'z'] + ['A' .. 'Z']];
  7. name = letter (digit | letter | '_')*;
  8. sign = '+' | '-';
  9.  
  10. tab = 9;
  11. lf = 10;
  12. cr = 13;
  13. eol = cr | lf | cr lf;
  14. separator = ' ' | tab | eol;
  15.  
  16. apostrophe = 39;
  17. quote = 34;
  18. not_eol = [all - [cr + lf]];
  19. escape_char = '\' not_eol;
  20.  
  21. c_char = [all - [apostrophe + ['\' + [lf + cr]]]] | escape_char;
  22. c_char_sequence = c_char+;
  23. s_char = [all - [quote + ['\' + [lf + cr]]]] | escape_char;
  24. s_char_sequence = s_char*;
  25.  
  26. not_star = [all - '*'];
  27. not_star_slash = [not_star - '/'];
  28.  
  29. double_slash = '//';
  30. slash_star = '/*';
  31.  
  32. line_comment = double_slash not_eol* eol;
  33. block_comment = slash_star not_star* '*'+ (not_star_slash not_star* '*'+)* '/';
  34.  
  35. Tokens
  36. blank = separator+;
  37. comment = line_comment | block_comment;
  38.  
  39. l_brace = '{';
  40. r_brace = '}';
  41.  
  42. def = 'def';
  43.  
  44. exch = 'exch';
  45. pop = 'pop';
  46. dup = 'dup';
  47.  
  48. roll = 'roll';
  49. clear = 'clear';
  50. copy = 'copy';
  51.  
  52. count = 'count';
  53. countto = 'countto';
  54.  
  55. read = 'read';
  56. print = 'print';
  57. interpret = 'interpret';
  58.  
  59. int = 'int';
  60. bool = 'bool';
  61. float = 'float';
  62. char = 'char';
  63. string = 'string';
  64.  
  65. exec = 'exec';
  66.  
  67. halt = 'halt';
  68. break = 'break';
  69.  
  70. equals = '=';
  71.  
  72. plus_equals = '+=';
  73. and_equals = '&=';
  74. or_equals = '|=';
  75. xor_equals = '^=';
  76. minus_equals = '-=';
  77. concat_equals = '~=';
  78.  
  79. arithmetic_left_shift_equals = '<<=';
  80. arithmetic_right_shift_equals = '>>=';
  81. logical_right_shift_equals = '>>>=';
  82.  
  83. multiply_equals = '*=';
  84. divide_equals = '/=';
  85. remainder_equals = '%=';
  86. idivide_equals = '//=';
  87. modulo_equals = '%%=';
  88.  
  89. equal_to = '==';
  90. not_equal_to = '!=';
  91.  
  92. less_than = '<';
  93. less_or_equal = '<=';
  94. more_than = '>';
  95. more_or_equal = '>=';
  96.  
  97. plus = '+';
  98. and = '&';
  99. or = '|';
  100. xor = '^';
  101. minus = '-';
  102. concat = '~';
  103.  
  104. arithmetic_left_shift = '<<';
  105. arithmetic_right_shift = '>>';
  106. logical_right_shift = '>>>';
  107.  
  108. multiply = '*';
  109. divide = '/';
  110. remainder = '%';
  111. idivide = '//';
  112. modulo = '%%';
  113.  
  114. not = 'not';
  115. neg = 'neg';
  116. inv = 'inv';
  117.  
  118. int_value = sign? digit+;
  119. bool_value = 'true' | 'false';
  120. float_value = sign? (digit+ ('.' digit*)? | '.' digit+);
  121. char_value = apostrophe c_char apostrophe;
  122. string_value = quote s_char_sequence quote;
  123.  
  124. label = '/' name;
  125. identifier = name;
  126.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement