Compare commits
11 commits
05c8f92683
...
1da53dba48
Author | SHA1 | Date | |
---|---|---|---|
ayrton | 1da53dba48 | ||
ayrton | 88ef999640 | ||
ayrton | 4d8609c38e | ||
ayrton | 09010a4789 | ||
ayrton | fb36aef06e | ||
ayrton | 561a9a5efa | ||
ayrton | 1e22f5a968 | ||
ayrton | d6f9a8684a | ||
ayrton | 54118b996d | ||
ayrton | ce7a660c00 | ||
ayrton | d211131c4e |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
fuzzer/
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
|
|
@ -4,24 +4,23 @@ This is a hecking fuzzer. It does the thing.
|
|||
|
||||
## Requirements
|
||||
- Python 3.11
|
||||
- ISLa Solver (`pip install isla-solver`)
|
||||
- English Words (`pip install english-words`) (so that you don't have an anurism while reading random names)
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
usage: gazprea_fuzzer.py [-h] [-b BATCH] [--seed SEED] config_file
|
||||
usage: gazprea_fuzzer.py [-h] [-b BATCH_SIZE] [--seed SEED] config_file file_name
|
||||
|
||||
Procedurally generate a test case for Gazprea
|
||||
|
||||
positional arguments:
|
||||
config_file path to your configuration file
|
||||
file_name name for the generated files
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
-b BATCH, --batch BATCH
|
||||
generate SIZE cases (fuzzer/input/nameX.in,
|
||||
/instream/..., /outputs/...)
|
||||
-b BATCH_SIZE, --batch_size BATCH_SIZE
|
||||
generate BATCH cases (fuzzer/source/nameX.in, /instream/..., /outputs/...)
|
||||
--seed SEED rng seed
|
||||
```
|
||||
|
||||
|
|
|
@ -2,10 +2,13 @@ import random
|
|||
import string
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
# from english_words import get_english_words_set
|
||||
from english_words import get_english_words_set
|
||||
|
||||
from ast_generator.utils import Variable, Argument, Routine, Scope, build_xml_element
|
||||
from constants import *
|
||||
|
||||
import keyword
|
||||
|
||||
|
||||
class AstGenerator:
|
||||
"""
|
||||
|
@ -33,18 +36,17 @@ class AstGenerator:
|
|||
"""
|
||||
self.settings = settings
|
||||
|
||||
self.symbol_table = [] # TODO this should be a list of scopes
|
||||
self.symbol_table = []
|
||||
global_scope = Scope(None, None)
|
||||
self.symbol_table.append(global_scope) # NOTE for debug
|
||||
self.current_scope = global_scope
|
||||
|
||||
# names = get_english_words_set(['web2'], lower=True)
|
||||
names = random.choices(string.ascii_letters, k=self.settings['properties']['id-length']['max'])
|
||||
possible_names = filter(lambda x: self.settings['properties']['id-length']['min'] < len(x)
|
||||
< self.settings['properties']['id-length']['max'], names)
|
||||
names = get_english_words_set(['web2'], alpha=True)
|
||||
possible_names = filter(lambda x: self.settings['properties']['id-length']['max'] <= len(x) <=
|
||||
self.settings['properties']['id-length']['max'] and not keyword.iskeyword(x), names)
|
||||
|
||||
var_name_len = len(list(possible_names))
|
||||
var_name_list = list(possible_names)
|
||||
var_name_len = len(var_name_list)
|
||||
self.variable_names = var_name_list[0:var_name_len // 2]
|
||||
self.routine_names = var_name_list[var_name_len // 2:var_name_len]
|
||||
|
||||
|
@ -53,6 +55,84 @@ class AstGenerator:
|
|||
self.current_nesting_depth = 0
|
||||
self.current_control_flow_nesting_depth = 0
|
||||
|
||||
# Numberlines - For computing probabilities
|
||||
self.int_op_options, self.int_op_cutoffs, self.int_op_numline = (
|
||||
self.get_numberlines('expression-weights',
|
||||
['brackets', 'arithmetic', 'unary'],
|
||||
[[], [], ['not']]))
|
||||
self.int_unary = ['negation', 'noop']
|
||||
|
||||
self.bool_op_options, self.bool_op_cutoffs, self.bool_op_numline = (
|
||||
self.get_numberlines('expression-weights',
|
||||
['brackets', 'comparison', 'logical', 'unary'],
|
||||
excluded_values=[[], ['less-than-or-equal', 'greater-than-or-equal', 'less-than',
|
||||
'greater-than'], [], ['noop', 'negation']]))
|
||||
self.bool_unary = ['not']
|
||||
|
||||
self.float_op_options, self.float_op_cutoffs, self.float_op_numline = (
|
||||
self.get_numberlines('expression-weights',
|
||||
['brackets', 'arithmetic', 'unary'],
|
||||
[[], [], ['not']]))
|
||||
self.float_unary = ['negation', 'noop']
|
||||
|
||||
self.char_op_options, self.char_op_cutoffs, self.char_op_numline = (
|
||||
self.get_numberlines('expression-weights',
|
||||
['brackets', 'comparison'],
|
||||
[[], ['less-than', 'greater-than', 'less-than-or-equal', 'greater-than-or-equal']]))
|
||||
|
||||
self.comp_op_options, self.comp_op_cutoffs, self.comp_op_numline = (
|
||||
self.get_numberlines('expression-weights',
|
||||
['brackets', 'comparison'],
|
||||
[[], []]))
|
||||
|
||||
def get_numberlines(self, settings_section: str, subsettings: list[str], excluded_values):
|
||||
assert len(subsettings) == len(excluded_values)
|
||||
|
||||
number_line = 0
|
||||
cutoffs = []
|
||||
cutoff = 0
|
||||
options = {}
|
||||
option = 0
|
||||
|
||||
settings = []
|
||||
|
||||
for key, value in self.settings[settings_section].items():
|
||||
if key in subsettings and key not in excluded_values: # this check needs to be done recursively
|
||||
if isinstance(value, int):
|
||||
t = {
|
||||
key: value
|
||||
}
|
||||
settings.append(t)
|
||||
elif isinstance(value, dict):
|
||||
settings.append(value)
|
||||
else:
|
||||
raise TypeError("invalid setting type. Found " + str(value) + " instead of expected int or dict")
|
||||
|
||||
for v in range(len(settings)):
|
||||
for i in excluded_values:
|
||||
for j in i:
|
||||
if j in settings[v]:
|
||||
settings[v].pop(j)
|
||||
|
||||
for v in settings:
|
||||
if isinstance(v, dict):
|
||||
for key, value in v.items():
|
||||
number_line += value
|
||||
cutoffs.append(cutoff + value)
|
||||
cutoff += value
|
||||
options[option] = key
|
||||
option += 1
|
||||
elif isinstance(v, int):
|
||||
number_line += v
|
||||
cutoffs.append(cutoff + v)
|
||||
cutoff += v
|
||||
options[option] = v
|
||||
option += 1
|
||||
else:
|
||||
raise TypeError("invalid setting type. Found " + str(v) + " instead of expected int")
|
||||
|
||||
return options, cutoffs, number_line
|
||||
|
||||
def generate_ast(self):
|
||||
"""
|
||||
@brief generates an AST from a grammar
|
||||
|
@ -91,7 +171,10 @@ class AstGenerator:
|
|||
self.pop_scope()
|
||||
self.current_ast_element = parent
|
||||
|
||||
def generate_block(self, tag=None, return_stmt=False, return_value=None, return_type=None):
|
||||
def generate_block(self, tag=None, return_stmt=False, return_value=None, return_type=None, block_type=None,
|
||||
loop_var=None):
|
||||
# TODO this should be broken into many functions depending on the block requirements
|
||||
|
||||
if tag is None:
|
||||
tag = []
|
||||
parent = self.current_ast_element
|
||||
|
@ -99,6 +182,12 @@ class AstGenerator:
|
|||
element = build_xml_element(tag, name=GAZ_BLOCK_TAG)
|
||||
self.current_ast_element.append(element)
|
||||
self.current_ast_element = element
|
||||
|
||||
# Generate the loop condition increment if we are in a loop
|
||||
if block_type == GAZ_LOOP_TAG:
|
||||
self.generate_loop_condition_check(loop_var)
|
||||
self.generate_loop_condition_increment(loop_var)
|
||||
|
||||
self.generate_statements()
|
||||
if return_stmt:
|
||||
self.generate_return(return_type=return_type, return_value=return_value)
|
||||
|
@ -107,6 +196,81 @@ class AstGenerator:
|
|||
self.pop_scope()
|
||||
self.current_ast_element = parent
|
||||
|
||||
def generate_loop_condition_check(self, loop_var: Variable):
|
||||
"""
|
||||
@brief generates the loop condition check
|
||||
|
||||
Ensures that the loop does not iterate more than max-loop-iterations times
|
||||
|
||||
@param loop_var:
|
||||
@return:
|
||||
"""
|
||||
# loop var is always an int
|
||||
assert loop_var.type == GAZ_INT_KEY
|
||||
|
||||
# create a conditional xml tag
|
||||
if_stmt = build_xml_element([], name=GAZ_IF_TAG)
|
||||
self.current_ast_element.append(if_stmt)
|
||||
parent = self.current_ast_element
|
||||
self.current_ast_element = if_stmt
|
||||
|
||||
# add the check 'if loop_var >= self.settings['generation_options']['max-loop-iterations']: break'
|
||||
operation = build_xml_element([("op", ">=")], name=GAZ_OPERATOR_TAG)
|
||||
self.current_ast_element.append(operation)
|
||||
self.current_ast_element = operation
|
||||
|
||||
lhs = build_xml_element([], name=GAZ_LHS_TAG)
|
||||
operation.append(lhs)
|
||||
|
||||
var = build_xml_element([("name", loop_var.name), ("type", loop_var.type)], name=GAZ_VAR_TAG)
|
||||
lhs.append(var)
|
||||
|
||||
rhs = build_xml_element([], name=GAZ_RHS_TAG)
|
||||
operation.append(rhs)
|
||||
rhs.append(self.make_literal(GAZ_INT_KEY, "'" + str(self.settings['generation-options']['max-loop-iterations']) + "'"))
|
||||
|
||||
true_block = build_xml_element([], name=GAZ_BLOCK_TAG)
|
||||
if_stmt.append(true_block)
|
||||
self.current_ast_element = true_block
|
||||
break_stmt = build_xml_element([], name=GAZ_BREAK_TAG)
|
||||
true_block.append(break_stmt)
|
||||
|
||||
# return everything to normalcy
|
||||
self.current_ast_element = parent
|
||||
|
||||
def generate_loop_condition_increment(self, loop_var):
|
||||
assert loop_var.type == GAZ_INT_KEY
|
||||
|
||||
parent = self.current_ast_element
|
||||
assignment = build_xml_element([], name=GAZ_ASSIGNMENT_TAG)
|
||||
self.current_ast_element.append(assignment)
|
||||
self.current_ast_element = assignment
|
||||
|
||||
# append the variable
|
||||
self.current_ast_element.append(loop_var.xml)
|
||||
|
||||
# add the increment 'loop_var += 1'
|
||||
assn_rhs = build_xml_element([], name=GAZ_RHS_TAG)
|
||||
self.current_ast_element.append(assn_rhs)
|
||||
self.current_ast_element = assn_rhs
|
||||
|
||||
operation = build_xml_element([("op", "+")], name=GAZ_OPERATOR_TAG)
|
||||
self.current_ast_element.append(operation)
|
||||
self.current_ast_element = operation
|
||||
|
||||
lhs = build_xml_element([], name=GAZ_LHS_TAG)
|
||||
operation.append(lhs)
|
||||
|
||||
var = build_xml_element([("name", loop_var.name), ("type", loop_var.type)], name=GAZ_VAR_TAG)
|
||||
lhs.append(var)
|
||||
|
||||
rhs = build_xml_element([], name=GAZ_RHS_TAG)
|
||||
operation.append(rhs)
|
||||
rhs.append(self.make_literal(GAZ_INT_KEY, '1'))
|
||||
|
||||
# return everything to normalcy
|
||||
self.current_ast_element = parent
|
||||
|
||||
def generate_return(self, return_type=None, return_value=None):
|
||||
if return_type is None or return_type == GAZ_VOID_TYPE:
|
||||
self.current_ast_element.append(build_xml_element([], name=GAZ_RETURN_TAG))
|
||||
|
@ -167,7 +331,7 @@ class AstGenerator:
|
|||
|
||||
def generate_statements(self):
|
||||
# Number line
|
||||
number_line = 180 #TODO fix the numberline stuff to reflect the settings
|
||||
number_line = 180 # TODO fix the numberline stuff to reflect the settings
|
||||
cutoffs = [10, 30, 50, 80, 100, 140, 180]
|
||||
options = {
|
||||
0: self.generate_declaration,
|
||||
|
@ -193,53 +357,42 @@ class AstGenerator:
|
|||
break
|
||||
break
|
||||
|
||||
def generate_int_real_expr(self):
|
||||
# Number line
|
||||
number_line = 100
|
||||
cutoffs = [10, 30, 50, 80, 100]
|
||||
options = { #TODO add brackets
|
||||
0: "addition",
|
||||
1: "subtraction",
|
||||
2: "multiplication",
|
||||
3: "division",
|
||||
4: "modulo",
|
||||
5: "power",
|
||||
6: "negation",
|
||||
7: "noop",
|
||||
8: "equality",
|
||||
9: "inequality",
|
||||
10: "less-than",
|
||||
11: "greater-than",
|
||||
12: "less-than-or-equal",
|
||||
13: "greater-than-or-equal",
|
||||
}
|
||||
def generate_int_expr(self):
|
||||
self._generate_expression([GAZ_INT_KEY],
|
||||
self.int_op_numline,
|
||||
self.int_op_cutoffs,
|
||||
self.int_op_options,
|
||||
self.int_unary)
|
||||
|
||||
unary = ["negation", "noop"]
|
||||
|
||||
self._generate_expression([GAZ_INT_KEY, GAZ_FLOAT_KEY], number_line, cutoffs, options, unary)
|
||||
def generate_float_expr(self):
|
||||
self._generate_expression([GAZ_FLOAT_KEY, GAZ_INT_KEY],
|
||||
self.float_op_numline,
|
||||
self.float_op_cutoffs,
|
||||
self.float_op_options,
|
||||
self.float_unary)
|
||||
|
||||
def generate_bool_expr(self):
|
||||
# Number line
|
||||
number_line = 100
|
||||
cutoffs = [10, 30, 50, 80, 100]
|
||||
options = { #TODO add brackets # TODO cannot guarantee correctness of comparison since booleans may appear
|
||||
0: "equality",
|
||||
1: "inequality",
|
||||
2: "less-than",
|
||||
3: "greater-than",
|
||||
4: "less-than-or-equal",
|
||||
5: "greater-than-or-equal",
|
||||
6: "and",
|
||||
7: "or",
|
||||
8: "xor",
|
||||
9: "not",
|
||||
}
|
||||
self._generate_expression([GAZ_BOOL_KEY],
|
||||
self.bool_op_numline,
|
||||
self.bool_op_cutoffs,
|
||||
self.bool_op_options,
|
||||
self.bool_unary)
|
||||
|
||||
unary = ["not"]
|
||||
def generate_char_expr(self):
|
||||
self._generate_expression([GAZ_CHAR_KEY],
|
||||
self.char_op_numline,
|
||||
self.char_op_cutoffs,
|
||||
self.char_op_options)
|
||||
|
||||
self._generate_expression([GAZ_BOOL_KEY], number_line, cutoffs, options, unary)
|
||||
def generate_comp_expr(self):
|
||||
self._generate_expression([GAZ_BOOL_KEY],
|
||||
self.comp_op_numline,
|
||||
self.comp_op_cutoffs,
|
||||
self.comp_op_options,
|
||||
comparison=True)
|
||||
|
||||
def _generate_expression(self, expr_type: list[str], number_line, cutoffs, options, unary=None):
|
||||
def _generate_expression(self, expr_type: list[str], number_line,
|
||||
cutoffs, options, unary=None, comparison: bool = False):
|
||||
if unary is None:
|
||||
unary = []
|
||||
|
||||
|
@ -248,7 +401,7 @@ class AstGenerator:
|
|||
|
||||
if self.current_nesting_depth > self.settings['generation-options']['max-nesting-depth'] or random.random() < \
|
||||
self.settings['block-termination-probability']:
|
||||
self.generate_literal(random.choice(expr_type)) # TODO add the reals
|
||||
self.generate_literal(random.choice(expr_type))
|
||||
self.current_nesting_depth -= 1
|
||||
return
|
||||
|
||||
|
@ -266,6 +419,13 @@ class AstGenerator:
|
|||
|
||||
if op in unary:
|
||||
self.generate_unary(op, random.choice(expr_type))
|
||||
elif op == GAZ_BRACKET_TAG:
|
||||
self.generate_bracket(random.choice(expr_type))
|
||||
elif comparison:
|
||||
if op in ['equality', 'inequality']:
|
||||
self.generate_binary(op, random.choice([GAZ_INT_KEY, GAZ_FLOAT_KEY, GAZ_CHAR_KEY]))
|
||||
else:
|
||||
self.generate_binary(op, random.choice([GAZ_INT_KEY, GAZ_FLOAT_KEY]))
|
||||
else:
|
||||
self.generate_binary(op, random.choice(expr_type))
|
||||
|
||||
|
@ -306,13 +466,26 @@ class AstGenerator:
|
|||
|
||||
self.current_ast_element = parent
|
||||
|
||||
def generate_xhs(self, handedness, op_type):
|
||||
def generate_bracket(self, op_type):
|
||||
parent = self.current_ast_element
|
||||
args = [
|
||||
("type", op_type),
|
||||
]
|
||||
element = build_xml_element(args, name=GAZ_BRACKET_TAG)
|
||||
self.current_ast_element.append(element)
|
||||
self.current_ast_element = element
|
||||
|
||||
self.generate_xhs(GAZ_RHS_TAG, op_type)
|
||||
|
||||
self.current_ast_element = parent
|
||||
|
||||
def generate_xhs(self, handedness, op_type, is_zero=False):
|
||||
element = build_xml_element([], name=handedness)
|
||||
parent = self.current_ast_element
|
||||
self.current_ast_element.append(element)
|
||||
self.current_ast_element = element
|
||||
|
||||
self.generate_expression(op_type)
|
||||
self.generate_expression(op_type, is_zero=is_zero)
|
||||
|
||||
self.current_ast_element = parent
|
||||
|
||||
|
@ -337,7 +510,8 @@ class AstGenerator:
|
|||
if self.current_control_flow_nesting_depth >= self.settings['generation-options']['max-nesting-depth']:
|
||||
return
|
||||
|
||||
if self.current_control_flow_nesting_depth > 0 and random.random() < self.settings['block-termination-probability']:
|
||||
if self.current_control_flow_nesting_depth > 0 and random.random() < self.settings[
|
||||
'block-termination-probability']:
|
||||
return
|
||||
|
||||
element = build_xml_element([], name=GAZ_IF_TAG)
|
||||
|
@ -357,13 +531,16 @@ class AstGenerator:
|
|||
self.pop_scope()
|
||||
self.current_ast_element = parent
|
||||
|
||||
def generate_loop(self):
|
||||
def generate_loop(self): # fixme generation of infinite loops happens too often...
|
||||
# FIXME make sure that loop conditions are evaluated at least once (assert true or make a config param)
|
||||
if self.current_control_flow_nesting_depth >= self.settings['generation-options']['max-nesting-depth']:
|
||||
return
|
||||
|
||||
if self.current_control_flow_nesting_depth > 0 and random.random() < self.settings['block-termination-probability']:
|
||||
if self.current_control_flow_nesting_depth > 0 and random.random() < self.settings[
|
||||
'block-termination-probability']:
|
||||
return
|
||||
|
||||
init_var = self.generate_zero_declaration()
|
||||
parent = self.current_ast_element
|
||||
element = build_xml_element([], name=GAZ_LOOP_TAG)
|
||||
self.current_ast_element.append(element)
|
||||
|
@ -372,10 +549,26 @@ class AstGenerator:
|
|||
self.current_control_flow_nesting_depth += 1
|
||||
self.push_scope()
|
||||
self.generate_expression(GAZ_BOOL_KEY)
|
||||
self.generate_block()
|
||||
self.generate_block(block_type=GAZ_LOOP_TAG,
|
||||
loop_var=init_var) # append a variable increment and prepend a break statement if var is > max loop iterations
|
||||
self.pop_scope()
|
||||
self.current_ast_element = parent
|
||||
|
||||
def generate_zero_declaration(self):
|
||||
parent = self.current_ast_element
|
||||
element = build_xml_element([], name=GAZ_DECLARATION_TAG)
|
||||
|
||||
self.current_ast_element.append(element)
|
||||
self.current_ast_element = element
|
||||
|
||||
variable = self.generate_variable(GAZ_INT_KEY, 'var')
|
||||
self.current_ast_element.append(variable.xml)
|
||||
self.current_scope.append(variable.name, variable)
|
||||
|
||||
self.generate_xhs(GAZ_RHS_TAG, variable.type, is_zero=True)
|
||||
self.current_ast_element = parent
|
||||
|
||||
return variable
|
||||
|
||||
def generate_assignment(self):
|
||||
possible_vars = self.current_scope.get_all_defined_mutable_vars()
|
||||
|
@ -389,7 +582,6 @@ class AstGenerator:
|
|||
self.current_ast_element.append(element)
|
||||
self.current_ast_element = element
|
||||
|
||||
|
||||
variable = random.choice(possible_vars)
|
||||
|
||||
self.current_ast_element.append(variable.xml)
|
||||
|
@ -422,11 +614,14 @@ class AstGenerator:
|
|||
else:
|
||||
return Variable(self.get_name(GAZ_VAR_TAG), var_type, mut)
|
||||
|
||||
|
||||
def generate_literal(self, var_type: str):
|
||||
def generate_literal(self, var_type: str, value=None):
|
||||
if value is None:
|
||||
value = self.get_value(var_type)
|
||||
else:
|
||||
value = value
|
||||
args = [
|
||||
("type", var_type),
|
||||
("value", str(self.get_value(var_type))),
|
||||
("value", str(value)),
|
||||
]
|
||||
element = build_xml_element(args, name=GAZ_LIT_TAG)
|
||||
self.current_ast_element.append(element)
|
||||
|
@ -446,18 +641,26 @@ class AstGenerator:
|
|||
self.current_scope = self.current_scope.get_top_scope()
|
||||
self.current_ast_element = self.ast
|
||||
|
||||
self.generate_declaration()
|
||||
self.generate_declaration(mut='const')
|
||||
|
||||
self.current_scope = current_scope
|
||||
self.current_ast_element = current_element
|
||||
|
||||
def generate_expression(self, expr_type: str):
|
||||
if expr_type == GAZ_INT_KEY or expr_type == GAZ_FLOAT_KEY:
|
||||
self.generate_int_real_expr()
|
||||
def generate_expression(self, expr_type: str, is_zero=False):
|
||||
if is_zero:
|
||||
self.generate_literal(expr_type, value=0)
|
||||
return
|
||||
elif expr_type == GAZ_INT_KEY or expr_type == GAZ_FLOAT_KEY:
|
||||
self.generate_int_expr()
|
||||
elif expr_type == GAZ_BOOL_KEY:
|
||||
self.generate_bool_expr()
|
||||
if random.random() < 0.5:
|
||||
self.generate_bool_expr()
|
||||
else:
|
||||
self.generate_comp_expr()
|
||||
elif expr_type == GAZ_CHAR_KEY:
|
||||
self.generate_char_expr()
|
||||
elif expr_type == ANY_TYPE: # TODO implement the choice of any type
|
||||
self.generate_int_real_expr()
|
||||
self.generate_int_expr()
|
||||
else:
|
||||
raise NotImplementedError(f"Expression type {expr_type} not implemented")
|
||||
|
||||
|
@ -490,7 +693,7 @@ class AstGenerator:
|
|||
@return a qualifier as a string
|
||||
"""
|
||||
number_line = (self.settings["misc-weights"]["type-qualifier-weights"]["const"] +
|
||||
self.settings["misc-weights"]["type-qualifier-weights"]["var"] -1 )
|
||||
self.settings["misc-weights"]["type-qualifier-weights"]["var"] - 1)
|
||||
|
||||
res = random.randint(0, number_line)
|
||||
if res in range(0, self.settings["misc-weights"]["type-qualifier-weights"]["const"]):
|
||||
|
@ -526,6 +729,8 @@ class AstGenerator:
|
|||
return random.uniform(-1000, 1000)
|
||||
elif type == GAZ_BOOL_KEY:
|
||||
return random.choice([True, False])
|
||||
elif type == GAZ_CHAR_KEY:
|
||||
return "'" + random.choice(string.ascii_letters) + "'"
|
||||
else:
|
||||
raise TypeError("Unimplemented generator for type: " + type)
|
||||
|
||||
|
@ -536,26 +741,20 @@ class AstGenerator:
|
|||
@param name_type:
|
||||
@return:
|
||||
"""
|
||||
length = random.randint(self.settings['properties']['id-length']['min'],
|
||||
self.settings['properties']['id-length']['max'])
|
||||
name = ''.join(random.choices(string.ascii_letters, k=length))
|
||||
return name
|
||||
|
||||
def get_op(self, type):
|
||||
|
||||
if type == GAZ_INT_KEY:
|
||||
cutoffs = []
|
||||
values = []
|
||||
ops = []
|
||||
for key, value in self.settings["expression-weights"]["arithmetic"]:
|
||||
cutoffs.append(value + sum(cutoffs))
|
||||
values.append(value)
|
||||
ops.append(get_op(key))
|
||||
|
||||
res = random.randint(0, sum(values))
|
||||
for i in range(len(cutoffs)):
|
||||
if res < cutoffs[i]:
|
||||
return ops[i]
|
||||
if not self.settings['properties']['use-english-words']:
|
||||
length = random.randint(self.settings['properties']['id-length']['min'],
|
||||
self.settings['properties']['id-length']['max'])
|
||||
name = ''.join(random.choices(string.ascii_letters, k=length))
|
||||
return name
|
||||
else:
|
||||
if name_type == GAZ_VAR_TAG:
|
||||
choice = random.choice(self.variable_names)
|
||||
self.variable_names.remove(choice)
|
||||
return choice
|
||||
else:
|
||||
choice = random.choice(self.routine_names)
|
||||
self.routine_names.remove(choice)
|
||||
return choice
|
||||
|
||||
def get_type(self, tag): # TODO Add support for composite types
|
||||
return 'int' # TODO Add support for all types
|
||||
|
@ -574,141 +773,3 @@ class AstGenerator:
|
|||
for i in range(len(cutoffs)):
|
||||
if res < cutoffs[i]:
|
||||
return types[i]
|
||||
|
||||
|
||||
class Variable:
|
||||
def __init__(self, name: str, type: str, qualifier: str, value: any = None):
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.value = value
|
||||
self.qualifier = qualifier
|
||||
self.xml = self._build_xml()
|
||||
|
||||
def _build_xml(self):
|
||||
args = [
|
||||
('name', self.name),
|
||||
('type', self.type),
|
||||
('mut', self.qualifier),
|
||||
]
|
||||
return build_xml_element(args, name=GAZ_VAR_TAG)
|
||||
|
||||
|
||||
class Argument:
|
||||
def __init__(self, name: str, type: str):
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.xml = self._build_xml()
|
||||
|
||||
def __str__(self):
|
||||
return self.type + " " + self.name
|
||||
|
||||
def _build_xml(self):
|
||||
args = [
|
||||
('name', self.name),
|
||||
('type', self.type),
|
||||
]
|
||||
return build_xml_element(args, name=GAZ_ARG_TAG)
|
||||
|
||||
|
||||
class Routine:
|
||||
def __init__(self, name: str, type: str, return_type: str, args: list[Argument], xml: ET.Element = None):
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.return_type = return_type
|
||||
self.arguments = args
|
||||
self.xml = xml
|
||||
self.xml = xml
|
||||
|
||||
|
||||
class Scope:
|
||||
def __init__(self, enclosing_scope, child_scope=None, associated_xml: ET.Element = None):
|
||||
self.symbols = {}
|
||||
self.enclosing_scope = enclosing_scope
|
||||
self.child_scope = child_scope
|
||||
self.xml = associated_xml
|
||||
|
||||
def resolve(self, name) -> ET.Element or None:
|
||||
if name in self.symbols:
|
||||
return self.symbols[name]
|
||||
else:
|
||||
return None
|
||||
|
||||
def append(self, name, item: Variable or Argument or Routine):
|
||||
self.symbols[name] = item
|
||||
|
||||
def append_element(self, name, value: ET.Element):
|
||||
self.symbols[name] = value
|
||||
|
||||
def set(self, name, value: ET.Element):
|
||||
self.symbols[name] = value
|
||||
|
||||
def get_all_defined_mutable_vars(self) -> list[Variable]:
|
||||
if self.enclosing_scope is None:
|
||||
return self._get_mutable_vars()
|
||||
else:
|
||||
return self.enclosing_scope.get_all_defined_mutable_vars() + self._get_mutable_vars()
|
||||
|
||||
def _get_mutable_vars(self) -> list[Variable]:
|
||||
mutable_vars = []
|
||||
|
||||
for name, var in self.symbols.items():
|
||||
if not isinstance(var, Variable):
|
||||
continue
|
||||
if var.qualifier != 'const':
|
||||
mutable_vars.append(self.symbols[name])
|
||||
return mutable_vars
|
||||
|
||||
def get_top_scope(self):
|
||||
if self.enclosing_scope is None:
|
||||
return self
|
||||
else:
|
||||
return self.enclosing_scope.get_top_scope()
|
||||
|
||||
|
||||
def build_xml_element(*keys, name):
|
||||
elem = ET.Element(name)
|
||||
for key in list(keys)[0]: # TODO refactor
|
||||
elem.set(key[0], key[1])
|
||||
return elem
|
||||
|
||||
|
||||
def get_op(op):
|
||||
if op == 'addition':
|
||||
return '+'
|
||||
elif op == 'subtraction':
|
||||
return '-'
|
||||
elif op == 'multiplication':
|
||||
return '*'
|
||||
elif op == 'division':
|
||||
return '/'
|
||||
elif op == 'modulo':
|
||||
return '%'
|
||||
elif op == 'power':
|
||||
return '^'
|
||||
elif op == 'or':
|
||||
return 'or'
|
||||
elif op == 'and':
|
||||
return 'and'
|
||||
elif op == 'equality':
|
||||
return '=='
|
||||
elif op == 'inequality':
|
||||
return '!='
|
||||
elif op == 'less-than':
|
||||
return '<'
|
||||
elif op == 'less-than-or-equal':
|
||||
return '<='
|
||||
elif op == 'greater-than':
|
||||
return '>'
|
||||
elif op == 'greater-than-or-equal':
|
||||
return '>='
|
||||
elif op == 'negation':
|
||||
return '-'
|
||||
elif op == 'not':
|
||||
return 'not'
|
||||
elif op == 'noop':
|
||||
return '+'
|
||||
elif op == 'concatenation':
|
||||
return '||'
|
||||
else:
|
||||
raise Exception("Unknown operator: " + op)
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import unittest
|
||||
import xml
|
||||
import xml.etree.ElementTree as ET
|
||||
import xml.dom.minidom
|
||||
|
||||
import yaml
|
||||
|
||||
from ast_generator.ast_generator import *
|
||||
from ast_generator.gazprea_ast_grammar import *
|
||||
from ast_generator.utils import Variable
|
||||
|
||||
|
||||
def reachable_return(block):
|
||||
|
@ -228,7 +227,7 @@ class TestGeneration(unittest.TestCase):
|
|||
# print("iteration: " + str(l))
|
||||
self.ast_gen.ast = ET.Element("block")
|
||||
self.ast_gen.current_ast_element = self.ast_gen.ast
|
||||
self.ast_gen.generate_int_real_expr()
|
||||
self.ast_gen.generate_int_expr()
|
||||
# self.write_ast()
|
||||
|
||||
if self.ast_gen.ast.find("operator") is None:
|
||||
|
@ -267,15 +266,12 @@ class TestGeneration(unittest.TestCase):
|
|||
def test_failing_assignment(self):
|
||||
self.ast_gen.ast = ET.Element("block")
|
||||
self.ast_gen.current_ast_element = self.ast_gen.ast
|
||||
# self.ast_gen.generate_main()
|
||||
with self.assertRaises(ValueError):
|
||||
self.ast_gen.generate_assignment()
|
||||
print(ET.tostring(self.ast_gen.ast, 'utf-8').decode('utf-8'))
|
||||
|
||||
self.assertIsNone(self.ast_gen.ast.find("assignment"))
|
||||
|
||||
|
||||
|
||||
|
||||
def is_no_op(self, operator):
|
||||
"""
|
||||
recursively check if operator is a no-op
|
||||
|
|
5122
ast_generator/test/xml/ast0.xml
Normal file
5122
ast_generator/test/xml/ast0.xml
Normal file
File diff suppressed because it is too large
Load diff
3192
ast_generator/test/xml/ast1.xml
Normal file
3192
ast_generator/test/xml/ast1.xml
Normal file
File diff suppressed because it is too large
Load diff
1394
ast_generator/test/xml/ast10.xml
Normal file
1394
ast_generator/test/xml/ast10.xml
Normal file
File diff suppressed because it is too large
Load diff
471
ast_generator/test/xml/ast11.xml
Normal file
471
ast_generator/test/xml/ast11.xml
Normal file
|
@ -0,0 +1,471 @@
|
|||
<block>
|
||||
<procedure name="main" return_type="int" args="()">
|
||||
<block>
|
||||
<return type="int">
|
||||
<literal type="int" value="0"/>
|
||||
</return>
|
||||
<stream type="std_output">
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="314.2266871191341"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-241.21664166820312"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
</block>
|
||||
</procedure>
|
||||
<function name="eW" return_type="int">
|
||||
<argument name="g" type="int"/>
|
||||
<argument name="GDUEYIipSt" type="int"/>
|
||||
<block>
|
||||
<declaration type="int">
|
||||
<variable name="Say" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1665738951"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="139.86158640644862"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="772509006"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-649.4294241575187"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="265.9685116353053"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-799.9949734775371"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1923533103"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-941.4029686824128"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="824.0735523578705"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-985.6412814884811"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-159.40159037510296"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1386411564"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1591711206"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-127.0430494010875"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-527.4944733203411"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="774177202"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-158812638"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<assignment>
|
||||
<variable name="Say" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="914793523"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1937356655"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="489.218538167064"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-414161182"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="650.3007997573827"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1979645026"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1416136146"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-411.1206483078911"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="767.0871225569206"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="811.1966660943963"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="103.14834036969614"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="2143674923"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-516.6041568838205"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-43.196377609604724"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-251.26908492535006"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="2102862513"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-788.424773416349"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="686248439"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1663561597"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="384631075"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-833.9029230404819"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1098477492"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</assignment>
|
||||
<return type="int">
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="174.93707879339513"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1381342040"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="874.6385020676307"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-751.4261809796049"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="25778016"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-308.91043711449356"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</return>
|
||||
<stream type="std_output">
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-478080710"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1247688226"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1668723401"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-415.88474440499294"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1027814199"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-361.3220068506513"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-339706165"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-992185978"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-484.35089403701954"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="109.67382107916842"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-2038884295"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="463.45832290675344"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="600.7608651825765"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="232.2518149247553"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-352.9351215605932"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1732315667"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="703480765"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="54.416126342769985"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="196.80181113204776"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="3.858371047113792"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
</block>
|
||||
</function>
|
||||
</block>
|
||||
|
1201
ast_generator/test/xml/ast12.xml
Normal file
1201
ast_generator/test/xml/ast12.xml
Normal file
File diff suppressed because it is too large
Load diff
463
ast_generator/test/xml/ast13.xml
Normal file
463
ast_generator/test/xml/ast13.xml
Normal file
|
@ -0,0 +1,463 @@
|
|||
<block>
|
||||
<procedure name="main" return_type="int" args="()">
|
||||
<block>
|
||||
<declaration type="int">
|
||||
<variable name="mtgqHyMR" type="int" mut="const"/>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-886.0949135168966"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-306721674"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="505.384240546746"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="644.8972883781132"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-2112855042"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-781.0138415122769"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="205.41249373358278"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1056378078"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-2028661745"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-378.4368829003138"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-161623317"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-842219085"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="20.263905912068594"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-452.05189940351227"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-633.8953115867257"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-912.441770503505"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-612.0623808756949"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1135585201"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<return type="int">
|
||||
<literal type="int" value="0"/>
|
||||
</return>
|
||||
<stream type="std_output">
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="399766159"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="2014917461"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="867.2183212429338"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-118.6161105454704"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-204.10116913366426"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="751.7762246394013"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="786062037"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="242383621"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-495168961"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1841981969"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="275.7114744278331"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1816859520"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-880.0217043467153"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-51556154"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="950.8363250531215"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="485.04787718219586"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1081890518"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-617554471"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="557.3688888036261"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1590018197"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="719.2896242851314"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
<stream type="std_output">
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="309.2004071522772"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-446658461"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="716.9460631063534"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="655298965"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1508954892"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="760.2915655536051"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="28583728"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="429.0156523389528"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="577.9876488452435"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="930.8535652247854"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-814.7548683779205"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-343046444"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="565.053588972037"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="937.8059780568267"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1730601731"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-518.9407078828895"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="448.6425050284274"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="187.11751419213647"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-2112467308"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1912369506"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-491.9568349060006"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="198427514"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="419.23917956954983"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-143555818"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1226638788"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1780107871"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1692858651"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
</block>
|
||||
</procedure>
|
||||
</block>
|
||||
|
768
ast_generator/test/xml/ast14.xml
Normal file
768
ast_generator/test/xml/ast14.xml
Normal file
|
@ -0,0 +1,768 @@
|
|||
<block>
|
||||
<procedure name="main" return_type="int" args="()">
|
||||
<block>
|
||||
<stream type="std_output">
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-67.75526424848397"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1570702545"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1139064342"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-587253194"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-859.0634099686765"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1308451787"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-816697988"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="350.70100394186056"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1484111038"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-773.4847755010039"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="167.7940931546293"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-88.33865142691661"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="907034114"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="460909479"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1719939865"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1123253746"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1290902317"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-441.3683853243582"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-946997372"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-775.8638746158608"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="689.5266358888487"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-898.4571992445709"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
<return type="int">
|
||||
<literal type="int" value="0"/>
|
||||
</return>
|
||||
<declaration type="int">
|
||||
<variable name="GwhdkLGQX" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<literal type="float" value="606.5426298463085"/>
|
||||
</rhs>
|
||||
</declaration>
|
||||
</block>
|
||||
</procedure>
|
||||
<function name="ZDXRWT" return_type="int">
|
||||
<argument name="Me" type="int"/>
|
||||
<argument name="f" type="int"/>
|
||||
<argument name="EgdQw" type="int"/>
|
||||
<argument name="MMLQqXFUNg" type="int"/>
|
||||
<argument name="fSESgBfmw" type="int"/>
|
||||
<argument name="oHaDTLvU" type="int"/>
|
||||
<argument name="avDWVRP" type="int"/>
|
||||
<block>
|
||||
<declaration type="int">
|
||||
<variable name="qKIeMD" type="int" mut="const"/>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1347725266"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="2106758124"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-399.5002378858363"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="438.9852092978954"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-286944467"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="312.966101335815"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="220.50930164623674"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1388954595"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-114.45471104309627"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1273645096"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-371.401868811986"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1123815717"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1653871188"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="2042072836"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-889.3745267690882"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-418.2947143416993"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="785.6330823015469"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-748.9147214928555"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1409661885"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-738843728"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="217.14338500371264"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="300.1884581798038"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="143.02822128737807"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-136045740"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="2121366436"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="12225528"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<declaration type="int">
|
||||
<variable name="bxLMkFGO" type="int" mut="const"/>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-909.1271474122651"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1504260861"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="189.006576852144"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-423593734"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="421.3753226828653"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-313.1093418883828"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="51617231"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-381.55305562061255"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="97.67899498921247"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1009491901"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1677366499"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-340532180"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-532311858"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1512846110"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="618.4426442556944"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-934.9115136694263"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="72.44707680822671"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-484.8091790077274"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<return type="int">
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-984.8072412782556"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1782244171"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1992820608"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="962.1536192886206"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1898497261"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-571.8412439815914"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-960.96955461872"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-834.496116772162"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1348537663"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="123699979"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-415.870300152053"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="54.84784192085158"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-593.389790416154"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</return>
|
||||
<stream type="std_output">
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1317336488"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="269.72508614247954"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="486913155"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="680667816"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="856.2057164451116"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="314920509"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-922.8238748478426"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-378.81250598576764"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1662430144"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="920842483"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
</block>
|
||||
</function>
|
||||
<function name="Lxe" return_type="int">
|
||||
<argument name="ouugz" type="int"/>
|
||||
<argument name="RbOujw" type="int"/>
|
||||
<block>
|
||||
<stream type="std_output">
|
||||
<literal type="float" value="-15.72531800465731"/>
|
||||
</stream>
|
||||
<return type="int">
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-43.755229743576365"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-932.1671571271519"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="521221712"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1434532637"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="12.512130687870126"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="59.298178601608925"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="233.89042601460164"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="711.6418015858287"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="531.4295701603933"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1802723949"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-392.4254090535402"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="154.20671006823227"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1052475485"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-379.47588475517534"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="641.673501781403"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1792314097"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-854.7221443550166"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</return>
|
||||
</block>
|
||||
</function>
|
||||
<function name="hkiO" return_type="int">
|
||||
<argument name="EuEfVFPO" type="int"/>
|
||||
<block>
|
||||
<return type="int">
|
||||
<literal type="int" value="-1144164542"/>
|
||||
</return>
|
||||
</block>
|
||||
</function>
|
||||
</block>
|
||||
|
4541
ast_generator/test/xml/ast15.xml
Normal file
4541
ast_generator/test/xml/ast15.xml
Normal file
File diff suppressed because it is too large
Load diff
1960
ast_generator/test/xml/ast16.xml
Normal file
1960
ast_generator/test/xml/ast16.xml
Normal file
File diff suppressed because it is too large
Load diff
2686
ast_generator/test/xml/ast17.xml
Normal file
2686
ast_generator/test/xml/ast17.xml
Normal file
File diff suppressed because it is too large
Load diff
355
ast_generator/test/xml/ast18.xml
Normal file
355
ast_generator/test/xml/ast18.xml
Normal file
|
@ -0,0 +1,355 @@
|
|||
<block>
|
||||
<procedure name="main" return_type="int" args="()">
|
||||
<block>
|
||||
<return type="int">
|
||||
<literal type="int" value="0"/>
|
||||
</return>
|
||||
<declaration type="int">
|
||||
<variable name="GsG" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-24.508787840229957"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-310221492"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-318.79685354362675"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-817261961"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1646869411"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-289353457"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="577083553"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-543.4345091746488"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-491.56924390907085"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1602877080"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="295041250"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1727869452"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-974.9793225551073"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1653345184"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-896.9344717429182"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="442.72337840020714"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="196.71592580498805"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="373.3472525610248"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="994822304"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-827.362360672443"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-397607600"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-535.5920280745536"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-158536307"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="533.9273073673917"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-331.5613655143393"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-584.2916986663149"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="282139110"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-234.85366100917292"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<stream type="std_output">
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-407.1313898318915"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="594.2595409502064"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-855067168"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1024538111"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="461409701"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-228845353"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1986037689"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="858553680"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-27822114"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1058568056"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="793.364834672303"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="147401340"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1786592785"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-2075667967"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1044119075"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-428.06336547207604"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1978344204"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="410.67581708202647"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="853593312"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-462.0147565823032"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-653.3430792190311"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="803.9940351095963"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
</block>
|
||||
</procedure>
|
||||
</block>
|
||||
|
2545
ast_generator/test/xml/ast19.xml
Normal file
2545
ast_generator/test/xml/ast19.xml
Normal file
File diff suppressed because it is too large
Load diff
2631
ast_generator/test/xml/ast2.xml
Normal file
2631
ast_generator/test/xml/ast2.xml
Normal file
File diff suppressed because it is too large
Load diff
1934
ast_generator/test/xml/ast3.xml
Normal file
1934
ast_generator/test/xml/ast3.xml
Normal file
File diff suppressed because it is too large
Load diff
139
ast_generator/test/xml/ast4.xml
Normal file
139
ast_generator/test/xml/ast4.xml
Normal file
|
@ -0,0 +1,139 @@
|
|||
<block>
|
||||
<procedure name="main" return_type="int" args="()">
|
||||
<block>
|
||||
<stream type="std_output">
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-332.985089884789"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1511463307"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="360.1108455256631"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-486382793"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-56673932"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="962.6315569923559"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="251.8682955572349"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-58.97520781582034"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-663830272"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-725.9465078703366"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="872.2253746490055"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-807.2884938799598"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="362.4783934580546"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1354656196"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1672379998"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-594663976"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="314.023365381478"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-757.1197288498458"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="304.6182803547342"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
<return type="int">
|
||||
<literal type="int" value="0"/>
|
||||
</return>
|
||||
</block>
|
||||
</procedure>
|
||||
</block>
|
||||
|
2712
ast_generator/test/xml/ast5.xml
Normal file
2712
ast_generator/test/xml/ast5.xml
Normal file
File diff suppressed because it is too large
Load diff
3183
ast_generator/test/xml/ast6.xml
Normal file
3183
ast_generator/test/xml/ast6.xml
Normal file
File diff suppressed because it is too large
Load diff
3641
ast_generator/test/xml/ast7.xml
Normal file
3641
ast_generator/test/xml/ast7.xml
Normal file
File diff suppressed because it is too large
Load diff
944
ast_generator/test/xml/ast8.xml
Normal file
944
ast_generator/test/xml/ast8.xml
Normal file
|
@ -0,0 +1,944 @@
|
|||
<block>
|
||||
<procedure name="main" return_type="int" args="()">
|
||||
<block>
|
||||
<return type="int">
|
||||
<literal type="int" value="0"/>
|
||||
</return>
|
||||
<stream type="std_output">
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1892208201"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-814067693"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="387.1202167534832"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="311282519"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1090704034"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-283923320"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="913.5997843232064"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-152.65176475382236"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-444.0876377978577"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-63661916"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="54.870633910077686"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1012067321"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1351539284"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1682445403"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
</block>
|
||||
</procedure>
|
||||
<function name="zognC" return_type="int">
|
||||
<argument name="k" type="int"/>
|
||||
<argument name="oJjP" type="int"/>
|
||||
<argument name="qLNBXFBIxS" type="int"/>
|
||||
<argument name="lTjI" type="int"/>
|
||||
<argument name="QIvOAlzqV" type="int"/>
|
||||
<block>
|
||||
<return type="int">
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-586.4338113277354"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-565.1160939450981"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-426717223"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="140280392"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="460.76170885004217"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1328611320"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-2079938065"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1425429986"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1147928825"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="428.03437348140983"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-539.701940125447"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-65680098"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="34846835"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</return>
|
||||
</block>
|
||||
</function>
|
||||
<function name="JKaSIGJ" return_type="int">
|
||||
<argument name="TTr" type="int"/>
|
||||
<argument name="IHPC" type="int"/>
|
||||
<argument name="xnxEgOAF" type="int"/>
|
||||
<argument name="QqQTprSIFR" type="int"/>
|
||||
<block>
|
||||
<return type="int">
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="311191993"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="212.9115363072042"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="358.6454091175708"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-307576324"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-515.8408558391303"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="561548183"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="895.2633354674908"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-432.38428278795607"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-527.4269573331176"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-825187278"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1541338554"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-415899237"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="105200532"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="901.3139232216604"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="48782566"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1237293651"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-552.8730704955371"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-440.18479148671474"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-841.4390813052062"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="70.52959135105584"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-652.5566443157834"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</return>
|
||||
</block>
|
||||
</function>
|
||||
<function name="rCVuhN" return_type="int">
|
||||
<argument name="SlXS" type="int"/>
|
||||
<argument name="YAtyElCX" type="int"/>
|
||||
<argument name="clcF" type="int"/>
|
||||
<block>
|
||||
<stream type="std_output">
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-641709076"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-78.1821413466954"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="318.076135076255"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="843.3460632947963"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-318255852"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1863767056"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="106.27057406215386"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-208.06347568909405"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-197273790"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-458075114"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="153.0249942207397"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
<declaration type="int">
|
||||
<variable name="svzc" type="int" mut="const"/>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-304757914"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-393937641"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-712603890"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1188737463"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="687.957179664791"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-76.01119583263278"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-952.6767380247567"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="363.9599315763662"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-2083509364"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<return type="int">
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="2101199760"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1887057042"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-738.8688222822686"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1767650299"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1560073484"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-156.7910592216473"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="403.5955414961677"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-514.8092595767699"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="99163840"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-896.1146872300392"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1639023141"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="869.4258154026443"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-788732652"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-790781922"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1210988123"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-696.1829582157134"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</return>
|
||||
<declaration type="int">
|
||||
<variable name="GOFDzQcrrd" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="146.76529447072016"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-416.80791787695216"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<stream type="std_output">
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-682321351"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-652.482554231393"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-1508355399"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1962109645"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1705910523"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-432949762"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-721142300"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="514076809"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1839185464"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-371.97390635024453"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-832.9691352285173"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="458547887"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-705.2930339492307"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1058111975"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1218779376"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="927.8635979534558"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="889534430"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-285.61469975577074"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-435631148"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</stream>
|
||||
<declaration type="int">
|
||||
<variable name="icmKJ" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<literal type="int" value="741910664"/>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<declaration type="int">
|
||||
<variable name="SfyWiJGS" type="int" mut="const"/>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="568.0849046977596"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="425724012"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="840178163"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-2031407093"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="183.6744536571489"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-90.94915797747728"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1628992858"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1433464745"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="820.706392834237"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="826.9153729750319"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="374.7804982683506"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1375810928"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="864.9518423991628"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-980866876"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="171.62617939689426"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-835.8716139861926"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1488878779"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="607534852"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-832.2030736437245"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-491527091"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-263774209"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1672615302"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="224.41486983107325"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1118285614"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1010688210"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-232407899"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="919.7340326486644"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="816157564"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
</block>
|
||||
</function>
|
||||
</block>
|
||||
|
520
ast_generator/test/xml/ast9.xml
Normal file
520
ast_generator/test/xml/ast9.xml
Normal file
|
@ -0,0 +1,520 @@
|
|||
<block>
|
||||
<procedure name="main" return_type="int" args="()">
|
||||
<block>
|
||||
<return type="int">
|
||||
<literal type="int" value="0"/>
|
||||
</return>
|
||||
</block>
|
||||
</procedure>
|
||||
<function name="SLrwcP" return_type="int">
|
||||
<argument name="DJhkR" type="int"/>
|
||||
<argument name="bpwQR" type="int"/>
|
||||
<block>
|
||||
<return type="int">
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="977.7974996471614"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="557797777"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-780.5503539855108"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="609.6186316570618"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="117.75924089675732"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="728066751"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="630.9429971623356"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-671.579760434576"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1972192974"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-152236428"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</return>
|
||||
<declaration type="int">
|
||||
<variable name="K" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="264836965"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="248.47054430310732"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-334534634"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-782.6446640862803"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="544.88522848807"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-611.6032890725234"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1666468786"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="969.5573071095944"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1914311012"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-930441597"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-71086775"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="388991486"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-484.94238737572414"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-682581772"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1227496547"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="2141169807"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="665862423"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-321.7159383759805"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-231.28197230220064"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-724831825"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</declaration>
|
||||
<assignment>
|
||||
<variable name="K" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="1638376106"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-388319401"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-829.8233087060607"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="2056955612"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="-45108486"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-473596599"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-405.23776021556364"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1042976432"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="3.671391617230597"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1483200413"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="360.6290816061155"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-786841187"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-553.8894514577041"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="242.6987344469012"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="662.293073769592"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-300219552"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-404.8335496204336"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="626.2212591011919"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-993.5558417213322"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-453.6768176930419"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-791616709"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</assignment>
|
||||
<assignment>
|
||||
<variable name="K" type="int" mut="var"/>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-688.1022047708459"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="672066131"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-769600937"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1815563585"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="-4.930557876996886"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="float" value="-228.73669522947444"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="854782224"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-207795075"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="int">
|
||||
<lhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="float" value="-909.8109507721024"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1101870903"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="float">
|
||||
<lhs>
|
||||
<literal type="float" value="196.56943548615118"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1034678999"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-501066730"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="multiplication" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="589228114"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-349833879"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="-1401347820"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="division" type="float">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1876952792"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="1539303194"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="addition" type="float">
|
||||
<lhs>
|
||||
<literal type="int" value="574673387"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-505627784"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<operator op="subtraction" type="int">
|
||||
<lhs>
|
||||
<literal type="int" value="1756658820"/>
|
||||
</lhs>
|
||||
<rhs>
|
||||
<literal type="int" value="-1091602168"/>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</operator>
|
||||
</rhs>
|
||||
</assignment>
|
||||
</block>
|
||||
</function>
|
||||
</block>
|
||||
|
99
ast_generator/utils.py
Normal file
99
ast_generator/utils.py
Normal file
|
@ -0,0 +1,99 @@
|
|||
from xml.etree import ElementTree as ET
|
||||
|
||||
from constants import GAZ_VAR_TAG, GAZ_ARG_TAG
|
||||
|
||||
|
||||
class Variable:
|
||||
def __init__(self, name: str, type: str, qualifier: str, value: any = None):
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.value = value
|
||||
self.qualifier = qualifier
|
||||
self.xml = self._build_xml()
|
||||
|
||||
def _build_xml(self):
|
||||
args = [
|
||||
('name', self.name),
|
||||
('type', self.type),
|
||||
('mut', self.qualifier),
|
||||
]
|
||||
return build_xml_element(args, name=GAZ_VAR_TAG)
|
||||
|
||||
|
||||
class Argument:
|
||||
def __init__(self, name: str, type: str):
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.xml = self._build_xml()
|
||||
|
||||
def __str__(self):
|
||||
return self.type + " " + self.name
|
||||
|
||||
def _build_xml(self):
|
||||
args = [
|
||||
('name', self.name),
|
||||
('type', self.type),
|
||||
]
|
||||
return build_xml_element(args, name=GAZ_ARG_TAG)
|
||||
|
||||
|
||||
class Routine:
|
||||
def __init__(self, name: str, type: str, return_type: str, args: list[Argument], xml: ET.Element = None):
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.return_type = return_type
|
||||
self.arguments = args
|
||||
self.xml = xml
|
||||
self.xml = xml
|
||||
|
||||
|
||||
class Scope:
|
||||
def __init__(self, enclosing_scope, child_scope=None, associated_xml: ET.Element = None):
|
||||
self.symbols = {}
|
||||
self.enclosing_scope = enclosing_scope
|
||||
self.child_scope = child_scope
|
||||
self.xml = associated_xml
|
||||
|
||||
def resolve(self, name) -> ET.Element or None:
|
||||
if name in self.symbols:
|
||||
return self.symbols[name]
|
||||
else:
|
||||
return None
|
||||
|
||||
def append(self, name, item: Variable or Argument or Routine):
|
||||
self.symbols[name] = item
|
||||
|
||||
def append_element(self, name, value: ET.Element):
|
||||
self.symbols[name] = value
|
||||
|
||||
def set(self, name, value: ET.Element):
|
||||
self.symbols[name] = value
|
||||
|
||||
def get_all_defined_mutable_vars(self) -> list[Variable]:
|
||||
if self.enclosing_scope is None:
|
||||
return self._get_mutable_vars()
|
||||
else:
|
||||
return self.enclosing_scope.get_all_defined_mutable_vars() + self._get_mutable_vars()
|
||||
|
||||
def _get_mutable_vars(self) -> list[Variable]:
|
||||
mutable_vars = []
|
||||
|
||||
for name, var in self.symbols.items():
|
||||
if not isinstance(var, Variable):
|
||||
continue
|
||||
if var.qualifier != 'const':
|
||||
mutable_vars.append(self.symbols[name])
|
||||
return mutable_vars
|
||||
|
||||
def get_top_scope(self):
|
||||
if self.enclosing_scope is None:
|
||||
return self
|
||||
else:
|
||||
return self.enclosing_scope.get_top_scope()
|
||||
|
||||
|
||||
def build_xml_element(*keys, name):
|
||||
elem = ET.Element(name)
|
||||
for key in list(keys)[0]: # TODO refactor
|
||||
elem.set(key[0], key[1])
|
||||
return elem
|
|
@ -36,13 +36,13 @@ def to_gaz_value(val):
|
|||
def to_gaz_op(param):
|
||||
if param == "negation" or param == "subtraction":
|
||||
return "-"
|
||||
elif param == "addition":
|
||||
elif param == "addition" or param == "noop":
|
||||
return "+"
|
||||
elif param == "multiplication":
|
||||
return "*"
|
||||
elif param == "division":
|
||||
return "/"
|
||||
elif param == "modulus":
|
||||
elif param == "modulo":
|
||||
return "%"
|
||||
elif param == "power":
|
||||
return "^"
|
||||
|
@ -82,7 +82,7 @@ class GazUnparser(GeneralUnparser):
|
|||
else:
|
||||
return str(val)
|
||||
|
||||
def translate_op(self, param):
|
||||
def translate_op(self, param, ty=None):
|
||||
return to_gaz_op(param)
|
||||
|
||||
def translate_type(self, ty):
|
||||
|
|
|
@ -18,7 +18,7 @@ class GeneralUnparser:
|
|||
arg_start_delimiter: str = "(",
|
||||
arg_end_delimiter: str = ")",
|
||||
arg_separator: str = ",",
|
||||
loop_start_delimiter: str = "loop (",
|
||||
loop_start_delimiter: str = "loop while (",
|
||||
loop_end_delimiter: str = ")",
|
||||
assignment_character: str = '=',
|
||||
conditional_start_delimiter: str = "if (",
|
||||
|
@ -72,7 +72,7 @@ class GeneralUnparser:
|
|||
self.unparse_node(node)
|
||||
|
||||
def unparse_node(self, node):
|
||||
if node.tag not in [GAZ_VAR_TAG, GAZ_RHS_TAG, GAZ_LHS_TAG, GAZ_LIT_TAG, GAZ_OPERATOR_TAG]:
|
||||
if node.tag not in [GAZ_VAR_TAG, GAZ_RHS_TAG, GAZ_LHS_TAG, GAZ_LIT_TAG, GAZ_OPERATOR_TAG, GAZ_BRACKET_TAG]:
|
||||
self.source += self.indentation_character * self.indentation
|
||||
|
||||
if node.tag == GAZ_BLOCK_TAG:
|
||||
|
@ -103,19 +103,28 @@ class GeneralUnparser:
|
|||
self.unparse_conditional(node)
|
||||
elif node.tag == GAZ_LOOP_TAG:
|
||||
self.unparse_loop(node)
|
||||
elif node.tag == GAZ_BRACKET_TAG:
|
||||
self.unparse_brackets(node)
|
||||
elif node.tag == GAZ_BREAK_TAG:
|
||||
self.unparse_break(node)
|
||||
else:
|
||||
raise Exception("Unknown tag: " + node.tag)
|
||||
|
||||
def unparse_block(self, node):
|
||||
if node.get(GAZ_TY_KEY) is None:
|
||||
self.source += f"{self.indentation * self.indentation_character}"
|
||||
|
||||
self.source += f"{self.block_delimiters[0]}\n"
|
||||
self.indentation += 4
|
||||
|
||||
for child in node:
|
||||
self.unparse_node(child)
|
||||
self.indentation -= 4
|
||||
|
||||
if node.get(GAZ_TY_KEY) is None:
|
||||
self.source += f"{self.block_delimiters[1]}\n\n"
|
||||
self.source += f"{self.indentation * self.indentation_character}{self.block_delimiters[1]}\n\n"
|
||||
elif node.get(GAZ_TY_KEY) in [GAZ_TRUE_BLOCK_TAG, GAZ_FALSE_BLOCK_TAG]:
|
||||
self.source += f"{self.block_delimiters[1]}"
|
||||
self.source += f"{self.indentation * self.indentation_character}{self.block_delimiters[1]}"
|
||||
|
||||
def unparse_declaration(self, node, declaration_op: str = '='):
|
||||
variable = node.find(GAZ_VAR_TAG)
|
||||
|
@ -164,8 +173,9 @@ class GeneralUnparser:
|
|||
self.unparse_node(child)
|
||||
|
||||
def unparse_operator(self, node):
|
||||
ty = node.get(GAZ_TY_KEY)
|
||||
self.unparse_xhs(node.find(GAZ_LHS_TAG))
|
||||
self.source += " {} ".format(self.translate_op(node.get("op")))
|
||||
self.source += " {} ".format(self.translate_op(node.get("op"), ty))
|
||||
self.unparse_xhs(node.find(GAZ_RHS_TAG))
|
||||
|
||||
def unparse_return(self, node):
|
||||
|
@ -271,6 +281,14 @@ class GeneralUnparser:
|
|||
self.source += "{}".format(self.translate_op(element_in.get("op")))
|
||||
self.unparse_xhs(element_in.find(GAZ_RHS_TAG))
|
||||
|
||||
def unparse_brackets(self, element_in: ET.Element):
|
||||
self.source += "("
|
||||
self.unparse_xhs(element_in.find(GAZ_RHS_TAG))
|
||||
self.source += ")"
|
||||
|
||||
def unparse_break(self, element_in: ET.Element):
|
||||
self.source += "break" + self.endline
|
||||
|
||||
def unparse_single_arg(self, param):
|
||||
return self.format_single_arg(self.translate_type(param.get(GAZ_TY_KEY)), param.get(GAZ_NAME_KEY))
|
||||
|
||||
|
@ -292,7 +310,7 @@ class GeneralUnparser:
|
|||
def translate_value(self, val):
|
||||
raise NotImplementedError
|
||||
|
||||
def translate_op(self, param):
|
||||
def translate_op(self, param, ty=None):
|
||||
raise NotImplementedError
|
||||
|
||||
def translate_type(self, ty):
|
||||
|
|
|
@ -21,16 +21,18 @@ def to_python_type(ty):
|
|||
raise Exception("Unknown type: " + ty)
|
||||
|
||||
|
||||
def to_python_op(param):
|
||||
def to_python_op(param, ty):
|
||||
if param == "negation" or param == "subtraction":
|
||||
return "-"
|
||||
elif param == "addition":
|
||||
elif param == "addition" or param == "noop":
|
||||
return "+"
|
||||
elif param == "multiplication":
|
||||
return "*"
|
||||
elif param == "division":
|
||||
elif param == "division" and ty != GAZ_INT_KEY:
|
||||
return "/"
|
||||
elif param == "modulus":
|
||||
elif param == "division" and ty == GAZ_INT_KEY:
|
||||
return "//"
|
||||
elif param == "modulo":
|
||||
return "%"
|
||||
elif param == "power":
|
||||
return "**"
|
||||
|
@ -46,6 +48,8 @@ def to_python_op(param):
|
|||
return ">"
|
||||
elif param == "greater-than-or-equal":
|
||||
return ">="
|
||||
elif param == "xor":
|
||||
return "!="
|
||||
else:
|
||||
warnings.warn("Warning, unknown operator: " + param)
|
||||
return param
|
||||
|
@ -65,7 +69,7 @@ class PythonUnparser(GeneralUnparser):
|
|||
conditional_else_delimiter="else:",
|
||||
conditional_end_delimiter=":",
|
||||
block_start_delimiter="",
|
||||
block_end_delimiter="",
|
||||
block_end_delimiter="", # TODO can this contain the pass?
|
||||
strip_conditionals=True)
|
||||
|
||||
def format_variable(self, mut, ty, name, declaration: bool = False):
|
||||
|
@ -77,8 +81,8 @@ class PythonUnparser(GeneralUnparser):
|
|||
def translate_value(self, val):
|
||||
return str(val)
|
||||
|
||||
def translate_op(self, param):
|
||||
return to_python_op(param)
|
||||
def translate_op(self, param, ty=None):
|
||||
return to_python_op(param, ty)
|
||||
|
||||
def translate_type(self, ty):
|
||||
return to_python_type(ty)
|
||||
|
@ -94,7 +98,7 @@ class PythonUnparser(GeneralUnparser):
|
|||
return "{}: {}".format(name, ty)
|
||||
|
||||
def unparse_block(self, node):
|
||||
super().unparse_block(node)
|
||||
# super().unparse_block(node)
|
||||
self.source += f"{self.block_delimiters[0]}\n"
|
||||
self.indentation += 4
|
||||
for child in node:
|
||||
|
@ -105,3 +109,7 @@ class PythonUnparser(GeneralUnparser):
|
|||
self.source += f"{self.block_delimiters[1]}\n\n"
|
||||
elif node.get(GAZ_TY_KEY) in [GAZ_TRUE_BLOCK_TAG, GAZ_FALSE_BLOCK_TAG]:
|
||||
self.source += f"{self.block_delimiters[1]}"
|
||||
|
||||
def unparse(self):
|
||||
super().unparse()
|
||||
self.source += "\nif __name__ == '__main__':\n main()"
|
||||
|
|
|
@ -54,7 +54,7 @@ class TestPythonUnparseCode(unittest.TestCase):
|
|||
parser.source = ""
|
||||
parser.unparse_node(parser.xml)
|
||||
self.assertIsNotNone(parser.source)
|
||||
self.assertEqual(parser.source, "\n a: int = 1\n print(a * 42, end='')\n return 0\n\n\n")
|
||||
self.assertEqual(parser.source, "\n a: int = 1\n print(a * 42, end='')\n return 0\n pass\n\n\n")
|
||||
|
||||
def test_unparse_assignment(self):
|
||||
with open("ast_parser/test/xml/assignment.xml", "r") as f:
|
||||
|
@ -129,7 +129,7 @@ class TestPythonUnparseCode(unittest.TestCase):
|
|||
parser.unparse_node(parser.xml)
|
||||
self.assertIsNotNone(parser.source)
|
||||
i = ' ' * parser.indentation
|
||||
self.assertEqual("def main() -> int:\n a: int = 1\n print(a * 42, end='')\n return 0\n\n\n", parser.source)
|
||||
self.assertEqual("def main() -> int:\n a: int = 1\n print(a * 42, end='')\n return 0\n pass\n\n\n", parser.source)
|
||||
|
||||
def test_unparse_args(self):
|
||||
with open("ast_parser/test/xml/many_args.xml", 'r') as f:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
if False:
|
||||
return 0
|
||||
pass
|
||||
else:
|
||||
return 1
|
||||
pass
|
||||
|
|
|
@ -2,5 +2,6 @@ def main() -> int:
|
|||
a: int = 1
|
||||
print(a * 42, end='')
|
||||
return 0
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
while True:
|
||||
print(a * 42, end='')
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
def beeeeees(a: int, b: int, bb: int, bbb: int, bbbb: int, bbbbb: int, bbbbbb: int, bbbbbbb: int, bbbbbbbb: int) -> int:
|
||||
return 0
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
-3
|
||||
-3
|
|
@ -5,19 +5,20 @@ generation-options:
|
|||
max-conditionals-loops: 5 # maximum number of loops/conditionals per routine
|
||||
max-number-of-routines: 5 # maximum number of routines (main will always be generated)
|
||||
generate-dead-code: True # generate dead code
|
||||
max-loop-iterations: 100 # maximum number of iterations in a loop
|
||||
properties:
|
||||
max-range-length: 5 # maximum length of ranges, vectors and tuples, (AxA matrices can exist)
|
||||
use-english-words: True # use english words instead of random names (this may limit the maximum number of names)
|
||||
id-length: # length of identifiers
|
||||
min: 1
|
||||
max: 10
|
||||
max: 5
|
||||
function-name-length: # length of function names
|
||||
min: 1
|
||||
max: 10
|
||||
number-of-arguments: # number of arguments to a routine
|
||||
min: 1
|
||||
max: 10
|
||||
generate-max-int: True # if False, generate integers between [-1000, 1000] else
|
||||
generate-max-int: False # if False, generate integers between [-1000, 1000] else
|
||||
expression-weights: # weights for expressions
|
||||
# the higher a weight, the more likely (0, 10000), 0 to exclude, 10000 for only that
|
||||
brackets: 10
|
||||
|
|
|
@ -45,3 +45,5 @@ GAZ_FALSE_BLOCK_TAG = "false"
|
|||
GAZ_ARG_TAG = "argument"
|
||||
GAZ_STRING_KEY = "string"
|
||||
GAZ_CHAR_KEY = "char"
|
||||
GAZ_BRACKET_TAG = "brackets"
|
||||
GAZ_BREAK_TAG = "break"
|
||||
|
|
15
fuzzer.py
15
fuzzer.py
|
@ -1,4 +1,6 @@
|
|||
import io
|
||||
import sys
|
||||
from contextlib import redirect_stdout
|
||||
from io import StringIO
|
||||
import xml
|
||||
|
||||
|
@ -28,7 +30,7 @@ class GazpreaFuzzer:
|
|||
|
||||
def fuzz(self):
|
||||
self.generator.generate_ast()
|
||||
self.write_ast()
|
||||
self.write_ast() # FIXME sometimes this is none
|
||||
|
||||
self.gaz_source_gen = GazUnparser(self.generator.ast, True)
|
||||
self.gaz_source_gen.unparse()
|
||||
|
@ -40,10 +42,13 @@ class GazpreaFuzzer:
|
|||
self.python_source_gen.unparse()
|
||||
|
||||
self.ground_truth = self.python_source_gen.source
|
||||
output = StringIO()
|
||||
sys.stdout = output
|
||||
exec(self.ground_truth)
|
||||
self.out = output.getvalue()
|
||||
# input = "if __name__ == '__main__':\n while True:\n pass\n" # debug
|
||||
|
||||
with redirect_stdout(io.StringIO()) as buf:
|
||||
# exec(str(self.ground_truth))
|
||||
exec(self.ground_truth, globals(), locals()) # FIXME the exec doesn't actually execute for some reason...
|
||||
|
||||
self.out = buf.getvalue()
|
||||
|
||||
def write_ast(self):
|
||||
dom = xml.dom.minidom.parseString(ET.tostring(self.generator.ast).decode('utf-8'))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import random
|
||||
from contextlib import redirect_stdout
|
||||
|
||||
import yaml
|
||||
|
||||
|
@ -32,14 +33,22 @@ class Fuzzer():
|
|||
self.fuzzer.fuzz()
|
||||
dom = xml.dom.minidom.parseString(ET.tostring(self.fuzzer.ast).decode('utf-8'))
|
||||
pretty: str = dom.toprettyxml()
|
||||
|
||||
with open("fuzzer/ground_truth/{}_{}.py".format(self.file_name, i), 'w') as f:
|
||||
f.write(self.fuzzer.ground_truth)
|
||||
with open("fuzzer/ground_truth/{}_{}.py".format(self.file_name, i), 'r') as f:
|
||||
with open("fuzzer/outputs/{}_{}.out".format(self.file_name, i), 'w') as y:
|
||||
with redirect_stdout(y): # Workaround for fuzzer.py:49
|
||||
try:
|
||||
exec(f.read(), globals(), locals())
|
||||
except OverflowError:
|
||||
os.system("rm -f fuzzer/ground_truth/{}_{}.py".format(self.file_name, i))
|
||||
continue
|
||||
with open("fuzzer/input/{}_{}.in".format(self.file_name, i), 'w') as f:
|
||||
f.write(self.fuzzer.source)
|
||||
with open("fuzzer/debug/{}_{}.out".format(self.file_name, i), 'w') as f:
|
||||
f.write(pretty)
|
||||
with open("fuzzer/outputs/{}_{}.out".format(self.file_name, i), 'w') as f:
|
||||
f.write(self.fuzzer.out)
|
||||
with open("fuzzer/ground_truth/{}_{}.py".format(self.file_name, i), 'w') as f:
|
||||
f.write(self.fuzzer.ground_truth)
|
||||
# y.write(self.fuzzer.out)
|
||||
# with open("fuzzer/instream/{}.in".format(i), 'w') as f:
|
||||
# f.write(self.fuzzer.source)
|
||||
# with open("fuzzer/outputs/{}.out".format(i), 'w') as f:
|
||||
|
@ -50,7 +59,7 @@ if __name__ == '__main__':
|
|||
parser = argparse.ArgumentParser(
|
||||
description='Procedurally generate a test case for Gazprea'
|
||||
)
|
||||
parser.add_argument('-b', '--batch_size', type=int, required=False,
|
||||
parser.add_argument('-b', '--batch_size', type=int, required=False, default=1,
|
||||
help="generate BATCH cases (fuzzer/source/nameX.in, /instream/..., /outputs/...)")
|
||||
parser.add_argument('--seed', type=int, required=False, action="store",
|
||||
help="rng seed")
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import concurrent.futures
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
|
@ -25,7 +27,7 @@ class TestCorrectness(unittest.TestCase):
|
|||
def test_assignment(self):
|
||||
self.ast_gen.ast = ET.Element("block")
|
||||
self.ast_gen.current_ast_element = self.ast_gen.ast
|
||||
self.ast_gen.generate_declaration()
|
||||
self.ast_gen.generate_declaration(mut='var')
|
||||
self.ast_gen.generate_assignment()
|
||||
|
||||
self.python_unparser.xml = self.ast_gen.ast
|
||||
|
@ -115,18 +117,19 @@ class TestCorrectness(unittest.TestCase):
|
|||
self.fail(e)
|
||||
|
||||
def test_loop(self):
|
||||
self.ast_gen.ast = ET.Element("block")
|
||||
self.ast_gen.current_ast_element = self.ast_gen.ast
|
||||
self.ast_gen.generate_loop()
|
||||
for i in range(1000):
|
||||
self.ast_gen.ast = ET.Element("block")
|
||||
self.ast_gen.current_ast_element = self.ast_gen.ast
|
||||
self.ast_gen.generate_loop()
|
||||
|
||||
self.python_unparser.xml = self.ast_gen.ast
|
||||
self.python_unparser.unparse()
|
||||
self.python_unparser.xml = self.ast_gen.ast
|
||||
self.python_unparser.unparse()
|
||||
|
||||
try:
|
||||
exec(self.python_unparser.source)
|
||||
except Exception as e:
|
||||
print(self.python_unparser.source)
|
||||
self.fail(e)
|
||||
try:
|
||||
compile(self.python_unparser.source, "beeeans", "exec")
|
||||
except Exception as e:
|
||||
print(self.python_unparser.source)
|
||||
self.fail(e)
|
||||
|
||||
def test_routine(self):
|
||||
self.ast_gen.ast = ET.Element("block")
|
||||
|
@ -153,5 +156,42 @@ class TestCorrectness(unittest.TestCase):
|
|||
print(self.python_unparser.source)
|
||||
self.fail(e)
|
||||
|
||||
def test_no_infinite_loops(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_infinite_loops_with_break_terminate(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_builtins(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_all_vars_get_printed(self):
|
||||
self.fail("TODO")
|
||||
|
||||
class TestTypeCorrectness(unittest.TestCase):
|
||||
def test_int_expr_correctness(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_float_expr_correctness(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_char_expr_correctness(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_bool_expr_correctness(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_tuple_expr_correctness(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_vector_expr_correctness(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_matrix_expr_correctness(self):
|
||||
self.fail("TODO")
|
||||
|
||||
def test_iterable_expr_correctness(self):
|
||||
self.fail("TODO")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue