Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
7060c3db
Commit
7060c3db
authored
Nov 17, 2014
by
Maxime Perrotin
Browse files
Support extra parameters in Ada backend
parent
da1fff7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
AdaGenerator.py
View file @
7060c3db
...
@@ -90,7 +90,7 @@ PROCEDURES = []
...
@@ -90,7 +90,7 @@ PROCEDURES = []
UNICODE_SEP
=
u
'
\u00dc
'
UNICODE_SEP
=
u
'
\u00dc
'
@
singledispatch
@
singledispatch
def
generate
(
ast
):
def
generate
(
*
args
,
**
kwargs
):
''' Generate the code for an item of the AST '''
''' Generate the code for an item of the AST '''
raise
TypeError
(
'[AdaGenerator] Unsupported AST construct'
)
raise
TypeError
(
'[AdaGenerator] Unsupported AST construct'
)
return
[],
[]
return
[],
[]
...
@@ -98,7 +98,7 @@ def generate(ast):
...
@@ -98,7 +98,7 @@ def generate(ast):
# Processing of the AST
# Processing of the AST
@
generate
.
register
(
ogAST
.
Process
)
@
generate
.
register
(
ogAST
.
Process
)
def
_process
(
process
):
def
_process
(
process
,
simu
=
False
,
**
kwargs
):
''' Generate the code for a complete process (AST Top level) '''
''' Generate the code for a complete process (AST Top level) '''
process_name
=
process
.
processName
process_name
=
process
.
processName
global
TYPES
global
TYPES
...
@@ -479,7 +479,7 @@ def write_statement(param, newline):
...
@@ -479,7 +479,7 @@ def write_statement(param, newline):
@
generate
.
register
(
ogAST
.
Output
)
@
generate
.
register
(
ogAST
.
Output
)
@
generate
.
register
(
ogAST
.
ProcedureCall
)
@
generate
.
register
(
ogAST
.
ProcedureCall
)
def
_call_external_function
(
output
):
def
_call_external_function
(
output
,
**
kwargs
):
''' Generate the code of a set of output or procedure call statement '''
''' Generate the code of a set of output or procedure call statement '''
code
=
[]
code
=
[]
local_decl
=
[]
local_decl
=
[]
...
@@ -605,7 +605,7 @@ def _call_external_function(output):
...
@@ -605,7 +605,7 @@ def _call_external_function(output):
@
generate
.
register
(
ogAST
.
TaskAssign
)
@
generate
.
register
(
ogAST
.
TaskAssign
)
def
_task_assign
(
task
):
def
_task_assign
(
task
,
**
kwargs
):
''' A list of assignments in a task symbol '''
''' A list of assignments in a task symbol '''
code
,
local_decl
=
[],
[]
code
,
local_decl
=
[],
[]
if
task
.
comment
:
if
task
.
comment
:
...
@@ -620,7 +620,7 @@ def _task_assign(task):
...
@@ -620,7 +620,7 @@ def _task_assign(task):
@
generate
.
register
(
ogAST
.
TaskInformalText
)
@
generate
.
register
(
ogAST
.
TaskInformalText
)
def
_task_informal_text
(
task
):
def
_task_informal_text
(
task
,
**
kwargs
):
''' Generate Ada comments for informal text '''
''' Generate Ada comments for informal text '''
code
=
[]
code
=
[]
if
task
.
comment
:
if
task
.
comment
:
...
@@ -630,7 +630,7 @@ def _task_informal_text(task):
...
@@ -630,7 +630,7 @@ def _task_informal_text(task):
@
generate
.
register
(
ogAST
.
TaskForLoop
)
@
generate
.
register
(
ogAST
.
TaskForLoop
)
def
_task_forloop
(
task
):
def
_task_forloop
(
task
,
**
kwargs
):
'''
'''
Return the code corresponding to a for loop. Two forms are possible:
Return the code corresponding to a for loop. Two forms are possible:
for x in range ([start], stop [, step])
for x in range ([start], stop [, step])
...
@@ -1454,7 +1454,7 @@ def _choiceitem(choice):
...
@@ -1454,7 +1454,7 @@ def _choiceitem(choice):
@
generate
.
register
(
ogAST
.
Decision
)
@
generate
.
register
(
ogAST
.
Decision
)
def
_decision
(
dec
):
def
_decision
(
dec
,
**
kwargs
):
''' generate the code for a decision '''
''' generate the code for a decision '''
code
,
local_decl
=
[],
[]
code
,
local_decl
=
[],
[]
if
dec
.
kind
==
'any'
:
if
dec
.
kind
==
'any'
:
...
@@ -1559,7 +1559,7 @@ def _decision(dec):
...
@@ -1559,7 +1559,7 @@ def _decision(dec):
@
generate
.
register
(
ogAST
.
Label
)
@
generate
.
register
(
ogAST
.
Label
)
def
_label
(
lab
):
def
_label
(
lab
,
**
kwargs
):
''' Transition following labels are generated in a separate section
''' Transition following labels are generated in a separate section
for visibility reasons (see Ada scope)
for visibility reasons (see Ada scope)
'''
'''
...
@@ -1567,7 +1567,7 @@ def _label(lab):
...
@@ -1567,7 +1567,7 @@ def _label(lab):
@
generate
.
register
(
ogAST
.
Transition
)
@
generate
.
register
(
ogAST
.
Transition
)
def
_transition
(
tr
):
def
_transition
(
tr
,
**
kwargs
):
''' generate the code for a transition '''
''' generate the code for a transition '''
code
,
local_decl
=
[],
[]
code
,
local_decl
=
[],
[]
empty_transition
=
all
(
isinstance
(
act
,
ogAST
.
TaskInformalText
)
empty_transition
=
all
(
isinstance
(
act
,
ogAST
.
TaskInformalText
)
...
@@ -1635,7 +1635,7 @@ def _transition(tr):
...
@@ -1635,7 +1635,7 @@ def _transition(tr):
@
generate
.
register
(
ogAST
.
Floating_label
)
@
generate
.
register
(
ogAST
.
Floating_label
)
def
_floating_label
(
label
):
def
_floating_label
(
label
,
**
kwargs
):
''' Generate the code for a floating label (Ada label + transition) '''
''' Generate the code for a floating label (Ada label + transition) '''
code
=
[]
code
=
[]
local_decl
=
[]
local_decl
=
[]
...
@@ -1652,7 +1652,7 @@ def _floating_label(label):
...
@@ -1652,7 +1652,7 @@ def _floating_label(label):
@
generate
.
register
(
ogAST
.
Procedure
)
@
generate
.
register
(
ogAST
.
Procedure
)
def
_inner_procedure
(
proc
):
def
_inner_procedure
(
proc
,
**
kwargs
):
''' Generate the code for a procedure - does not support states '''
''' Generate the code for a procedure - does not support states '''
code
=
[]
code
=
[]
local_decl
=
[]
local_decl
=
[]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment