Created
September 1, 2013 08:39
-
-
Save dmj/6403133 to your computer and use it in GitHub Desktop.
ANTLR4 grammer for PICA+ records
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
/* ANTLR4 Grammar for PICA+ records */ | |
grammar PicaRecord ; | |
file : record ('\n' record)* ; | |
record : field+ ; | |
field : tag ' ' subfield+ '\u001e'; | |
tag : FIELD_TAG ; | |
subfield : SUBFIELD ; | |
// Lexer rules | |
FIELD_TAG : DIGIT DIGIT DIGIT (UPPER | SYMBOL_AT) ('/' DIGIT DIGIT)?; | |
SUBFIELD : '\u001f' SUBFIELD_CODE SUBFIELD_VALUE* ; | |
SUBFIELD_CODE : ALNUM ; | |
SUBFIELD_VALUE : ~('\u001f' | '\u001e') ; | |
fragment ALNUM : DIGIT | LOWER | UPPER ; | |
fragment DIGIT : '0'..'9' ; | |
fragment LOWER : 'a'..'z' ; | |
fragment UPPER : 'A'..'Z' ; | |
fragment SYMBOL_AT : '@' ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment