Absyn

OpenModelicaParser.Absyn is the abstract syntax of Modelica and MetaModelica: the tree that parseFile, parseString and Modelica"..." return. Each kind of node is an abstract type, and its forms are immutable records (structs) of that type: test them with isa or match on them. Lists are ImmutableList lists; optional fields are Option{T} (Some{T} or nothing). The fields are described by comments in src/Absyn/Absyn.jl.

import OpenModelicaParser
import OpenModelicaParser.Absyn
program = OpenModelicaParser.parseString("model M Real x; equation x = 1; end M;", "M.mo")
cls = first(program.classes)        # an Absyn.CLASS
cls.name                            # "M"
cls.restriction isa Absyn.R_MODEL   # true
cls.info.lineNumberStart            # 1

The tree

A PROGRAM holds the classes of a file and its within clause. A CLASS has a name, its prefixes, a Restriction, a body (ClassDef) and its position in the source (SourceInfo). A body of parts lists public and protected elements, equations and algorithms.

TypeRecords
ProgramPROGRAM
WithinWITHIN, TOP
ClassCLASS
ClassDefPARTS, DERIVED, ENUMERATION, OVERLOAD, CLASS_EXTENDS, PDER
ClassPartPUBLIC, PROTECTED, EQUATIONS, INITIALEQUATIONS, ALGORITHMS, INITIALALGORITHMS, CONSTRAINTS, EXTERNAL
ElementItemELEMENTITEM, LEXER_COMMENT
ElementELEMENT, DEFINEUNIT, TEXT
ElementSpecCLASSDEF, EXTENDS, IMPORT, COMPONENTS
ImportNAMED_IMPORT, QUAL_IMPORT, UNQUAL_IMPORT, GROUP_IMPORT
ComponentItem, ComponentCOMPONENTITEM, COMPONENT
ModificationCLASSMOD
ElementArgMODIFICATION, REDECLARATION, INHERITANCEBREAK
EquationItemEQUATIONITEM, EQUATIONITEMCOMMENT
EquationEQ_EQUALS, EQ_CONNECT, EQ_IF, EQ_FOR, EQ_WHEN_E, EQ_NORETCALL, EQ_FAILURE, EQ_PDE, EQ_RECONFIGURE
AlgorithmItemALGORITHMITEM, ALGORITHMITEMCOMMENT
AlgorithmALG_ASSIGN, ALG_IF, ALG_FOR, ALG_PARFOR, ALG_WHILE, ALG_WHEN_A, ALG_NORETCALL, ALG_RETURN, ALG_BREAK, ALG_CONTINUE, ALG_FAILURE, ALG_TRY
ExpINTEGER, REAL, STRING, BOOL, CREF, BINARY, UNARY, LBINARY, LUNARY, RELATION, IFEXP, CALL, PARTEVALFUNCTION, ARRAY, MATRIX, RANGE, TUPLE, END, CODE, AS, CONS, MATCHEXP, LIST, DOT, SUBSCRIPTED_EXP, EXPRESSIONCOMMENT, BREAK
ComponentRefCREF_IDENT, CREF_QUAL, CREF_FULLYQUALIFIED, WILD, ALLWILD
PathIDENT, QUALIFIED, FULLYQUALIFIED
SubscriptSUBSCRIPT, NOSUB
TypeSpecTPATH, TCOMPLEX
Restriction22 records: R_MODEL, R_BLOCK, R_CONNECTOR, R_RECORD, R_FUNCTION, R_PACKAGE, R_TYPE, ...
Comment, AnnotationCOMMENT, ANNOTATION
SourceInfoSOURCEINFO

Source positions, the optional type, printing

OpenModelicaParser.Absyn — Module
OpenModelicaParser.Absyn

The abstract syntax of Modelica and MetaModelica: the records that OpenModelicaParser.Parser builds and the frontend instantiates. Formerly the package Absyn.jl (1.4.2); import OpenModelicaParser.Absyn keeps the name Absyn in the code that uses it.

source
OpenModelicaParser.Absyn.SOURCEINFO — Type
SOURCEINFO(fileName, isReadOnly, lineNumberStart, columnNumberStart, lineNumberEnd, columnNumberEnd[,
           lastModification])

The file (isReadOnly: true for libraries), the start and end positions, and the file's modification time (stat(2) mtime as Float64; 0.0 when not given).

source
OpenModelicaParser.Absyn.dumpBinary — Method

A binary or logical operation: the right operand in parentheses also when it binds as tightly (a - (b - c)) or is a unary operation (a + (-b): Modelica allows a unary operator only at the start); ^ takes no operator expression unparenthesised on either side.

source
OpenModelicaParser.Absyn.dumpPrecedence — Method

How tightly an expression binds, higher is tighter: if-expressions and ranges, or, and, not, relations, + -, * /, unary + -, ^, then primaries. Unary minus binds tighter than * (-a*x) and looser than ^ ((-a)^2).

source
OpenModelicaParser.Absyn.Optional — Module

Option{T}: Union{Some{T}, Nothing}, MetaModelica's optional type. In a submodule, used without importing the name, so @exportAll does not export it: MetaModelica exports Option, and two exported bindings of one name clash in code that uses both.

source