Created
March 28, 2022 17:45
-
-
Save melchisedech333/1aac5f057b235ea69afe8bc8d4650555 to your computer and use it in GitHub Desktop.
Gramática
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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