aboutsummaryrefslogtreecommitdiff
path: root/module/c/ast.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/c/ast.scm')
-rw-r--r--module/c/ast.scm25
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
+ ))