Commit 26369f30 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] gt_visitors: Add docs

parent 00f1bdb6
......@@ -36,10 +36,10 @@
## 35042 RENNES Cedex, FRANCE
##
##
## Contributor(s): Geoffroy Andrieux, Nolwenn Le Meur
## Contributor(s): Geoffroy Andrieux, Nolwenn Le Meur, Pierre Vignet
##
"""
Utilities for compiling conditions, event and constraints
Utilities for compiling conditions, events and constraints
"""
from antlr4 import InputStream, CommonTokenStream, RecognitionException
......@@ -47,24 +47,20 @@ from cadbiom.models.biosignal.translators.sigexpr_lexer import sigexpr_lexer
from cadbiom.models.biosignal.translators.sigexpr_compiler import sigexpr_compiler
# GT2MCSysVisitor compile a MC model from a guarded transition model
# mangling constants
ENVAC = "_envac"
ENVINAC = "_envinac"
ACT = "_activ"
INACT = "_inac"
UPDAT = "_update"
def compile_cond(text, symb_table, error_reporter, deep=-1, message=""):
"""Compile a condition expression to a tree representation
@param text: string to be compiled
@param symb_table: symbol table of the compiler
@param error_reporter: use a CompilReporter for full information!!
@param deep: optional - if >0 the compiler doesn't accept states
declared inside macro
@return: a tree representing the expression
:param text: string to be compiled
:param symb_table: symbol table of the compiler.
See :class:`cadbiom.models.clause_constraints.CLDynSys.CLDynSys`
:param error_reporter: use a CompilReporter for full information!!
:param deep: optional - if > 0 the compiler doesn't accept states
declared inside macro
:type text: <str>
:type symb_table: <dict <str>: <tuple <str>, <int>>>
:type error_reporter: <Reporter>
:type deep: <int>
:return: a tree representing the expression
"""
text_c = text + " $"
reader = InputStream(text_c)
......@@ -92,10 +88,14 @@ def compile_cond(text, symb_table, error_reporter, deep=-1, message=""):
def compile_constraint(const_txt, symb_table, error_reporter):
"""Compile a constraint expression to a tree representation
@param const_txt: string to be compiled
@param symb_table: symbol table of the compiler
@param error_reporter: output error messages
@return: a tree representing the expression
:param const_txt: string to be compiled
:param symb_table: symbol table of the compiler.
See :class:`cadbiom.models.clause_constraints.CLDynSys.CLDynSys`
:param error_reporter: output error messages
:type const_txt: <str>
:type symb_table: <dict <str>: <tuple <str>, <int>>>
:type error_reporter: <Reporter>
:return: a tree representing the expression
"""
text_c = const_txt + " $"
reader = InputStream(text_c)
......@@ -114,14 +114,20 @@ def compile_constraint(const_txt, symb_table, error_reporter):
def compile_event(text, symb_table, free_clocks, error_reporter):
"""Compile an event expression to a tree representation
@param text: string to be compiled
@param symb_table: symbol table of the compiler
@param free_clocks: boolean if true free clocks are collected
@param error_reporter: output error messages
@return: a triple exp, se, fc
:param text: string to be compiled
:param symb_table: symbol table of the compiler.
See :class:`cadbiom.models.clause_constraints.CLDynSys.CLDynSys`
:param free_clocks: boolean if true free clocks are collected
:param error_reporter: output error messages
:type text: <str>
:type symb_table: <dict <str>: <tuple <str>, <int>>>
:type free_clocks: <boolean>
:type error_reporter: <Reporter>
:return: a tuple (exp, se, fc)
where exp is the event expression,
se the state events (s#> ..) used and
fc is the free clocks used in the event expression.
:rtype: <tuple>
"""
text_c = text + " $"
reader = InputStream(text_c)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment