uppaal2jetracer.declarations package

Submodules

uppaal2jetracer.declarations.declarations_ast module

Declarations Abstract Syntax Tree (AST)

This file provides the definitions of various nodes used to represent a C syntax tree. It is utilized by pycparser to construct and process abstract syntax trees (ASTs) for C code. The nodes defined here implement the visitor pattern, allowing tree traversal and manipulation.

Based on the c_ast.py from the pycparser project by Eli Bendersky (https://eli.thegreenplace.net) under the BSD license.

This file can be imported and contains the following classes:

  • Node: Abstract base class for all AST nodes.

  • NodeVisitor: Base class for visitor implementations for traversing AST nodes.

  • ArrayDecl: Represents an array declaration node.

  • ArrayRef: Represents an array reference node.

  • Assignment: Represents an assignment operation node.

  • BinaryOp: Represents a binary operation node.

  • Compound: Represents a compound statement node.

  • CompoundLiteral: Represents a compound literal node.

  • Decl: Represents a declaration node.

  • DeclList: Represents a list of declarations node.

  • EmptyStatement: Represents an empty statement node.

  • ExprList: Represents a list of expressions node.

  • FileAST: Represents the root node of the syntax tree, containing the file’s AST.

  • FuncCall: Represents a function call node.

  • FuncDecl: Represents a function declaration node.

  • FuncDef: Represents a function definition node.

  • ID: Represents an identifier node.

  • IdentifierType: Represents a type identifier node.

  • InitList: Represents an initialization list node.

  • NamedInitializer: Represents a named initializer node.

  • ParamList: Represents a list of parameters node.

  • RangeDecl: Represents a range declaration node.

  • Return: Represents a return statement node.

  • Struct: Represents a struct declaration node.

  • StructRef: Represents a struct reference node.

  • TypeDecl: Represents a type declaration node.

  • Typedef: Represents a type definition node.

  • Typename: Represents a type name node.

  • UnaryOp: Represents a unary operation node.

The classes marked by a “#” (DoWhile, For, If, While) were kept from the original implementation for the C programming language together with the respective rules in the Declaration Parser. This means UPPAAL code with loops and if statements is parsable and results in a correct AST. However, the NodeVisitor does not support them as they were no use case for the uppaal2jetracer project. In consequence neither the Executor nor the Tree Visitor support them. To support the execution of those control structures, the NodeVisitor needs to be extended and their functionality needs to be implemented in the Executor.

class ArrayDecl(type, dim, dim_quals, coord=None)[source]

Bases: Node

Represents a nested declaration of an array with the given type.

Variables:
  • type (Node) – The base type of the array.

  • dim (int) – The dimension (e.g., constant 42).

  • dim_quals (list) – List of dimension qualifiers, supporting C99’s ‘const’ and ‘static’ in array dimensions.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('dim_quals',)
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
dim
dim_quals
type
class ArrayRef(name, subscript, coord=None)[source]

Bases: Node

Represents an array reference in the AST.

Variables:
  • name (Node) – The name of the array being referenced.

  • subscript (Node) – The index or subscript of the array.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
name
subscript
class Assignment(op, lvalue, rvalue, coord=None)[source]

Bases: Node

Represents an assignment operation in the AST.

Variables:
  • op (str) – The assignment operator (e.g., “=”, “+=”).

  • lvalue (Node) – The left-hand side of the assignment.

  • rvalue (Node) – The right-hand side of the assignment.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('op',)
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord: Coord
lvalue: Node
op: str
rvalue: Node
class BinaryOp(op, left, right, coord=None)[source]

Bases: Node

Represents a binary operation in the AST.

Variables:
  • op (str) – The binary operator (e.g., “+”, “-”, “*”, “/”).

  • left (Node) – The left operand of the binary operation.

  • right (Node) – The right operand of the binary operation.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('op',)
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
left
op
right
class Compound(block_items, coord=None)[source]

Bases: Node

Represents a compound statement (block) in the AST.

Variables:

block_items (list[Node]) – A list of statements or declarations within the block.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
block_items
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
class CompoundLiteral(type, init, coord=None)[source]

Bases: Node

Represents a compound literal (anonymous aggregate).

Variables:
  • type (Node) – The type of the compound literal.

  • init (Node) – The initializer for the compound literal.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
init
type
class Constant(type, value, coord=None)[source]

Bases: Node

Represents a constant value in the AST.

Variables:
  • type (str) – The type of the constant (e.g., “int”, “double”, “char”, “string”).

  • value (str) – The value of the constant.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('type', 'value')
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
type
value
class Decl(name, quals, is_typedef, funcspec, type, init, coord=None)[source]

Bases: Node

Represents a variable or type declaration in the AST.

Variables:
  • name (str) – The name of the declared variable or type.

  • quals (list[str]) – A list of qualifiers (e.g., “const”, “volatile”).

  • type (Node) – The declaration type, possibly nested with modifiers.

  • init (Node) – The initialization value, or None if not initialized.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('name', 'quals', 'is_typedef', 'funcspec')
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
funcspec
init
is_typedef
name
quals
type
class DeclList(decls, coord=None)[source]

Bases: Node

Represents a list of declarations in the AST.

Variables:

decls (list[Node]) – A list of declarations.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
decls
class DoWhile(cond, stmt, coord=None)[source]

Bases: Node

Represents a do while loop in the AST. NOT SUPPORTED BY NODEVISITOR!

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

cond
coord
stmt
class EmptyStatement(coord=None)[source]

Bases: Node

Represents an empty statement (a semicolon “;” on its own).

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
class ExprList(exprs, coord=None)[source]

Bases: Node

Represents a list of expressions separated by the comma operator.

Variables:

exprs (list[Node]) – A list of expressions.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
exprs
class FileAST(ext, coord=None)[source]

Bases: Node

Represents the top-level AST node for an UPPAAL file (a translation unit).

Variables:

ext (list[Node]) – A list of external declarations or definitions in the file.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
ext
class For(init, cond, next_, stmt, coord=None)[source]

Bases: Node

Represents a for loop in the AST. NOT SUPPORTED BY NODEVISITOR!

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

cond
coord
init
next
stmt
class FuncCall(name, args, coord=None)[source]

Bases: Node

Represents a function call in the AST.

Variables:
  • name (str) – The name of the function being called.

  • args (Node) – The arguments passed to the function.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

args
attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
name
class FuncDecl(args, type, coord=None)[source]

Bases: Node

Represents a function declaration in the AST.

Variables:
  • args (Node) – The parameters of the function.

  • type (Node) – The return type of the function.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

args
attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
type
class FuncDef(decl, param_decls, body, coord=None)[source]

Bases: Node

Represents a function definition in the AST.

Variables:
  • decl (Node) – The declarator for the function name.

  • param_decls (list[Node]) – A list of parameter declarations (optional, for K&R-style definitions).

  • body (Node) – The body of the function (a compound statement).

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
body
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
decl
param_decls
class ID(name, coord=None)[source]

Bases: Node

Represents an identifier in the AST.

Variables:

name (str) – The name of the identifier.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('name',)
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
name
class IdentifierType(names, coord=None)[source]

Bases: Node

Represents a holder for types that are a simple identifier (e.g., built-in types like “int”).

Variables:

names (list[str]) – A list of type names (e.g., [“unsigned”, “int”]).

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('names',)
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
names
class If(cond, iftrue, iffalse, coord=None)[source]

Bases: Node

Represents an if statement in the AST. NOT SUPPORTED BY NODEVISITOR!

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

cond
coord
iffalse
iftrue
class InitList(exprs, coord=None)[source]

Bases: Node

Represents an initialization list used for compound literals.

Variables:

exprs (list[Node]) – A list of expressions for initialization.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
exprs
class NamedInitializer(name, expr, coord=None)[source]

Bases: Node

Represents a named initializer for C99.

Variables:
  • name (list[Node]) – A sequence of nodes representing the name (e.g., hierarchical or constant expressions).

  • expr (Node) – The expression initializing the name.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
expr
name
class Node[source]

Bases: ABC

Abstract base class for AST nodes.

Each node represents a specific construct in the C code and can be visited using a NodeVisitor.

abstract accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

abstract children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

class NodeVisitor[source]

Bases: ABC

Base class for visiting AST nodes using the Visitor pattern.

This class defines a set of methods, one for each type of AST node, which must be implemented by subclasses.

abstract visit_arraydecl(array_decl: ArrayDecl)[source]

Abstract method to visit an ArrayDecl node. Return depends on implementation of this method.

Parameters:

array_decl (ArrayDecl) – The array declaration node.

abstract visit_arrayref(array_ref: ArrayRef)[source]

Abstract method to visit an ArrayRef node. Return depends on implementation of this method.

Parameters:

array_ref (ArrayRef) – The array reference node.

abstract visit_assignment(assignment: Assignment)[source]

Abstract method to visit an Assignment node. Return depends on implementation of this method.

Parameters:

assignment (Assignment) – The assignment node.

abstract visit_binaryop(binaryop: BinaryOp)[source]

Abstract method to visit a BinaryOp node. Return depends on implementation of this method.

Parameters:

binaryop (BinaryOp) – The binary operation node.

abstract visit_compound(compound: Compound)[source]

Abstract method to visit a Compound node. Return depends on implementation of this method.

Parameters:

compound (Compound) – The compound node.

abstract visit_compoundliteral(compound_literal: CompoundLiteral)[source]

Abstract method to visit a CompoundLiteral node. Return depends on implementation of this method.

Parameters:

compound_literal (CompoundLiteral) – The compound literal node.

abstract visit_constant(constant: Constant)[source]

Abstract method to visit a Constant node. Return depends on implementation of this method.

Parameters:

constant (Constant) – The constant node.

abstract visit_decl(decl: Decl)[source]

Abstract method to visit a Decl node. Return depends on implementation of this method.

Parameters:

decl (Decl) – The declaration node.

abstract visit_decllist(decl_list: DeclList)[source]

Abstract method to visit a DeclList node. Return depends on implementation of this method.

Parameters:

decl_list (DeclList) – The declaration list node.

abstract visit_emptystatement()[source]

Abstract method to visit an EmptyStatement node. Return depends on implementation of this method.

abstract visit_exprlist(expr_list: ExprList)[source]

Abstract method to visit an ExprList node. Return depends on implementation of this method.

Parameters:

expr_list (ExprList) – The expression list node.

abstract visit_fileast(fileast: FileAST)[source]

Abstract method to visit a FileAST node. Return depends on implementation of this method.

Parameters:

fileast (FileASt) – The fileast node.

abstract visit_funccall(funccall: FuncCall)[source]

Abstract method to visit a FuncCall node. Return depends on implementation of this method.

Parameters:

funccall (FuncCall) – The function call node.

abstract visit_funcdecl(funcdecl: FuncDecl)[source]

Abstract method to visit a FuncDecl node. Return depends on implementation of this method.

Parameters:

funcdecl (FuncDecl) – The function declaration node.

abstract visit_funcdef(funcdef: FuncDef)[source]

Abstract method to visit a FuncDef node. Return depends on implementation of this method.

Parameters:

funcdef (FuncDef) – The function definition node.

abstract visit_id(identifier: ID)[source]

Abstract method to visit an ID node. Return depends on implementation of this method.

Parameters:

identifier (ID) – The identifier node.

abstract visit_identifiertype(identifier_type: IdentifierType)[source]

Abstract method to visit an IdentifierType node. Return depends on implementation of this method.

Parameters:

identifier_type (IdentifierType) – The identifier type node.

abstract visit_initlist(init_list: InitList)[source]

Abstract method to visit an InitList node. Return depends on implementation of this method.

Parameters:

init_list (InitList) – The initialization list node.

abstract visit_namedinitializer(named_initializer: NamedInitializer)[source]

Abstract method to visit a NamedInitializer node. Return depends on implementation of this method.

Parameters:

named_initializer (NamedInitializer) – The named initializer node.

abstract visit_paramlist(param_list: ParamList)[source]

Abstract method to visit a ParamList node. Return depends on implementation of this method.

Parameters:

param_list (ParamList) – The parameter list node.

abstract visit_rangedecl(range_decl: RangeDecl)[source]

Abstract method to visit a RangeDecl node. Return depends on implementation of this method.

Parameters:

range_decl (RangeDecl) – The range declaration node.

abstract visit_return(ret: Return)[source]

Abstract method to visit a Return node. Return depends on implementation of this method.

Parameters:

ret (Return) – The return node.

abstract visit_struct(struct: Struct)[source]

Abstract method to visit a Struct node. Return depends on implementation of this method.

Parameters:

struct (Struct) – The struct node.

abstract visit_structref(structref: StructRef)[source]

Abstract method to visit a StructRef node. Return depends on implementation of this method.

Parameters:

structref (StructRef) – The struct reference node.

abstract visit_typedecl(typedecl: TypeDecl)[source]

Abstract method to visit a TypeDecl node. Return depends on implementation of this method.

Parameters:

typedecl (TypeDecl) – The type declaration node.

abstract visit_typedef(typedef: Typedef)[source]

Abstract method to visit a Typedef node. Return depends on implementation of this method.

Parameters:

typedef (Typedef) – The type definition node.

abstract visit_typename(typename: Typename)[source]

Abstract method to visit a Typename node. Return depends on implementation of this method.

Parameters:

typename (Typename) – The type name node.

abstract visit_unaryop(unaryop: UnaryOp)[source]

Abstract method to visit a UnaryOp node. Return depends on implementation of this method.

Parameters:

unaryop (UnaryOp) – The unary operation node.

class ParamList(params, coord=None)[source]

Bases: Node

Represents a list of function parameter declarations.

Variables:

params (list[Node]) – A list of parameter declarations.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
params
class RangeDecl(type, lower, upper, coord=None)[source]

Bases: Node

Represents an UPPAAL range declaration.

Variables:
  • type (Node) – The range type, possibly nested with modifiers.

  • lower (Node) – The lower bound of the range (integer or ID).

  • upper (Node) – The upper bound of the range (integer or ID).

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
lower
type
upper
class Return(expr, coord=None)[source]

Bases: Node

Represents a return statement in the AST.

Variables:

expr (Node or None) – The expression being returned, or None if it’s a void return.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
expr
class Struct(name, decls, coord=None)[source]

Bases: Node

Represents a struct declaration in the AST.

Variables:
  • name (str) – The tag name of the struct.

  • decls (list[Node]) – The declarations of members in the struct.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('name',)
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
decls
name
class StructRef(name, type, field, coord=None)[source]

Bases: Node

Represents a reference to a struct field.

Variables:
  • name (Node) – The struct being referenced.

  • type (str) – The type of reference (“.” for member access or “->” for pointer dereference).

  • field (Node) – The field being accessed in the struct.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('type',)
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
field
name
type
class TypeDecl(declname, quals, type, coord=None)[source]

Bases: Node

Represents a base type declaration in the AST.

Variables:
  • declname (str) – The name of the declaration.

  • quals (list[str]) – A list of qualifiers (e.g., “const”, “volatile”).

  • type (Node) – The type of the declaration.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('declname', 'quals')
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
declname
quals
type
class Typedef(name, quals, is_typedef, type, coord=None)[source]

Bases: Node

Represents a typedef declaration in the AST.

Variables:
  • name (str) – The name of the typedef.

  • quals (list[str]) – A list of qualifiers (e.g., “const”, “volatile”).

  • is_typedef (bool) – The is_typedef flag.

  • type (Node) – The type being defined by the typedef.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('name', 'quals', 'is_typedef')
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
is_typedef
name
quals
type
class Typename(name, quals, type, coord=None)[source]

Bases: Node

Represents a typename in the AST.

Variables:
  • name (str or None) – The name of the typename (or None for unnamed types).

  • quals (list[str]) – A list of qualifiers (e.g., “const”, “volatile”).

  • type (Node) – The type being referred to by the typename.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('name', 'quals')
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
name
quals
type
class UnaryOp(op, expr, coord=None)[source]

Bases: Node

Represents a unary operation in the AST.

Variables:
  • op (str) – The unary operator (e.g., “-”, “!”, “~”).

  • expr (Node) – The operand of the unary operation.

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ('op',)
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

coord
expr
op
class While(cond, stmt, coord=None)[source]

Bases: Node

Represents a while loop in the AST. NOT SUPPORTED BY NODEVISITOR!

accept(node_visitor: NodeVisitor)[source]

Abstract method to accept a visitor for traversing or processing the node.

Parameters:

node_visitor (NodeVisitor) – NodeVisitor, which implements the specific visit method for this type of node.

Returns:

Depends on the NodeVisitor

attr_names = ()
children()[source]

Returns a sequence of all child nodes.

Returns:

An iterable containing the child nodes of the current node.

cond
coord
stmt

uppaal2jetracer.declarations.declarations_tree_visitor module

Declarations Tree Visitor

This file provides a Visitor to traverse an AST and return a string representation of the node structure for debugging purposes.

This file can be imported and contains the following classes:

  • DeclarationsTreeVisitor: NodeVisitor that traverses the declarations and returns a string.

class DeclarationsTreeVisitor[source]

Bases: NodeVisitor

Declarations Tree Visitor

An implementation of the class:NodeVisitor. It returns a string representation of the AST’s node structure for debugging purposes.

visit_arraydecl(array_decl: ArrayDecl)[source]

Abstract method to visit an ArrayDecl node. Return depends on implementation of this method.

Parameters:

array_decl (ArrayDecl) – The array declaration node.

visit_arrayref(array_ref: ArrayRef)[source]

Abstract method to visit an ArrayRef node. Return depends on implementation of this method.

Parameters:

array_ref (ArrayRef) – The array reference node.

visit_assignment(assignment: Assignment)[source]

Abstract method to visit an Assignment node. Return depends on implementation of this method.

Parameters:

assignment (Assignment) – The assignment node.

visit_binaryop(binaryop: BinaryOp)[source]

Abstract method to visit a BinaryOp node. Return depends on implementation of this method.

Parameters:

binaryop (BinaryOp) – The binary operation node.

visit_compound(compound: Compound)[source]

Abstract method to visit a Compound node. Return depends on implementation of this method.

Parameters:

compound (Compound) – The compound node.

visit_compoundliteral(compound_literal: CompoundLiteral)[source]

Abstract method to visit a CompoundLiteral node. Return depends on implementation of this method.

Parameters:

compound_literal (CompoundLiteral) – The compound literal node.

visit_constant(constant: Constant)[source]

Abstract method to visit a Constant node. Return depends on implementation of this method.

Parameters:

constant (Constant) – The constant node.

visit_decl(decl: Decl)[source]

Abstract method to visit a Decl node. Return depends on implementation of this method.

Parameters:

decl (Decl) – The declaration node.

visit_decllist(decl_list: DeclList)[source]

Abstract method to visit a DeclList node. Return depends on implementation of this method.

Parameters:

decl_list (DeclList) – The declaration list node.

visit_emptystatement()[source]

Abstract method to visit an EmptyStatement node. Return depends on implementation of this method.

visit_exprlist(expr_list: ExprList)[source]

Abstract method to visit an ExprList node. Return depends on implementation of this method.

Parameters:

expr_list (ExprList) – The expression list node.

visit_fileast(fileast: FileAST)[source]

Abstract method to visit a FileAST node. Return depends on implementation of this method.

Parameters:

fileast (FileASt) – The fileast node.

visit_funccall(funccall: FuncCall)[source]

Abstract method to visit a FuncCall node. Return depends on implementation of this method.

Parameters:

funccall (FuncCall) – The function call node.

visit_funcdecl(funcdecl: FuncDecl)[source]

Abstract method to visit a FuncDecl node. Return depends on implementation of this method.

Parameters:

funcdecl (FuncDecl) – The function declaration node.

visit_funcdef(funcdef: FuncDef)[source]

Abstract method to visit a FuncDef node. Return depends on implementation of this method.

Parameters:

funcdef (FuncDef) – The function definition node.

visit_id(identifier: ID)[source]

Abstract method to visit an ID node. Return depends on implementation of this method.

Parameters:

identifier (ID) – The identifier node.

visit_identifiertype(identifier_type: IdentifierType)[source]

Abstract method to visit an IdentifierType node. Return depends on implementation of this method.

Parameters:

identifier_type (IdentifierType) – The identifier type node.

visit_initlist(init_list: InitList)[source]

Abstract method to visit an InitList node. Return depends on implementation of this method.

Parameters:

init_list (InitList) – The initialization list node.

visit_namedinitializer(named_initializer: NamedInitializer)[source]

Abstract method to visit a NamedInitializer node. Return depends on implementation of this method.

Parameters:

named_initializer (NamedInitializer) – The named initializer node.

visit_paramlist(param_list: ParamList)[source]

Abstract method to visit a ParamList node. Return depends on implementation of this method.

Parameters:

param_list (ParamList) – The parameter list node.

visit_rangedecl(range_decl: RangeDecl)[source]

Abstract method to visit a RangeDecl node. Return depends on implementation of this method.

Parameters:

range_decl (RangeDecl) – The range declaration node.

visit_return(ret: Return)[source]

Abstract method to visit a Return node. Return depends on implementation of this method.

Parameters:

ret (Return) – The return node.

visit_struct(struct: Struct)[source]

Abstract method to visit a Struct node. Return depends on implementation of this method.

Parameters:

struct (Struct) – The struct node.

visit_structref(structref: StructRef)[source]

Abstract method to visit a StructRef node. Return depends on implementation of this method.

Parameters:

structref (StructRef) – The struct reference node.

visit_typedecl(typedecl: TypeDecl)[source]

Abstract method to visit a TypeDecl node. Return depends on implementation of this method.

Parameters:

typedecl (TypeDecl) – The type declaration node.

visit_typedef(typedef: Typedef)[source]

Abstract method to visit a Typedef node. Return depends on implementation of this method.

Parameters:

typedef (Typedef) – The type definition node.

visit_typename(typename: Typename)[source]

Abstract method to visit a Typename node. Return depends on implementation of this method.

Parameters:

typename (Typename) – The type name node.

visit_unaryop(unaryop: UnaryOp)[source]

Abstract method to visit a UnaryOp node. Return depends on implementation of this method.

Parameters:

unaryop (UnaryOp) – The unary operation node.

Module contents