====== BNF Grammar ====== ===== Introduction ===== This is a [[http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form|BNF Grammar]] compatiable with [[http://www.devincook.com/goldparser/|Gold Parser]] for LOLCode. Gold Parser is pretty cool and has 'Engine' implimentations in plenty of languages, including but not limited to C#, C, Python and Java. An engine will take an compile grammar and should give you a funky parse tree, from this you could generate ASM, MSIL or 'some other language' as the output (which would require a bit of work mind you). Currently it can parse [[http://tinyurl.com/3dtx7e|Eko's recommendation example]]. However there are likely to be issues with this grammar, if you find any please make updates and/or let me know. ===== The Grammar ===== "Name" = 'LOLCODE' "Author" = 'Phil Price' "Version" = '1.0Rec' "About" = 'www.lolcode.com' "Start Symbol" = ! ------------------------------------------------- Sets {WS} = {Whitespace} - {CR} - {LF} {ID Head} = {Letter} + [_] {ID Tail} = {Alphanumeric} + [_] {String Chars} = {Printable} + {HT} - ["] ! ------------------------------------------------- Terminals Whitespace = {WS}+ NewLine = {CR}{LF} | {CR} | {LF} Identifier = {ID Head}{ID Tail}* StringLiteral = '"' {String Chars}* '"' IntLiteral = {digit}+ Comment = BTW{Space}{Printable}* ! ------------------------------------------------- Statement seperators      ::= NewLine          !One or more | NewLine ::= NewLine          !One or more | NewLine | '.' | '.' ::= NewLine       !Zero or more           | !Empty !======================================================= ! ------------------------------------------------- Program ::= ::= 'HAI' KTHXBYE ! ------------------------------------------------- Keyword Lists ::= 'WORD' | 'LINE' | 'LETTAR' | !Nothing ::= 'UPZ' | 'NERFZ' | 'TIEMZD' | 'OVARZ' ::= 'BYES' | 'DIAF' !======================================================= ::= | !Empty ::= | | | | | | | | | | Comment ::= 'CAN HAS' Identifier '?' | 'CAN HAS' StringLiteral '?' ::= 'VISIBLE' | 'VISIBLE' '!' ::= 'I HAS A' Identifier | 'I HAS A' Identifier ITZ ! This should actually work according the langue definitons ::= 'LOL' 'R' ::= 'GIMMEH' Identifier ::= | IntLiteral | IntLiteral StringLiteral ::= 'IZ' 'YARLY' 'KTHX' | 'IZ' 'KTHX' ::= 'NOWAI' | ! Nothing ::= 'IM IN YR' Identifier 'KTHX' ::= 'GTFO' ::= '!!' | '!!' ::= '?' | !Nothing ! ---- Portions of the following block are based on Basic-64.grm from devincook.com/goldparaser ::= OR | ::= AND | ::= NOT | ::= 'LIEK' | 'BIGR THAN' | 'SMALR THAN' | ::= 'UP' | 'NERF' | ::= 'TIEMZ' | 'OVAR' | ::= '-' | | '-' | ::= IntLiteral | StringLiteral ::= Identifier | IN MAH ::= | ===== Changes ===== * Updated to be 1.0rec compliant --- //Phil Price, 2007/06/02 18:34// ===== Feedback =====