Skip to content
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.

Commit

Permalink
fix hlorenzi#91: don't allow bracket slice after newline
Browse files Browse the repository at this point in the history
  • Loading branch information
hlorenzi committed Jun 23, 2021
1 parent 76284f4 commit 88cd22f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/expr/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::*;
pub struct ExpressionParser<'a, 'parser: 'a>
{
parser: &'a mut syntax::Parser<'parser>,
//rule_params: Option<&'a [RuleParameter]>,
}


Expand All @@ -14,23 +13,16 @@ impl expr::Expr
{
ExpressionParser::new(parser).parse_expr()
}


/*pub fn parse_for_rule(parser: &mut Parser, rule_params: &[RuleParameter]) -> Result<expr::Expr, ()>
{
ExpressionParser::new(parser, Some(rule_params)).parse_expr()
}*/
}


impl<'a, 'parser> ExpressionParser<'a, 'parser>
{
pub fn new(parser: &'a mut syntax::Parser<'parser>/*, rule_params: Option<&'a [RuleParameter]>*/) -> ExpressionParser<'a, 'parser>
pub fn new(parser: &'a mut syntax::Parser<'parser>) -> ExpressionParser<'a, 'parser>
{
ExpressionParser
{
parser,
//rule_params,
}
}

Expand Down Expand Up @@ -272,6 +264,9 @@ impl<'a, 'parser> ExpressionParser<'a, 'parser>
{
let inner = self.parse_size()?;

if self.parser.next_is_linebreak()
{ return Ok(inner); }

let tk_open = match self.parser.maybe_expect(syntax::TokenKind::BracketOpen)
{
Some(tk) => tk,
Expand Down Expand Up @@ -306,6 +301,9 @@ impl<'a, 'parser> ExpressionParser<'a, 'parser>
{
let inner = self.parse_unary()?;

if self.parser.next_is_linebreak()
{ return Ok(inner); }

let tk_grave = match self.parser.maybe_expect(syntax::TokenKind::Grave)
{
Some(tk) => tk,
Expand Down
8 changes: 8 additions & 0 deletions tests/issue91/1.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ruledef
{
halt => 0x01
[ld] => 0x02
}

halt ; = 0x01
[ld] ; = 0x02

0 comments on commit 88cd22f

Please sign in to comment.