Add helper functions for making shared pointers to rules
- start work on item set class
This commit is contained in:
parent
ec8b7ccf20
commit
11e3980319
33 changed files with 486 additions and 150 deletions
43
spec/lr/parse_table_spec.cpp
Normal file
43
spec/lr/parse_table_spec.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include "spec_helper.h"
|
||||
|
||||
Describe(parse_table_construction) {
|
||||
Grammar grammar = Grammar(
|
||||
{
|
||||
"expression",
|
||||
"term",
|
||||
"factor",
|
||||
"number",
|
||||
"variable",
|
||||
"plus",
|
||||
"times",
|
||||
"left_paren",
|
||||
"right_paren"
|
||||
}, {
|
||||
rules::choice({
|
||||
rules::seq({
|
||||
rules::sym("term"),
|
||||
rules::sym("plus"),
|
||||
rules::sym("term") }),
|
||||
rules::sym("term") }),
|
||||
rules::choice({
|
||||
rules::seq({
|
||||
rules::sym("factor"),
|
||||
rules::sym("times"),
|
||||
rules::sym("factor") }),
|
||||
rules::sym("factor") }),
|
||||
rules::choice({
|
||||
rules::sym("variable"),
|
||||
rules::sym("number"),
|
||||
rules::seq({
|
||||
rules::sym("left_paren"),
|
||||
rules::sym("expression"),
|
||||
rules::sym("right_paren") }) }),
|
||||
rules::pattern("\\d+"),
|
||||
rules::pattern("\\w+"),
|
||||
rules::str("+"),
|
||||
rules::str("*"),
|
||||
rules::str("("),
|
||||
rules::str(")")
|
||||
}
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue