diff --git a/examples/c/src/c.rustemo b/examples/c/src/c.rustemo index 7f5d5e35..f23d8501 100644 --- a/examples/c/src/c.rustemo +++ b/examples/c/src/c.rustemo @@ -162,6 +162,13 @@ Statement: ForInitClause: ";" {None} | Expression ";" {ForInitWithExpression} | Declaration {ForInitWithDeclaration}; +// Layout - comments, whitespaces. +Layout: LayoutItem*; +LayoutItem: WS | Comment; +Comment: '/*' Corncs '*/' | CommentLine; +Corncs: Cornc*; +Cornc: Comment | NotComment | WS; + terminals Ampersand: '&'; @@ -251,5 +258,12 @@ Volatile: "volatile"; While: 'while'; Num: /[+\-]?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+\-]?\d+)?/; -Identifier: /\p{XID_Start}\p{XID_Continue}*/; +Identifier: /[a-zA-Z_][0-9a-zA-Z_]*/; StringLiteral: /"[^"]*"/; + +// Layout terminals +WS: /\s+/; +CommentLine: /\/\/.*/; +NotComment: /((\*[^\/])|[^\s*\/]|\/[^\*])+/; +BCommentBegin: '/*'; +BCommentEnd: '*/'; diff --git a/examples/c/src/main.rs b/examples/c/src/main.rs index e7a11a96..db9080ec 100644 --- a/examples/c/src/main.rs +++ b/examples/c/src/main.rs @@ -1,3 +1,12 @@ +use rustemo::{Parser, rustemo_mod}; + +rustemo_mod!(c, "/src/"); +rustemo_mod!(c_actions, "/src/"); + +use c::CParser; + fn main() { - println!("Hello, world!"); + let mut parser = CParser::new(); + let forest = parser.parse_file("binary_tree.c"); + println!("{forest:?}"); }