mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:38:10 +00:00
JSSpecCompiler: Always treat trailing MemberAccess as punctuation
Due to the way expression parser is written, we need to resolve the ambiguity between member access operators and dots used for punctuation during lexing. The lexer uses a (totally bulletproof) heuristic to do that: whenever '.' is followed by ' ' or '\n', it is considered a dot and member access otherwise. While it works fine for prettified test cases, non-prettified files often lack enter after a trailing dot character. Since MemberAccess will always be invalid at that position, explicitly treat trailing dot as a part of punctuation.
This commit is contained in:
parent
b4a9fde756
commit
b74df136fe
4 changed files with 32 additions and 0 deletions
|
@ -151,6 +151,10 @@ ParseErrorOr<TokenizeTreeResult> tokenize_tree(XML::Node const* node, bool allow
|
|||
},
|
||||
move(ignore_comments)));
|
||||
}
|
||||
|
||||
if (tokens.size() && tokens.last().type == TokenType::MemberAccess)
|
||||
tokens.last().type = TokenType::Dot;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue