Skip to content

Commit 2bfc00f

Browse files
committed
Fixed parsing tags in nsplug.
1 parent f8f5808 commit 2bfc00f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

moos-parser/src/nsplug/lexer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub enum Token<'input> {
3636
MacroElseIfDef,
3737
MacroElse,
3838
MacroEndIf,
39+
MacroTag,
3940
TagKeyword,
4041
UnknownMacro(&'input str),
4142
OrOperator,
@@ -267,6 +268,7 @@ impl<'input> Lexer<'input> {
267268
"ifdef" => Token::MacroIfDef,
268269
"ifndef" => Token::MacroIfNotDef,
269270
"include" => Token::MacroInclude,
271+
"<tag>" => Token::MacroTag,
270272
_ => Token::UnknownMacro(line),
271273
}
272274
}

moos-parser/src/nsplug/nsplug.lalrpop

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ TagLine: Line = {
6666
line_end_index: el.index,
6767
indent: indent.unwrap_or_default().into(),
6868
},
69-
// TODO: Need to handle when there are no <>
69+
<indent: WhiteSpace?> <l:@L> "#<tag>" <r:@R> WhiteSpace* <tag: VariableString> WhiteSpace* <el:@L>END =>
70+
Line::Tag {
71+
tag: Tag{tag: tag, is_macro: true, range: TokenRange::new_line(l,r).unwrap()},
72+
comment: None,
73+
line: l.line,
74+
line_end_index: el.index,
75+
indent: indent.unwrap_or_default().into(),
76+
},
7077
}
7178

7279
MacroDefinition: MacroDefinition = {
@@ -369,6 +376,7 @@ extern {
369376
"#ifdef" => Token::MacroIfDef,
370377
"#ifndef" => Token::MacroIfNotDef,
371378
"#include" => Token::MacroInclude,
379+
"#<tag>" => Token::MacroTag,
372380
"#unknown" => Token::UnknownMacro(<&'input str>),
373381
"tag" => Token::TagKeyword,
374382
"||" => Token::OrOperator,

0 commit comments

Comments
 (0)