modparc.syntax package¶
Submodules¶
modparc.syntax.class_definition module¶
modparc.syntax.component_clause module¶
component_clause¶
Parser definition for funcparserlib. The parsers that need forward declaration are defined as function annotated by the Parser decorator.
The definitions are specified in the Appendix B.2.4 of the Modelica Specification 3.3.
modparc.syntax.equations module¶
equations¶
Parser definition for funcparserlib. The parsers that need forward declaration are defined as function annotated by the Parser decorator
The definitions are specified in the Appendix B.2.6 of the Modelica Specification 3.3.
Note that there’s no definition for the assertion statement/calls in the specification, so the Assertion parser is separately defined.
modparc.syntax.expressions module¶
expressions¶
Parser definition for funcparserlib. The parsers that need forward declaration are defined as function annotated by the Parser decorator
The definitions are specified in the Appendix B.2.7 of the Modelica Specification 3.3.
modparc.syntax.extends module¶
extends¶
Parser definition for funcparserlib. The parsers that need forward declaration are defined as function annotated by the Parser decorator.
The definitions are specified in the Appendix B.2.3 of the Modelica Specification 3.3.
modparc.syntax.modification module¶
modparc.syntax.stored_definition module¶
stored_definition¶
Parser definition for funcparserlib.
The definitions are specified in the Appendix B.2.1 of the Modelica Specification 3.3.
This is the top-level module used by in the library api as it parses the contents of a Modelica source code file (files with suffix .mo).
modparc.syntax.syntax_elements module¶
syntax_element¶
Each syntax element is defined as a class in the syntax_element module, to enable basic formatting and query function for the parse tree.
-
class
modparc.syntax.syntax_elements.
AddOp
(elements)¶
-
class
modparc.syntax.syntax_elements.
AlgorithmSection
(elements)¶
-
class
modparc.syntax.syntax_elements.
Annotation
(elements)¶
-
class
modparc.syntax.syntax_elements.
Argument
(elements)¶
-
class
modparc.syntax.syntax_elements.
ArgumentList
(elements)¶
-
class
modparc.syntax.syntax_elements.
ArithmeticExpression
(elements)¶
-
class
modparc.syntax.syntax_elements.
ArraySubscript
(elements)¶
-
class
modparc.syntax.syntax_elements.
Assertion
(elements)¶
-
class
modparc.syntax.syntax_elements.
BasePrefix
(elements)¶
-
class
modparc.syntax.syntax_elements.
ClassDefinition
(elements)¶
-
class
modparc.syntax.syntax_elements.
ClassModification
(elements)¶
-
class
modparc.syntax.syntax_elements.
ClassPrefixes
(elements)¶
-
class
modparc.syntax.syntax_elements.
ClassSpecifier
(elements)¶
-
class
modparc.syntax.syntax_elements.
Comment
(elements)¶
-
class
modparc.syntax.syntax_elements.
ComponentClause
(elements)¶
-
class
modparc.syntax.syntax_elements.
ComponentClause1
(elements)¶
-
class
modparc.syntax.syntax_elements.
ComponentDeclaration
(elements)¶
-
class
modparc.syntax.syntax_elements.
ComponentDeclaration1
(elements)¶
-
class
modparc.syntax.syntax_elements.
ComponentList
(elements)¶
-
class
modparc.syntax.syntax_elements.
ComponentReference
(elements)¶
-
class
modparc.syntax.syntax_elements.
Composition
(elements)¶
-
class
modparc.syntax.syntax_elements.
ConditionAttribute
(elements)¶
-
class
modparc.syntax.syntax_elements.
ConnectClause
(elements)¶
-
class
modparc.syntax.syntax_elements.
ConstrainingClause
(elements)¶
-
class
modparc.syntax.syntax_elements.
Declaration
(elements)¶
-
class
modparc.syntax.syntax_elements.
Element
(elements)¶
-
class
modparc.syntax.syntax_elements.
ElementList
(elements)¶
-
class
modparc.syntax.syntax_elements.
ElementModification
(elements)¶
-
class
modparc.syntax.syntax_elements.
ElementModificationOrReplaceable
(elements)¶
-
class
modparc.syntax.syntax_elements.
ElementRedeclaration
(elements)¶
-
class
modparc.syntax.syntax_elements.
ElementReplaceable
(elements)¶
-
class
modparc.syntax.syntax_elements.
EnumList
(elements)¶
-
class
modparc.syntax.syntax_elements.
EnumerationLiteral
(elements)¶
-
class
modparc.syntax.syntax_elements.
Equation
(elements)¶
-
class
modparc.syntax.syntax_elements.
EquationSection
(elements)¶
-
class
modparc.syntax.syntax_elements.
Expression
(elements)¶
-
class
modparc.syntax.syntax_elements.
ExpressionList
(elements)¶
-
class
modparc.syntax.syntax_elements.
ExtendsClause
(elements)¶
-
class
modparc.syntax.syntax_elements.
ExternalFunctionCall
(elements)¶
-
class
modparc.syntax.syntax_elements.
Factor
(elements)¶
-
class
modparc.syntax.syntax_elements.
ForEquation
(elements)¶
-
class
modparc.syntax.syntax_elements.
ForIndex
(elements)¶
-
class
modparc.syntax.syntax_elements.
ForIndices
(elements)¶
-
class
modparc.syntax.syntax_elements.
ForStatement
(elements)¶
-
class
modparc.syntax.syntax_elements.
FunctionArgument
(elements)¶
-
class
modparc.syntax.syntax_elements.
FunctionArguments
(elements)¶
-
class
modparc.syntax.syntax_elements.
FunctionCallArgs
(elements)¶
-
class
modparc.syntax.syntax_elements.
IfEquation
(elements)¶
-
class
modparc.syntax.syntax_elements.
IfStatement
(elements)¶
-
class
modparc.syntax.syntax_elements.
ImportClause
(elements)¶
-
class
modparc.syntax.syntax_elements.
ImportList
(elements)¶
-
class
modparc.syntax.syntax_elements.
LanguageSpecification
(elements)¶
-
class
modparc.syntax.syntax_elements.
LogicalExpression
(elements)¶
-
class
modparc.syntax.syntax_elements.
LogicalFactor
(elements)¶
-
class
modparc.syntax.syntax_elements.
LogicalTerm
(elements)¶
-
class
modparc.syntax.syntax_elements.
Modification
(elements)¶
-
class
modparc.syntax.syntax_elements.
MulOp
(elements)¶
-
class
modparc.syntax.syntax_elements.
Name
(elements)¶
-
class
modparc.syntax.syntax_elements.
NamedArgument
(elements)¶
-
class
modparc.syntax.syntax_elements.
NamedArguments
(elements)¶
-
class
modparc.syntax.syntax_elements.
OutputExpressionList
(elements)¶
-
class
modparc.syntax.syntax_elements.
Primary
(elements)¶
-
class
modparc.syntax.syntax_elements.
RelOp
(elements)¶
-
class
modparc.syntax.syntax_elements.
Relation
(elements)¶
-
class
modparc.syntax.syntax_elements.
ShortClassDefinition
(elements)¶
-
class
modparc.syntax.syntax_elements.
SimpleExpression
(elements)¶
-
class
modparc.syntax.syntax_elements.
Statement
(elements)¶
-
class
modparc.syntax.syntax_elements.
StoredDefinition
(elements)¶
-
class
modparc.syntax.syntax_elements.
StringComment
(elements)¶
-
class
modparc.syntax.syntax_elements.
Subscript
(elements)¶
-
class
modparc.syntax.syntax_elements.
SyntaxElement
(elements)[source]¶ Bases:
object
The class is a base implementation for all the syntax elements
All the derived classes would inherit this syntax element, and they only differ in their names.
The base implemenation provides possibility for inspection and querying the parsed syntax elements.
-
code
()[source]¶ Create a predefined representation of all the tokens in the instance
Returns: formatted tokens contained in the instance
-
static
find
(syntax_element, type_name, result)[source]¶ Search the matching elements with pre-order tree trasversal
Parameters: - syntax_element – the syntax element to be explored
- type_name – type name to be searched
- result – mutable list to store the results
Returns: no explicit return, communication through result variable
-
-
class
modparc.syntax.syntax_elements.
Term
(elements)¶
-
class
modparc.syntax.syntax_elements.
TypePrefix
(elements)¶
-
class
modparc.syntax.syntax_elements.
TypeSpecifier
(elements)¶
-
class
modparc.syntax.syntax_elements.
WhenEquation
(elements)¶
-
class
modparc.syntax.syntax_elements.
WhenStatement
(elements)¶
-
class
modparc.syntax.syntax_elements.
WhileEquation
(elements)¶
-
class
modparc.syntax.syntax_elements.
WhileStatement
(elements)¶
Module contents¶
syntax¶
The main utilities module for the parser implementation, with tokenizer and parser creation functions.
-
modparc.syntax.
keyword
(key, combinator=<function a>)[source]¶ Parser to match a keyword token with a key and a combinator
Parameters: - key – exact key of the keyword, e.g.: begin, assert etc.
- combinator – use the combinator to create a parser
Returns: a parser that matches a keyword
-
modparc.syntax.
language_element
(key, tok_type, combinator=<function a>)[source]¶ Parser to match language element by using a certain combinator
Parameters: - key – exact key of the token, e.g.: begin, model, )
- tok_type – predefined token type to be matched
- combinator – use the combinator to create a parser
Returns: a parser that matches elements using the above condition
-
modparc.syntax.
op
(key, combinator=<function a>)[source]¶ Parser to match a operator token with a key and a combinator
Parameters: - key – exact key of the operator, e.g.: +, .* etc.
- combinator – use the combinator to create a parser
Returns: a parser that matches an operator