ErrorHandling
Attributes
- Source
- ErrorHandling.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ErrorHandling.type
Members list
Type members
Classlikes
What to do with input that is not accepted: one character for the lexer, one lexeme for the parser.
What to do with input that is not accepted: one character for the lexer, one lexeme for the parser.
Attributes
- Source
- ErrorHandling.scala
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
A lexer error handler. In handler, the error carries the context's fields with their types (error.line). It can also change the context. In handler, ctx is the lexer context as in a rule body: assigning its fields (ctx.count += 1) changes the context the lexer goes on with, so they can stay vals.
A lexer error handler. In handler, the error carries the context's fields with their types (error.line). It can also change the context. In handler, ctx is the lexer context as in a rule body: assigning its fields (ctx.count += 1) changes the context the lexer goes on with, so they can stay vals.
case class MyCtx(line: Line = Line.Start, skipped: Int = 0) extends LexerCtx
given ErrorHandling[MyCtx] = ErrorHandling.forLexer: error =>
ctx.skipped += 1
ErrorHandling.Strategy.SkipOne
The error reported for the input keeps the context from before the handler ran.
Type parameters
- Ctx
-
the lexer context
Value parameters
- handler
-
the strategy for an error, written directly as a lambda
Attributes
- Source
- ErrorHandling.scala
A parser error handler, which can change the context. In handler, ctx is the parser context as in an action: assigning its fields (ctx.skipsLeft -= 1) changes the context the parser goes on with, so they can stay vals.
A parser error handler, which can change the context. In handler, ctx is the parser context as in an action: assigning its fields (ctx.skipsLeft -= 1) changes the context the parser goes on with, so they can stay vals.
case class MyCtx(skipsLeft: Int = 3) extends ParserCtx
given ErrorHandling[MyCtx] = ErrorHandling.forParser: error =>
if ctx.skipsLeft == 0 then ErrorHandling.Strategy.Stop
else
ctx.skipsLeft -= 1
ErrorHandling.Strategy.SkipOne
Type parameters
- Ctx
-
the parser context
Value parameters
- handler
-
the strategy for an error, written directly as a lambda
Attributes
- Source
- ErrorHandling.scala
