amc.parser module

Module contents

Parser for AMC files.

class amc.parser.Parser(optimize=True, **kwargs)

Parser for AMC files.

Parameters
optimizebool

If True, tries to import pregenerated parser and lexer tables to improve startup time. If tables do not exist, they are written to the package directory, if possible.

**kwargs

Additional keword arguments passed to the lexer constructor and the main parser invocation yacc.yacc. See the PLY documentation for details.

Attributes
lexerLexer

The AMC lexer.

tokenstuple

List of all tokens generated by the lexer.

parserLRParser

PLY parser object used for parsing.

Methods

parse(self, text[, debug])

Parse the given text as an AMC file.

parse(self, text, debug=0)

Parse the given text as an AMC file.

Parameters
textstr

Text to parse.

debugint

Debug level, increase for more output from the PLY parser.

exception amc.parser.LexerError(token, line, col)

Bases: Exception

A lexer error.

Parameters
tokenLexToken

The offending token.

lineint

Line number.

colint

Column number.

Attributes
tokenLexToken

The offending token.

lineint

Line number.

colint

Column number.

exception amc.parser.ParserError(msg, line, col)

Bases: Exception

A parser error.

Parameters
msgstr

Error message.

lineint

Line number.

colint

Column number.

Attributes
msgstr

Error message.

lineint

Line number.

colint

Column number.

exception amc.parser.ParserSyntaxError(token, line, col)

Bases: amc.parser._parser.ParserError

A syntax error.

Parameters
tokenLexToken

Offending token.

lineint

Line number.

colint

Column number.

Attributes
tokenLexToken

Offending token.

exception amc.parser.UnknownTensorError(name, line, col)

Bases: amc.parser._parser.ParserError

An unknown tensor has been encountered.

Parameters
namestr

Name of the tensor.

lineint

Line number.

colint

Column number.

Attributes
namestr

Name of the tensor.

exception amc.parser.SubscriptError(tensor, msg, line, col)

Bases: amc.parser._parser.ParserError

Illegal use of subscripts on a tensor.

Parameters
tensorast.TensorDeclaration

The tensor.

msgstr

Error message.

lineint

Line number.

colint

Column number.

Attributes
tensorast.TensorDeclaration

The tensor.