Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
igordejanovic committed Feb 27, 2024
1 parent 56a832a commit 54cd2f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
16 changes: 15 additions & 1 deletion examples/c/src/c.rustemo
Original file line number Diff line number Diff line change
Expand Up @@ -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: '&';
Expand Down Expand Up @@ -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: '*/';
11 changes: 10 additions & 1 deletion examples/c/src/main.rs
Original file line number Diff line number Diff line change
@@ -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:?}");
}

0 comments on commit 54cd2f8

Please sign in to comment.