Note that there are some explanatory texts on larger screens.

plurals
  1. POantlrworks with multiple equals
    primarykey
    data
    text
    <p>I'm having a problem with my grammar.</p> <p>It says Decision can match input such as <code>"{EQUAL, GREATER..GREATER_EQUAL, LOWER..LOWER_EQUAL, NOT_EQUAL}" using multiple alternatives: 1, 2</code>, Although all the trees of rules are correct.</p> <p>Anyone to help?!</p> <pre><code>grammar test; //parser : .* EOF; program :T_PROGRAM ID T_LEFTPAR identifier_list T_RIGHTPAR T_SEMICOLON declarations subprogram_declarations compound_statement T_DOT; identifier_list :(ID) (',' ID)*; declarations :() (T_VAR identifier_list COLON type T_SEMICOLON)* ; type : standard_type| T_ARRAY T_LEFTBRACK NUM T_TO NUM T_RIGHTBRACK T_OF standard_type ; standard_type : INT | FLOAT ; subprogram_declarations :() (subprogram_declaration T_SEMICOLON)* ; subprogram_declaration : subprogram_head declarations compound_statement; subprogram_head :T_FUNCTION ID arguments COLON standard_type | T_PROCEDURE ID arguments ; arguments :T_LEFTPAR parameter_list T_RIGHTPAR | ; parameter_list :(identifier_list COLON type) (T_SEMICOLON identifier_list COLON type)*; compound_statement : T_BEGIN optional_statements T_END; optional_statements :statement_list | ; statement_list :(statement) (T_SEMICOLON statement)*; statement : variable ASSIGN expression | procedure_statement | compound_statement | T_IF expression T_THEN statement T_ELSE statement | T_WHILE expression T_DO statement ; procedure_statement :ID | ID T_LEFTPAR expression_list T_RIGHTPAR; expression_list : (expression) (',' expression)*; variable : ID T_LEFTBRACK expression T_RIGHTBRACK | ; expression :( () |simple_expression) (( LOWER | LOWER_EQUAL | GREATER | GREATER_EQUAL | EQUAL | NOT_EQUAL ) simple_expression)* ; simple_expression : ( () | sign ) term (( PLUS | MINUS | T_OR ) term)*; term : (factor) (( CROSS | DIVIDE | MOD | T_AND ) factor)*; factor : variable |ID T_LEFTPAR expression_list T_RIGHTPAR | NUM | T_LEFTPAR expression T_RIGHTPAR | T_NOT factor; sign : '+' | '-'; /********/ T_PROGRAM : 'program'; T_FUNCTION : 'function'; T_PROCEDURE : 'procedure'; T_READ : 'read'; T_WRITE : 'write'; T_OF : 'of'; T_ARRAY : 'array'; T_VAR : 'var'; T_FLOAT : 'float'; T_INT : 'int'; T_CHAR : 'char'; T_STRING : 'string'; T_BEGIN : 'begin'; T_END : 'end'; T_IF : 'if'; T_THEN : 'then'; T_ELSE : 'else'; T_WHILE : 'while'; T_DO : 'do'; T_NOT : 'not'; NUM : INT | FLOAT; STRING : '"' ( ESC_SEQ | ~('\\'|'"') )* '"' ; CHAR: '\'' ( ESC_SEQ | ~('\''|'\\') ) '\'' ; ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ; COMMENT : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;} ; LOWER : '&lt;'; LOWER_EQUAL : '&lt;='; GREATER : '&gt;'; GREATER_EQUAL : '&gt;='; EQUAL : '='; NOT_EQUAL : '&lt;&gt;'; ASSIGN : ':='; COLON : ':'; PLUS : '+'; MINUS : '-'; T_OR : 'OR'; CROSS : '*'; DIVIDE : '/'; MOD : 'MOD'; T_AND : 'AND'; T_LEFTPAR : '('; T_RIGHTPAR : ')'; T_LEFTBRACK : '['; T_RIGHTBRACK : ']'; T_TO : '..'; T_DOT : '.'; T_SEMICOLON : ';'; T_COMMA : ','; T_BADNUM : (NUM)(CHAR)*; T_BADSTRING : '"' ( ESC_SEQ | ~('\\'|'"') )*WS; WS : ( ' ' | '\t' | '\r' | '\n' ) {$channel=HIDDEN;} ; fragment EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ; fragment HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ; fragment ESC_SEQ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | UNICODE_ESC | OCTAL_ESC ; fragment OCTAL_ESC : '\\' ('0'..'3') ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ('0'..'7') | '\\' ('0'..'7') ; fragment UNICODE_ESC : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT ; fragment INT : '0'..'9'+ ; fragment FLOAT : ('0'..'9')+ '.' ('0'..'9')* EXPONENT? | '.' ('0'..'9')+ EXPONENT? | ('0'..'9')+ EXPONENT ; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload