Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Package dssl;
- Helpers
- all = [0 .. 127];
- digit = ['0' .. '9'];
- letter = [['a' .. 'z'] + ['A' .. 'Z']];
- name = letter (digit | letter | '_')*;
- sign = '+' | '-';
- tab = 9;
- lf = 10;
- cr = 13;
- eol = cr | lf | cr lf;
- separator = ' ' | tab | eol;
- apostrophe = 39;
- quote = 34;
- not_eol = [all - [cr + lf]];
- escape_char = '\' not_eol;
- c_char = [all - [apostrophe + ['\' + [lf + cr]]]] | escape_char;
- c_char_sequence = c_char+;
- s_char = [all - [quote + ['\' + [lf + cr]]]] | escape_char;
- s_char_sequence = s_char*;
- not_star = [all - '*'];
- not_star_slash = [not_star - '/'];
- double_slash = '//';
- slash_star = '/*';
- line_comment = double_slash not_eol* eol;
- block_comment = slash_star not_star* '*'+ (not_star_slash not_star* '*'+)* '/';
- Tokens
- blank = separator+;
- comment = line_comment | block_comment;
- l_brace = '{';
- r_brace = '}';
- def = 'def';
- exch = 'exch';
- pop = 'pop';
- dup = 'dup';
- roll = 'roll';
- clear = 'clear';
- copy = 'copy';
- count = 'count';
- countto = 'countto';
- read = 'read';
- print = 'print';
- interpret = 'interpret';
- int = 'int';
- bool = 'bool';
- float = 'float';
- char = 'char';
- string = 'string';
- exec = 'exec';
- halt = 'halt';
- break = 'break';
- equals = '=';
- plus_equals = '+=';
- and_equals = '&=';
- or_equals = '|=';
- xor_equals = '^=';
- minus_equals = '-=';
- concat_equals = '~=';
- arithmetic_left_shift_equals = '<<=';
- arithmetic_right_shift_equals = '>>=';
- logical_right_shift_equals = '>>>=';
- multiply_equals = '*=';
- divide_equals = '/=';
- remainder_equals = '%=';
- idivide_equals = '//=';
- modulo_equals = '%%=';
- equal_to = '==';
- not_equal_to = '!=';
- less_than = '<';
- less_or_equal = '<=';
- more_than = '>';
- more_or_equal = '>=';
- plus = '+';
- and = '&';
- or = '|';
- xor = '^';
- minus = '-';
- concat = '~';
- arithmetic_left_shift = '<<';
- arithmetic_right_shift = '>>';
- logical_right_shift = '>>>';
- multiply = '*';
- divide = '/';
- remainder = '%';
- idivide = '//';
- modulo = '%%';
- not = 'not';
- neg = 'neg';
- inv = 'inv';
- int_value = sign? digit+;
- bool_value = 'true' | 'false';
- float_value = sign? (digit+ ('.' digit*)? | '.' digit+);
- char_value = apostrophe c_char apostrophe;
- string_value = quote s_char_sequence quote;
- label = '/' name;
- identifier = name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement