fix: catch function call without keyword with parenscheck

This commit is contained in:
Barf-Vader 2025-02-07 16:27:32 +00:00
parent d32855cc29
commit 4bf63454f4

@ -13,6 +13,7 @@ import cats.data.NonEmptyList
import parsley.errors.DefaultErrorBuilder
import parsley.errors.ErrorBuilder
import parsley.errors.tokenextractors.LexToken
import parsley.character.char
object parser {
import lexer.implicits.implicitSymbol
@ -49,6 +50,9 @@ object parser {
case Expr
case Pair
val _parensCheck =
char('(').verifiedExplain("functions can only be called using 'call' keyword")
implicit val builder: ErrorBuilder[String] = new DefaultErrorBuilder with LexToken {
def tokens = errTokens
}
@ -67,8 +71,8 @@ object parser {
GreaterEq from ">="
) +:
SOps(InfixL)(
(Add from "+").label("binary operator"),
(Sub from "-").label("binary operator")
((Add from "+").label("binary operator") | _parensCheck),
((Sub from "-").label("binary operator") | _parensCheck)
) +:
SOps(InfixL)(Mul from "*", Div from "/", Mod from "%") +:
SOps(Prefix)(