SyntaxDefinition

ll1compiletime.syntax.SyntaxDefinition
trait SyntaxDefinition[T, K]

The trait to define a syntax

Attributes

K

the Kind type

T

the Token type

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Type members

Types

type CSyntax[X] = Syntax[X, Token, Kind]

Type of a syntax in this context of SyntaxDefinition

Type of a syntax in this context of SyntaxDefinition

Attributes

X

the return value of the syntax

type Kind = K

the type of Kind of the parsing Tokens

the type of Kind of the parsing Tokens

Attributes

type Token = T

the type of parsing Tokens

the type of parsing Tokens

Attributes

Value members

Abstract methods

def getKind(t: Token): Kind

Return the Kind of a given Token

Return the Kind of a given Token

Attributes

t

the given Token

Returns:

the Kind corresponding to the token

Concrete methods

def accept[B](k: Kind)(f: PartialFunction[Token, B])(using IdCounter): CSyntax[B]

A Syntax that accept a Token of the given Kind and applies applies the function f on the parsed Token

A Syntax that accept a Token of the given Kind and applies applies the function f on the parsed Token

Attributes

B

the resulting type when parsing the given kind

f

the partial function to apply to a parsed Token of the kind

k

the kind of the Token to parse

def elem(k: Kind)(using IdCounter): CSyntax[Token]

A syntax that produce the parsed Token of the given Kind

A syntax that produce the parsed Token of the given Kind

Attributes

k

the Kind of the Token to parse

def epsilon[B](e: B)(using IdCounter): CSyntax[B]

A nullable sytnax which gives the given value on an empty sequence of Token

A nullable sytnax which gives the given value on an empty sequence of Token

Attributes

B

the type of the value to produce

e

the value to produce

def failure[B](using IdCounter): CSyntax[B]

The empty syntax, results in parsing failure

The empty syntax, results in parsing failure

Attributes

B

the type of value that should be produced

def many[A](rep: CSyntax[A])(using IdCounter): CSyntax[Seq[A]]

The syntax the represent 0 or more repetition of the given syntax

The syntax the represent 0 or more repetition of the given syntax

Attributes

A

the type of the syntax to repeat

rep

the syntax to be repeated

def many1[A](rep: CSyntax[A])(using IdCounter): CSyntax[Seq[A]]

The syntax the represent 1 or more repetition of the given syntax

The syntax the represent 1 or more repetition of the given syntax

Attributes

A

the type of the syntax to repeat

rep

the syntax to be repeated

def oneOf[A](syntaxes: CSyntax[A]*)(using IdCounter): CSyntax[A]

Return a syntax that is a disjunction of the given syntaxes

Return a syntax that is a disjunction of the given syntaxes

Attributes

A

the type of the disjunction syntaxes

syntaxes

the syntax to create the disjunction from

Example:

oneOf[X] (a,b,...,n) // can be seen as (a | b | ... | n | failure[X])

def opt[B](cs: CSyntax[B]): CSyntax[Option[B]]

Define an optional syntax.

Define an optional syntax.

If the parsing succeed the value is of type Some[B] Otherwise it is of type None

Attributes

def recursive[B](syntax: => CSyntax[B])(using IdCounter): CSyntax[B]

Define a recursive Syntax

Define a recursive Syntax

Attributes

B

the type of the parsed value

syntax

the inner recursive syntax

def rep1sep[A, B](rep: CSyntax[A], sep: CSyntax[B])(using IdCounter): CSyntax[Seq[A]]

The syntax the represent 1 or more repetition of the given syntax rep, each separated by a syntax sep. The resulting syntax is a sequence of reps

The syntax the represent 1 or more repetition of the given syntax rep, each separated by a syntax sep. The resulting syntax is a sequence of reps

Attributes

A

the type of the syntax to repeat

B

the type of the separator syntax

rep

the syntax to be repeated

sep

the separator syntax

def repsep[A, B](rep: CSyntax[A], sep: CSyntax[B])(using IdCounter): CSyntax[Seq[A]]

The syntax the represent 0 or more repetition of the given syntax rep, each separated by a syntax sep. The resulting syntax is a sequence of reps

The syntax the represent 0 or more repetition of the given syntax rep, each separated by a syntax sep. The resulting syntax is a sequence of reps

Attributes

A

the type of the syntax to repeat

B

the type of the separator syntax

rep

the syntax to be repeated

sep

the separator syntax

Givens

Givens

given idc: IdCounter

a given IdCounter that gives unique ids to Syntaxes

a given IdCounter that gives unique ids to Syntaxes

Attributes

Extensions

Extensions

extension [X](thiz: CSyntax[X])
def +:[X]: CSyntax[Seq[X]]

Syntax Sequence operator

Syntax Sequence operator

Returns a new syntax which is the sequence of syntaxes thiz and then that, prepend the parsed value of thiz to the sequence of value of that

Attributes

that

second element of the sequence, values are prepended to

thiz

first element of the sequence

def map[B](f: X => B): CSyntax[B]

Map this syntax of X to a syntax of B by applying the function f on resulting the value

Map this syntax of X to a syntax of B by applying the function f on resulting the value

Attributes

B

the type of the resulting syntax

f

the function applied on the parsed value

def up[B >: X]: CSyntax[B]

Upcase thiz to a supertype B of X

Upcase thiz to a supertype B of X

Attributes

B

the supertype to upcast to

Returns:

a new syntax with B as inner type

infix def |(that: CSyntax[X])(using ic: IdCounter): CSyntax[X]

Syntax Disjunction operator

Syntax Disjunction operator

Returns a new syntax which is the disjunction of syntaxes thiz and that

Attributes

that

the other syntax of the disjunction

thiz

a sytnax of the disjunction

infix def ||[B](that: CSyntax[B])(using e: IdCounter): CSyntax[Either[X, B]]

Syntax Disjunction operator

Syntax Disjunction operator

Returns a new syntax which is the disjunction of syntaxes thiz and that

Attributes

that

the other syntax of the disjunction

thiz

a sytnax of the disjunction

infix def ~[B](that: CSyntax[B]): CSyntax[X ~ B]

Syntax Sequence operator

Syntax Sequence operator

Returns a new syntax which is the sequence of syntaxes thiz and then that

Attributes

that

second element of the sequence

thiz

first element of the sequence

infix def ~<~[B](that: CSyntax[B]): CSyntax[X]

Sequence operator, keeping the left value

Sequence operator, keeping the left value

Returns a new syntax which is the sequence of syntaxes thiz and then that, keeping only the value of thiz.

Attributes

that

second element of the sequence

thiz

first element of the sequence

infix def ~>~[B](that: CSyntax[B]): CSyntax[B]

Sequence operator, keeping the right value

Sequence operator, keeping the right value

Returns a new syntax which is the sequence of syntaxes thiz and then that, keeping only the value of that.

Attributes

that

second element of the sequence

thiz

first element of the sequence

extension [X](thiz: CSyntax[Seq[X]])
def :+(that: CSyntax[X]): CSyntax[Seq[X]]

Syntax Sequence operator

Syntax Sequence operator

Returns a new syntax which is the sequence of syntaxes thiz and then that, append the parsed value of that to the sequence of value of thiz

Attributes

that

second element of the sequence

thiz

first element of the sequence, values are appended to