Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Package drlc;
- Helpers
- all = [0 .. 0xFFFF];
- digit = ['0' .. '9'];
- letter = [['a' .. 'z'] + ['A' .. 'Z']];
- name_char = digit | letter | '_';
- apostrophe = ''';
- sign = '-' | '+';
- tab = 9;
- lf = 10;
- cr = 13;
- eol = cr | lf | cr lf;
- separator = ' ' | tab | eol;
- double_slash = '//';
- slash_star = '/*';
- star_slash = '*/';
- not_eol = [all - [cr + lf]];
- not_star = [all - '*'];
- not_star_slash = [not_star - '/'];
- line_comment = double_slash not_eol* eol;
- block_comment = slash_star not_star* '*'+ (not_star_slash not_star* '*'+)* '/';
- Tokens
- directive_prefix = '\';
- set_argc = 'set_argc';
- modifier = 'stack' | 'static';
- const = 'const';
- conditional_start_section_keyword = 'if' | 'unless';
- conditional_middle_section_keyword = 'elsif' | 'elsunless';
- else = 'else';
- loop = 'loop';
- conditional_iterative_section_keyword = 'while' | 'until';
- repeat = 'repeat';
- goto = 'goto';
- exit = 'exit';
- return = 'return';
- continue = 'continue';
- break = 'break';
- equals = '=';
- l_par = '(';
- r_par = ')';
- l_bracket = '[';
- r_bracket = ']';
- l_brace = '{';
- r_brace = '}';
- comma = ',';
- colon = ':';
- semicolon = ';';
- dereference = '#';
- address_of = '@';
- logical_and = '&&';
- logical_or = '||';
- logical_xor = '^^';
- equal_to = '==';
- not_equal_to = '!=';
- less_than = '<';
- less_or_equal = '<=';
- more_than = '>';
- more_or_equal = '>=';
- plus = '+';
- and = '&';
- or = '|';
- xor = '^';
- minus = '-';
- arithmetic_left_shift = '<<';
- arithmetic_right_shift = '>>';
- logical_right_shift = '>>>';
- circular_left_shift = '<</';
- circular_right_shift = '>>/';
- multiply = '*';
- divide = '/';
- remainder = '%';
- complement = '~';
- to_bool = '?';
- not = '!';
- name = letter name_char*;
- integer = sign? digit+;
- character = apostrophe not_eol apostrophe;
- blank = separator+;
- comment = line_comment | block_comment;
- Ignored Tokens
- blank,
- comment;
- Productions
- unit =
- setup program;
- setup =
- setup_section*;
- program =
- program_section*;
- /* UNIT SPECIFICATION */
- setup_section =
- {directive_call} directive_call;
- directive_call =
- directive_prefix directive semicolon;
- directive =
- {set_argc} set_argc l_par expression r_par;
- program_section =
- {function_declaration} function_declaration |
- {function_definition} function_definition |
- {basic_section} basic_section;
- basic_section =
- {empty_statement} empty_statement |
- {constant_definition} constant_definition |
- {variable_declaration} variable_declaration |
- {assignment_statement} assignment_statement |
- {expression_statement} expression_statement |
- {conditional_section} conditional_section |
- {iterative_section} iterative_section |
- {goto_statement} goto_statement |
- {section_label} section_label;
- /* SECTION SPECIFICATIONS */
- function_declaration =
- type function_name l_par parameter_list? r_par semicolon;
- function_definition =
- modifier* type function_name l_par parameter_list? r_par l_brace basic_section* stop_statement? r_brace;
- empty_statement =
- semicolon;
- constant_definition =
- const type constant_name equals expression semicolon;
- variable_declaration =
- {excluding_initialization} type variable_lvalue semicolon |
- {including_initialization} type variable_lvalue equals expression semicolon;
- assignment_statement =
- variable_lvalue equals expression semicolon;
- expression_statement =
- {function} function semicolon;
- conditional_section =
- conditional_start_section conditional_middle_section* else_section?;
- conditional_start_section =
- conditional_start_section_keyword expression l_brace basic_section* stop_statement? r_brace;
- conditional_middle_section =
- conditional_middle_section_keyword expression l_brace basic_section* stop_statement? r_brace;
- else_section =
- else l_brace basic_section* stop_statement? r_brace;
- iterative_section =
- {loop} loop l_brace basic_section* stop_statement? r_brace |
- {conditional} conditional_iterative_section_keyword expression l_brace basic_section* stop_statement? r_brace |
- {repeat_conditional} repeat l_brace basic_section* stop_statement? r_brace conditional_iterative_section_keyword expression semicolon;
- goto_statement =
- goto label_name semicolon;
- section_label =
- label_name colon;
- stop_statement =
- {exit} exit semicolon dead_section* |
- {return} return semicolon dead_section* |
- {continue} continue semicolon dead_section* |
- {break} break semicolon dead_section* |
- {exit_expression} exit expression semicolon dead_section* |
- {return_expression} return expression semicolon dead_section*;
- dead_section =
- {dead0} basic_section |
- {dead1} exit semicolon |
- {dead2} return semicolon |
- {dead3} continue semicolon |
- {dead4} break semicolon |
- {dead5} exit expression semicolon |
- {dead6} return expression semicolon;
- /* COMPONENT SPECIFICATIONS */
- type =
- {basic} address_of* type_name |
- {function} address_of* l_par type r_par l_bracket parameter_list? r_bracket;
- type_name =
- name;
- function_name =
- name;
- parameter_list =
- type variable_lvalue? parameter_list_tail*;
- parameter_list_tail =
- comma type variable_lvalue?;
- constant_name =
- name;
- variable_lvalue =
- dereference* variable_name;
- variable_name =
- name;
- label_name =
- name;
- expression =
- expression0;
- expression0 =
- {prioritized} expression1 |
- {binary} expression0 logical_binary_op expression1;
- expression1 =
- {prioritized} expression2 |
- {binary} expression1 equality_binary_op expression2;
- expression2 =
- {prioritized} expression3 |
- {binary} expression2 comparative_binary_op expression3;
- expression3 =
- {prioritized} expression4 |
- {binary} expression3 additive_binary_op expression4;
- expression4 =
- {prioritized} expression5 |
- {binary} expression4 shift_binary_op expression5;
- expression5 =
- {prioritized} expression6 |
- {binary} expression5 multiplicative_binary_op expression6;
- expression6 =
- {prioritized} expression7 |
- {unary} unary_op expression6 |
- {dereference} dereference expression6 |
- {address_of} address_of variable_name;
- expression7 =
- {prioritized} expression8 |
- {function} function_expression;
- expression8 =
- {value} value |
- {variable} variable_name |
- {parentheses} l_par expression0 r_par;
- value =
- {integer} integer |
- {character} character;
- function_expression =
- function;
- function =
- expression7 l_par argument_list? r_par;
- argument_list =
- expression argument_list_tail*;
- argument_list_tail =
- comma expression;
- /* OPERATION SPECIFICATIONS */
- logical_binary_op =
- {logical_and} logical_and |
- {logical_or} logical_or |
- {logical_xor} logical_xor;
- equality_binary_op =
- {equal_to} equal_to |
- {not_equal_to} not_equal_to;
- comparative_binary_op =
- {less_than} less_than |
- {less_or_equal} less_or_equal |
- {more_than} more_than |
- {more_or_equal} more_or_equal;
- additive_binary_op =
- {plus} plus |
- {and} and |
- {or} or |
- {xor} xor |
- {minus} minus;
- shift_binary_op =
- {arithmetic_left_shift} arithmetic_left_shift |
- {arithmetic_right_shift} arithmetic_right_shift |
- {logical_right_shift} logical_right_shift |
- {circular_left_shift} circular_left_shift |
- {circular_right_shift} circular_right_shift;
- multiplicative_binary_op =
- {multiply} multiply |
- {divide} divide |
- {remainder} remainder;
- unary_op =
- {plus} plus |
- {minus} minus |
- {complement} complement |
- {to_bool} to_bool |
- {not} not;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement