mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-11-17 15:55:31 +00:00
Changed to use C++ raw string.
This commit is contained in:
parent
5ebd01c846
commit
d834a7c4ce
@ -34,15 +34,15 @@ int main(int argc, const char** argv)
|
||||
return result;
|
||||
};
|
||||
|
||||
peg parser(
|
||||
" EXPRESSION <- _ TERM (TERM_OPERATOR TERM)* "
|
||||
" TERM <- FACTOR (FACTOR_OPERATOR FACTOR)* "
|
||||
" FACTOR <- NUMBER / '(' _ EXPRESSION ')' _ "
|
||||
" TERM_OPERATOR <- < [-+] > _ "
|
||||
" FACTOR_OPERATOR <- < [/*] > _ "
|
||||
" NUMBER <- < [0-9]+ > _ "
|
||||
" ~_ <- [ \t\r\n]* "
|
||||
);
|
||||
peg parser(R"(
|
||||
EXPRESSION <- _ TERM (TERM_OPERATOR TERM)*
|
||||
TERM <- FACTOR (FACTOR_OPERATOR FACTOR)*
|
||||
FACTOR <- NUMBER / '(' _ EXPRESSION ')' _
|
||||
TERM_OPERATOR <- < [-+] > _
|
||||
FACTOR_OPERATOR <- < [/*] > _
|
||||
NUMBER <- < [0-9]+ > _
|
||||
~_ <- [ \t\r\n]*
|
||||
)");
|
||||
|
||||
parser["EXPRESSION"] = reduce;
|
||||
parser["TERM"] = reduce;
|
||||
|
@ -39,15 +39,15 @@ int main(int argc, const char** argv)
|
||||
}
|
||||
};
|
||||
|
||||
peg parser(
|
||||
" EXPRESSION <- _ TERM (TERM_OPERATOR TERM)* "
|
||||
" TERM <- FACTOR (FACTOR_OPERATOR FACTOR)* "
|
||||
" FACTOR <- NUMBER / '(' _ EXPRESSION ')' _ "
|
||||
" TERM_OPERATOR <- < [-+] > _ "
|
||||
" FACTOR_OPERATOR <- < [/*] > _ "
|
||||
" NUMBER <- < [0-9]+ > _ "
|
||||
" ~_ <- [ \t\r\n]* "
|
||||
);
|
||||
peg parser(R"(
|
||||
EXPRESSION <- _ TERM (TERM_OPERATOR TERM)*
|
||||
TERM <- FACTOR (FACTOR_OPERATOR FACTOR)*
|
||||
FACTOR <- NUMBER / '(' _ EXPRESSION ')' _
|
||||
TERM_OPERATOR <- < [-+] > _
|
||||
FACTOR_OPERATOR <- < [/*] > _
|
||||
NUMBER <- < [0-9]+ > _
|
||||
~_ <- [ \t\r\n]*
|
||||
)");
|
||||
|
||||
parser.enable_ast();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user