// Denne grammatik er til et SUBSET af bibtex!! // understøtter KUN entries af formen: // @STRING{RMP="Rev. Mod. Phys."} // ELLER // @Book{abramowitz+stegun, // author = "Milton Abramowitz and Irene A. Stegun", // title = "Handbook of Mathematical Functions with // Formulas, Graphs, and Mathematical Tables", // publisher = "Dover", // year = 1964, // address = "New York", // edition = "ninth Dover printing, tenth GPO printing", // isbn = "0-486-61272-4" // } // TRIVIA // Note that the lexical language is both non-regular // (because braces must balance) // and context-sensitive (because { can mean different // things depending on its syntactic context). // JUNK = (~["@", "\n", " ", "\r", "\t"])+ // baseret på http://www.gerg.ca/software/btOOL/doc/bt_language.html // ændringer: () er ikke entry opener/closer, kun {} // top level LEXING: SKIP: ( <"%" (~["\n"])* > | " " | "\r" | "\t" | "\n" ) TOKENS: ABREV = ("@" ("S"|"s") ("T"|"t") ("R"|"r") ("I"|"i") ("N"|"n") ("G"|"g") ) AT = "@" //NEWLINE = "\n" NUMBER = (["0"-"9"])+ STRING = ("\"" (~["\""])+ "\"") NAME = (["a"-"z", "A"-"Z", "0"-"9", "!", "$", "&", "*", "+", "-", ".", "/", ":", ";", "<", ">", "?", "[", "]", "^", "_", "`", "|"])+ LBRACE = "{" RBRACE = "}" LPAR = "(" RPAR = ")" EQUALS = "=" COMMA = "," GRAMMAR: Bibfile ::= Entries ; Entries ::= Entry (Entries)? ; Entry ::= AT NAME Body | ABREV LBRACE NAME EQUALS STRING RBRACE ; Body ::= LBRACE Contents RBRACE ; Contents ::= NAME COMMA Fields | NUMBER COMMA Fields ; // for regular entries // for macro definition Entries // for preamble entries Fields ::= Field (COMMA Fields)? ; Field ::= NAME EQUALS Value ; Value ::= STRING | NUMBER | NAME ;