Parser

Internal documentation for the amalgam.parser module.

amalgam.parser.parse(text: str, source: str = '<unknown>')amalgam.amalgams.Amalgam[source]

Facilitates regular parsing that can fail.

class amalgam.parser.Expression(visit_tokens=True)[source]

Transforms expressions in text into their respective amalgams.Amalgam representations.

atom(colon, identifier)[source]
floating(number)[source]
fraction(number)[source]
integral(number)[source]
quoted(quote, expression)[source]
s_expression(*values)[source]
string(*values)[source]
symbol(identifier)[source]
vector(*values)[source]
class amalgam.parser.ParsingError(line: int, column: int, text: str, source: str)[source]

Base exception for errors during parsing.

line

The line number nearest to the error

Type

int

column

The column number nearest to the error

Type

int

text

The original text being parsed

Type

str

source

The source of the original text

Type

str

class amalgam.parser.ExpectedEOF(line: int, column: int, text: str, source: str)[source]

Raised when multiple expressions are found.

class amalgam.parser.ExpectedExpression(line: int, column: int, text: str, source: str)[source]

Raised when no expressions are found.

class amalgam.parser.MissingClosing(line: int, column: int, text: str, source: str)[source]

Raised on missing closing parentheses or brackets.

class amalgam.parser.MissingOpening(line: int, column: int, text: str, source: str)[source]

Raised on missing opening parentheses or brackets.