fix: catch function call without keyword with parenscheck
This commit is contained in:
parent
d32855cc29
commit
4bf63454f4
@ -13,6 +13,7 @@ import cats.data.NonEmptyList
|
|||||||
import parsley.errors.DefaultErrorBuilder
|
import parsley.errors.DefaultErrorBuilder
|
||||||
import parsley.errors.ErrorBuilder
|
import parsley.errors.ErrorBuilder
|
||||||
import parsley.errors.tokenextractors.LexToken
|
import parsley.errors.tokenextractors.LexToken
|
||||||
|
import parsley.character.char
|
||||||
|
|
||||||
object parser {
|
object parser {
|
||||||
import lexer.implicits.implicitSymbol
|
import lexer.implicits.implicitSymbol
|
||||||
@ -49,6 +50,9 @@ object parser {
|
|||||||
case Expr
|
case Expr
|
||||||
case Pair
|
case Pair
|
||||||
|
|
||||||
|
val _parensCheck =
|
||||||
|
char('(').verifiedExplain("functions can only be called using 'call' keyword")
|
||||||
|
|
||||||
implicit val builder: ErrorBuilder[String] = new DefaultErrorBuilder with LexToken {
|
implicit val builder: ErrorBuilder[String] = new DefaultErrorBuilder with LexToken {
|
||||||
def tokens = errTokens
|
def tokens = errTokens
|
||||||
}
|
}
|
||||||
@ -67,8 +71,8 @@ object parser {
|
|||||||
GreaterEq from ">="
|
GreaterEq from ">="
|
||||||
) +:
|
) +:
|
||||||
SOps(InfixL)(
|
SOps(InfixL)(
|
||||||
(Add from "+").label("binary operator"),
|
((Add from "+").label("binary operator") | _parensCheck),
|
||||||
(Sub from "-").label("binary operator")
|
((Sub from "-").label("binary operator") | _parensCheck)
|
||||||
) +:
|
) +:
|
||||||
SOps(InfixL)(Mul from "*", Div from "/", Mod from "%") +:
|
SOps(InfixL)(Mul from "*", Div from "/", Mod from "%") +:
|
||||||
SOps(Prefix)(
|
SOps(Prefix)(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user