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