diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-21 16:04:56 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-21 17:28:19 +0200 |
commit | 0e3df321ab2fce795bdc6b9aeb92724733cf8ee0 (patch) | |
tree | 8370e465f2b16f46f623f3e77eef4b1be2219f92 /module/c/ast.scm | |
parent | Merge call-with-tmpfile and diffs for testrunner. (diff) | |
download | calp-0e3df321ab2fce795bdc6b9aeb92724733cf8ee0.tar.gz calp-0e3df321ab2fce795bdc6b9aeb92724733cf8ee0.tar.xz |
Major work on parser.
Diffstat (limited to 'module/c/ast.scm')
-rw-r--r-- | module/c/ast.scm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/module/c/ast.scm b/module/c/ast.scm new file mode 100644 index 00000000..bf5ad630 --- /dev/null +++ b/module/c/ast.scm @@ -0,0 +1,25 @@ +(define-module (c ast) + :use-module ((c to-token) :select (preprocessing-token->token)) + :use-module ((c parse2) + :select (build-lexical-analyzer + make-parser + error-procedure)) + :use-module ((hnh util) :select (->>)) + :use-module ((c flatten-begin) + :select (flatten-begin + remove-invalid-struct-like-declarations)) + :export (build-ast)) + +(define (parse% lexical-analyzer) + ((make-parser) lexical-analyzer error-procedure)) + +(define (build-ast cpp-tokens) + (->> cpp-tokens +;;; 7. Whitespace tokens are discarded, each preprocessing token is converted into a token + (map preprocessing-token->token) +;;; 8. All external objects and functions are resolved + build-lexical-analyzer + parse% + flatten-begin + remove-invalid-struct-like-declarations + )) |