Skip to content

Instantly share code, notes, and snippets.

@lamont-granquist
Created July 2, 2021 23:13
Show Gist options
  • Save lamont-granquist/8b46694084a04f1134f648c7de469c45 to your computer and use it in GitHub Desktop.
Save lamont-granquist/8b46694084a04f1134f648c7de469c45 to your computer and use it in GitHub Desktop.
grammar KspConfigNode
rule doc
__ (single_statement / "}" __ )* __ <Doc>
end
rule node
identifier __ ( single_statement / multi_statement ) __ <Node>
end
rule single_statement
node / value_assignment / multi_statement / garbage __ <Statement>
end
rule multi_statement
"{" __ single_statement* ( "}" / eof ) __ <MultiStatement>
end
rule value_assignment
identifier whitespace* [+-/*^]? "=" whitespace* value __ <Assignment>
end
rule garbage
identifier __
end
rule value
(!eolChar .)* <Value>
end
rule identifier
[^={} \t\u00A0\uFEFF\u1680\u180E\u2000-\u200A\u202F\u205F\u3000\n\r\u2028\u2029]+ <Identifier>
end
rule __
( whitespace / eol / comment )*
end
rule comment
( "//" / "\\\\" ) (!eolChar .)*
end
rule eol
"\n" / "\r\n" / "\r" / "\u2028" / "\u2029"
end
rule eolChar
[\n\r\u2028\u2029]
end
rule whitespace
[ \t\u00A0\uFEFF\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment