mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
parser: prevent non-associative and equal precedence operators being used in same expression
This commit is contained in:
parent
be4e54c5be
commit
b384bb81ec
@ -8,7 +8,7 @@ use crate::{
|
||||
use std::{fmt::Display, vec::IntoIter};
|
||||
use trunk_lexer::{Span, Token, TokenKind};
|
||||
|
||||
use self::precedence::Precedence;
|
||||
use self::precedence::{Precedence, Associativity};
|
||||
|
||||
type ParseResult<T> = Result<T, ParseError>;
|
||||
|
||||
@ -1812,6 +1812,7 @@ impl Parser {
|
||||
break;
|
||||
}
|
||||
|
||||
let span = self.current.span.clone();
|
||||
let kind = self.current.kind.clone();
|
||||
|
||||
if is_postfix(&kind) {
|
||||
@ -1834,6 +1835,10 @@ impl Parser {
|
||||
break;
|
||||
}
|
||||
|
||||
if rpred == precedence && matches!(rpred.associativity(), Some(Associativity::Non)) {
|
||||
return Err(ParseError::UnexpectedToken(kind.to_string(), span));
|
||||
}
|
||||
|
||||
self.next();
|
||||
|
||||
match kind {
|
||||
|
Loading…
Reference in New Issue
Block a user