Created
August 30, 2016 14:35
-
-
Save fendrin/c1a2b205acc7e2d65d2aa5c2b16e4bce 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
g = P { | |
"Line" | |
Line: Space * (((V"Define" + V"EndIf" + V"Else" + V"IfDef" + V"Macro" + V"PureMacro" + V"EmptyTag" + V"TagStart" + V"TagEnd" + V"Attribute")^0 * Comment) * (L(Stop)) + EmptyLine) / komisch! | |
Shared: Boolean + Number + Variable + TMultiLineString + TString + DoubleString + MultiLineString + V"PureMacro" + V"Macro" | |
Param: V"Shared" + (C(notName) / mark_value"string") | |
Value: Space * ( V"Shared" + V"Attribute" + UnquotedString ) | |
TagStart: (sym"[" * Name * symx"]") / mark_value("tagStart") | |
TagEnd: (sym"[/" * Name * symx"]") / mark_value("tagEnd") | |
EmptyTag: V"TagStart" * V"TagEnd" / (table) -> { value: table.value, type: "tagEmpty" } | |
KeyList: Cg(Ct(Name * (sym"," * Name)^0),"keys") | |
ValueList: Cg(Ct(V"Value" * (sym"," * (V"Value"))^0 ),"values") | |
Attribute: Ct(Space * V"KeyList" * sym"=" * Space * V"ValueList" ) / mark2("type","attribute") | |
PureMacro: sym"{" * (Name / mark_value"pureMacro") * sym"}" | |
Argument: ( sym"(" * V"Value" * sym")" ) + V"Param" | |
Macro: Ct(sym"{" * Cg(Name,"name") * SomeSpace * Cg(Ct(V"Argument" * (SomeSpace * V"Argument")^0 ),"parameters") * sym"}") / mark2("type", "macro") | |
IfHave: sym"#Ifhave" * SomeSpace * (Path / mark_value"ifHave") | |
IfDef: sym"#ifdef" * SomeSpace * (Name / mark_value"ifDef" ) | |
IfNDef: sym"#ifndef" * SomeSpace * (Name / mark_value"ifNDef") | |
Else: sym"#else" / -> { type: "else" } | |
EndIf: sym"#endif" / -> { type: "endIf" } | |
EndDef: sym"#enddef" / -> { type: "endDef"} | |
Define: Ct(sym"#define" * SomeSpace * Cg(Name, "name") * SomeSpace * Cg(Ct(V"Argument" * (SomeSpace * V"Argument")^0 ),"parameters") ) / mark2("type", "define") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment