Skip to content

Commit

Permalink
feat: add support for LALRPOP (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
abiriadev committed May 2, 2024
1 parent dfaf79b commit ba11288
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,13 @@
"env": ["ksh"],
"extensions": ["ksh"]
},
"Lalrpop": {
"name": "LALRPOP",
"line_comment": ["//"],
"extensions": ["lalrpop"],
"quotes": [["\\\"", "\\\""], ["#\\\"", "\\\"#"]],
"verbatim_quotes": [["r##\\\"", "\\\"##"], ["r#\\\"", "\\\"#"]]
},
"KvLanguage": {
"name":"KV Language",
"line_comment": ["# "],
Expand Down
37 changes: 37 additions & 0 deletions tests/data/lalrpop.lalrpop
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 37 lines 26 code 3 comments 8 blanks
use crate::ast::{ExprSymbol, Opcode};
use crate::tok9::Tok;

grammar<'input>(input: &'input str);

// line comment
pub Expr: Box<ExprSymbol<'input>> = { // comment 1
Expr r##"verbatim2"## Factor => Box::new(ExprSymbol::Op(<>)),
Factor, // comment 2
};

Factor: Box<ExprSymbol<'input>> = { // comment 3
Factor "FactorOp" Term => Box::new(ExprSymbol::Op(<>)),
Term,
};

// comment 4

Term: Box<ExprSymbol<'input>> = {
r#"verbatim"# => Box::new(ExprSymbol::NumSymbol(<>)),
"(" <Expr> ")"
};

extern {
type Location = usize;
type Error = ();

enum Tok<'input> {
r#"verbatim"# => Tok::NumSymbol(<&'input str>),
"FactorOp" => Tok::FactorOp(<Opcode>),
r##"verbatim2"## => Tok::ExprOp(<Opcode>),
"(" => Tok::ParenOpen,
")" => Tok::ParenClose,
}
}

0 comments on commit ba11288

Please sign in to comment.