feat: improved error messages for atom types
This commit is contained in:
parent
057d625464
commit
ded35dcc6e
@ -12,8 +12,6 @@ val errConfig = new ErrorConfig {
|
||||
"%" -> Label("binary operator"),
|
||||
"&&" -> Label("binary operator"),
|
||||
"*" -> Label("binary operator"),
|
||||
"+" -> Label("binary operator"),
|
||||
"-" -> Label("binary operator"),
|
||||
"/" -> Label("binary operator"),
|
||||
"<" -> Label("binary operator"),
|
||||
"<=" -> Label("binary operator"),
|
||||
@ -32,8 +30,8 @@ val errConfig = new ErrorConfig {
|
||||
"string" -> Label("valid type"),
|
||||
"fst" -> Label("pair extraction"),
|
||||
"snd" -> Label("pair extraction"),
|
||||
"false" -> Label("boolean value"),
|
||||
"true" -> Label("boolean value")
|
||||
"false" -> Label("boolean literal"),
|
||||
"true" -> Label("boolean literal")
|
||||
)
|
||||
}
|
||||
object lexer {
|
||||
|
@ -29,11 +29,14 @@ object parser {
|
||||
Greater from ">",
|
||||
GreaterEq from ">="
|
||||
) +:
|
||||
SOps(InfixL)(Add from "+", Sub from "-") +:
|
||||
SOps(InfixL)(
|
||||
(Add from "+").label("binary operator"),
|
||||
(Sub from "-").label("binary operator")
|
||||
) +:
|
||||
SOps(InfixL)(Mul from "*", Div from "/", Mod from "%") +:
|
||||
SOps(Prefix)(
|
||||
Not from "!",
|
||||
Negate from (notFollowedBy(negateCheck) ~> "-"),
|
||||
(Negate from (notFollowedBy(negateCheck) ~> "-")).hide,
|
||||
Len from "len",
|
||||
Ord from "ord",
|
||||
Chr from "chr"
|
||||
@ -43,10 +46,10 @@ object parser {
|
||||
|
||||
// Atoms
|
||||
private lazy val `<atom>`: Atoms[Expr6] = Atoms(
|
||||
IntLiter(integer),
|
||||
BoolLiter(("true" as true) | ("false" as false)),
|
||||
CharLiter(charLit),
|
||||
StrLiter(stringLit),
|
||||
IntLiter(integer).label("integer literal"),
|
||||
BoolLiter(("true" as true) | ("false" as false)).label("boolean literal"),
|
||||
CharLiter(charLit).label("character literal"),
|
||||
StrLiter(stringLit).label("string literal"),
|
||||
PairLiter from "null",
|
||||
`<ident-or-array-elem>`,
|
||||
Parens("(" ~> `<expr>` <~ ")")
|
||||
|
Loading…
x
Reference in New Issue
Block a user