Skip to content

Instantly share code, notes, and snippets.

@melchisedech333
Created March 28, 2022 17:45
Show Gist options
  • Save melchisedech333/1aac5f057b235ea69afe8bc8d4650555 to your computer and use it in GitHub Desktop.
Save melchisedech333/1aac5f057b235ea69afe8bc8d4650555 to your computer and use it in GitHub Desktop.
Gramática
parser grammar TParser;
options {
tokenVocab = TLexer;
}
@parser::postinclude {
#ifndef _WIN32
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
}
// Gramática.
main
: sentence EOF
;
sentence
: sentence expression
|
;
expression
: VAR variables END
;
variables
: definition
| definition SEPARATOR variables
;
definition
: VARIABLE ATTR value
| VARIABLE TYPE ATTR value
;
array
: ARRAY_OPEN ARRAY_CLOSE
| ARRAY_OPEN elements ARRAY_CLOSE
;
elements
: value
| value SEPARATOR elements
| value TYPE SEPARATOR elements
;
value
: VARIABLE
| STRING
| INTEGER
| array
| VARIABLE TYPE
| STRING TYPE
| INTEGER TYPE
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment