version 0.0.0.1 (using C++17)
parse input ( string or file ) to tokens
using lexcial parse output as input, setup first and follow set and parse tokens according to BNF(EBNF) rules.
since without left recursion check, eliminate left recursion rule before you parse it
- seque, alter and terminal ( implemented by functions )
seque as: T==> A B C
bnf::Nseque<uchar> S{ "S" };
S( A, B, C );
alter as: T==> A|B|C
bnf::Nalter<uchar> S{ "S" };
S( A, B, C );
string as: T==> "something"
bnf::Nliteral<uchar> T{ "name of something", "something", nid_something };
state machine funcions as: T==> 'a'|'b'|...'z'
bnf::Nfunc<uchar> f{ "lowletter", _f, _frs, nid_something };
_f = [ Nfunc<uchar> &node ]->roadmap {
...
return (ch>='a' && ch<='z')?matched:unmatched;
}
_frs = [ char ch ]->roadmap {
return (ch>='a' && ch<='z')?matched:unmatched;
}
with range as: T==> 'a'{1,4}, min value is zero means allow match nothing, when max equal -1 match any number input
bnf::Nliteral<uchar> T{ "name", "a", nid_a, 1, 4 };
- lua syntax parser ( match hexical number not implemented yet! ) in file llua.h and llua.cpp
output text format is Lua string, include success or fail, stack and result size used, matched or unmatched count, if fail should print the information of match cursor
Licensed under the MIT License.