Parser

alpaca.internal.parser.Parser
abstract class Parser[Ctx <: ParserCtx](using x$1: withDefault[Ctx, Empty])(using empty: Empty[Ctx], tables: Tables[Ctx])

Base class for parsers.

Users should extend this class and define their grammar rules as Rule instances. The parser uses an LR parsing algorithm with automatic parse table generation.

Type parameters

Ctx

the global context type, defaults to EmptyGlobalCtx

Attributes

Experimental
true
Source
Parser.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

final inline protected def ctx: Ctx

Provides access to the parser context within rule definitions.

Provides access to the parser context within rule definitions.

This is compile-time only and can only be used inside parser rule definitions.

Attributes

Source
Parser.scala
transparent inline protected def production: ProductionSelector

Provides compile-time access to named productions for use in conflict resolution definitions.

Provides compile-time access to named productions for use in conflict resolution definitions.

This method allows you to reference productions by their names as defined in your parser. It is typically used when specifying conflict resolutions, enabling you to refer to productions in a type-safe and compile-time-checked manner.

Example usage:

 override val resolutions = Set(
   production.plus.after(production.times)
 )

Attributes

Note

This is a compile-time only feature and should be used within parser definitions.

Source
Parser.scala

Abstract fields

val root: Rule[_]

The root rule of the grammar.

The root rule of the grammar.

This is the starting point for parsing.

Attributes

Source
Parser.scala

Concrete fields

The set of conflict resolution rules for this parser.

The set of conflict resolution rules for this parser.

Override this to resolve shift/reduce or reduce/reduce conflicts by specifying precedence relationships between productions and tokens.

Attributes

Source
Parser.scala