Skip to content

Commit

Permalink
sample
Browse files Browse the repository at this point in the history
  • Loading branch information
linsyking committed Mar 31, 2023
1 parent fac89f5 commit fa997c1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
9 changes: 9 additions & 0 deletions examples/syn.meow
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
hh() { "dd" }
sdf(hhs, fff) {
"fd" = hhg("ss");
var ldk = {
var s = ("ff" + hhs + "d");
"hhh"
};
"ffs"
}
20 changes: 8 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::env::args;

pub mod ast;

#[macro_use]
Expand All @@ -6,18 +8,12 @@ extern crate lalrpop_util;
lalrpop_mod!(pub parse); // synthesized by LALRPOP

fn main() {
let mut argv = args();
argv.next();
let fp = argv.next().expect("unknown file");
let fc = std::fs::read_to_string(fp).expect("failed to open the file");
let res = parse::ProgramParser::new()
.parse(
r#"hh() { "dd" }
sdf(hhs, fff) {
"fd" = hhg("ss");
var ldk = {
var s = ("ff" + hhs + "d");
"hhh"
};
"ffs"
}"#,
)
.expect("Not expected!");
.parse(fc.as_str())
.expect("unexpected token!");
println!("{:?}", res);
}

0 comments on commit fa997c1

Please sign in to comment.