diff options
author | Matthew Sotoudeh <matthew@masot.net> | 2024-02-19 16:41:13 -0800 |
---|---|---|
committer | Matthew Sotoudeh <matthew@masot.net> | 2024-02-19 16:41:13 -0800 |
commit | 26a42b4a7ba077659f791208a2a7989bfdfb3663 (patch) | |
tree | 02069692c4d629d3108bbed43c4eb6eddfd2fbc7 /examples | |
parent | e133f250761c67b4465181f41909e78c272901d3 (diff) |
playing with the C grammar
Diffstat (limited to 'examples')
-rw-r--r-- | examples/file.c | 3 | ||||
-rw-r--r-- | examples/test.py | 8 | ||||
-rw-r--r-- | examples/type_ambiguous.c | 3 |
3 files changed, 11 insertions, 3 deletions
diff --git a/examples/file.c b/examples/file.c new file mode 100644 index 0000000..a94ceea --- /dev/null +++ b/examples/file.c @@ -0,0 +1,3 @@ +void hello(int x) { + x += 1; +} diff --git a/examples/test.py b/examples/test.py index e5783c5..ac7e223 100644 --- a/examples/test.py +++ b/examples/test.py @@ -1,14 +1,16 @@ import earlpy +p = earlpy.Parser("grammars/c") + if False: p = earlpy.Parser("grammars/expression") node = p.parse_string("1 + 1 + 2 + 3") print(node.pprint()) -elif True: +elif False: p = earlpy.Parser("grammars/c") - node = p.parse_file("examples/simple.c") + node = p.parse_file("examples/file.c") print(node.pprint()) -else: +elif False: p = earlpy.Parser("grammars/c") node = p.parse_file("examples/expr.c") print(node.pprint()) diff --git a/examples/type_ambiguous.c b/examples/type_ambiguous.c new file mode 100644 index 0000000..36602ae --- /dev/null +++ b/examples/type_ambiguous.c @@ -0,0 +1,3 @@ +void hello(int x) { + foo_t * x; +} |