Last active
August 29, 2015 14:11
-
-
Save godber/9e90bd3cb7df2f4aa20d to your computer and use it in GitHub Desktop.
This file contains 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
/***************************************************************************** | |
* ODLv2 as Defined Here: http://pds.nasa.gov/documents/sr/Chapter12.pdf | |
*****************************************************************************/ | |
grammar ODLv21; | |
WS | |
: [ \t] -> skip | |
; | |
INTEGER | |
: (SIGN) UNSIGNED_INTEGER | |
; | |
UNSIGNED_INTEGER | |
: (DIGIT)+ | |
; | |
SIGN | |
: [+-] | |
; | |
REAL | |
: (SIGN) UNSCALED_REAL | |
| (SIGN) SCALED_REAL | |
; | |
UNSCALED_REAL | |
: UNSIGNED_INTEGER.(UNSIGNED_INTEGER) | |
| .UNSIGNED_INTEGER | |
; | |
SCALED_REAL | |
: UNSCALED_REAL EXPONENT | |
; | |
EXPONENT | |
: 'E' INTEGER | |
| 'e' INTEGER | |
; | |
STRING_CHARACTER | |
: LETTER | |
| DIGIT | |
| [ .] | |
; | |
STRING | |
: '"' STRING_CHARACTER+ '"' | |
| STRING_CHARACTER+ | |
; | |
IDENTIFIER | |
: LETTER(LETTER|DIGIT|'_'LETTER|'_'DIGIT)* | |
; | |
NEWLINE | |
: '\r\n' | |
; | |
LETTER | |
: [a-zA-Z] | |
; | |
DIGIT | |
: [0-9] | |
; | |
label | |
: (statement)*('END'|'end') | |
; | |
statement | |
: assignment_stmt (comment_stmt)* NEWLINE | |
| comment_stmt NEWLINE | |
| NEWLINE | |
; | |
assignment_stmt | |
: IDENTIFIER '=' value | |
; | |
comment_stmt | |
: '/*' STRING '*/' | |
; | |
value | |
: STRING | |
| INTEGER | |
; |
This file contains 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
PDS_VERSION_ID = PDS3 | |
INTEGER1 = 1 | |
FLOAT = 2.3 | |
COMMENT1 = THING TEST | |
COMMENT2 = Alive. | |
END |
This file contains 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
enter label, LT(1)=PDS_VERSION_ID | |
enter statement, LT(1)=PDS_VERSION_ID | |
enter assignment_stmt, LT(1)=PDS_VERSION_ID | |
consume [@0,0:13='PDS_VERSION_ID',<16>,1:0] rule assignment_stmt | |
consume [@1,15:15='=',<2>,1:15] rule assignment_stmt | |
enter value, LT(1)= PDS3 | |
consume [@2,16:20=' PDS3',<15>,1:16] rule value | |
exit value, LT(1)= | |
exit assignment_stmt, LT(1)= | |
consume [@3,21:22='\r\n',<17>,1:21] rule statement | |
exit statement, LT(1)=INTEGER1 | |
line 2:0 extraneous input 'INTEGER1 ' expecting {'END', 'end', '/*', IDENTIFIER, ' | |
'} | |
enter statement, LT(1)= | |
consume [@7,41:42='\r\n',<17>,2:18] rule statement | |
exit statement, LT(1)=FLOAT | |
line 3:0 extraneous input 'FLOAT ' expecting {'END', 'end', '/*', IDENTIFIER, ' | |
'} | |
enter statement, LT(1)= | |
consume [@11,63:64='\r\n',<17>,3:20] rule statement | |
exit statement, LT(1)=COMMENT1 | |
line 4:0 extraneous input 'COMMENT1 ' expecting {'END', 'end', '/*', IDENTIFIER, ' | |
'} | |
enter statement, LT(1)= | |
consume [@15,92:93='\r\n',<17>,4:27] rule statement | |
exit statement, LT(1)=COMMENT2 | |
line 5:0 extraneous input 'COMMENT2 ' expecting {'END', 'end', '/*', IDENTIFIER, ' | |
'} | |
enter statement, LT(1)= | |
consume [@19,117:118='\r\n',<17>,5:23] rule statement | |
exit statement, LT(1)=END | |
consume [@20,119:121='END',<3>,6:0] rule label | |
exit label, LT(1)= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment