gelijergensen / MetaLogic

A general purpose calculator for propositional logic systems
MIT License
0 stars 0 forks source link

Added Parser for generic ASTs #4

Closed gelijergensen closed 3 years ago

gelijergensen commented 3 years ago

Currently, the parser accepts the grammar

<S>           ::= <leaf> | <node> | "(" <S> ")"
<leaf>        ::= <identifier>
<node>        ::= <opname> <args>
<opname>      ::= <symbols> | <identifier> | "(" <opname> ")"
<args>        ::= <leafOrNode> | <leafOrNode> <args>
<leafOrNode>  ::= <leaf> | "(" <node> ")"
<identifier>  ::= <alpha> | <alpha> <alphaNums>
<symbols>     ::= <symbol> | <symbol> <symbols>
<alphaNums>   ::= <alphaNum> | <alphaNum> <alphaNums>
<alphaNum>    ::= ...
<symbol>      ::= ...

where <alphaNum> recognizes a single alpha numeric character and <symbol> recognizes any one character in .,:;'/<>?~!@#$%^&*-+=|\. Notice that we do this at the word level (all whitespace is used to make tokens and then we strip it off). For example, the parser sees " x ( yx) " as ["x", "(", "yx", ")"].

resolves #3