debugging
This commit is contained in:
9
simplifiedKrakenGrammer.kgm
Normal file
9
simplifiedKrakenGrammer.kgm
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Goal = translation_unit ;
|
||||||
|
translation_unit = function "
|
||||||
|
" ;
|
||||||
|
|
||||||
|
function = "why" typed_return WS code_block ;
|
||||||
|
typed_return = WS "bad" | ;
|
||||||
|
code_block = "{" WS "}" ;
|
||||||
|
|
||||||
|
WS = "( | )+" | ;
|
||||||
@@ -16,9 +16,6 @@ adt ast_node {
|
|||||||
adt_def: adt_def,
|
adt_def: adt_def,
|
||||||
function: function,
|
function: function,
|
||||||
code_block: code_block,
|
code_block: code_block,
|
||||||
typed_parameter: typed_parameter,
|
|
||||||
expression: expression,
|
|
||||||
boolean_expression: boolean_expression,
|
|
||||||
statement: statement,
|
statement: statement,
|
||||||
if_statement: if_statement,
|
if_statement: if_statement,
|
||||||
match_statement: match_statement,
|
match_statement: match_statement,
|
||||||
@@ -36,8 +33,6 @@ adt ast_node {
|
|||||||
passthrough_params: passthrough_params,
|
passthrough_params: passthrough_params,
|
||||||
in_passthrough_params: in_passthrough_params,
|
in_passthrough_params: in_passthrough_params,
|
||||||
out_passthrough_params: out_passthrough_params,
|
out_passthrough_params: out_passthrough_params,
|
||||||
opt_string: opt_string,
|
|
||||||
param_assign: param_assign,
|
|
||||||
function_call: function_call,
|
function_call: function_call,
|
||||||
value: value
|
value: value
|
||||||
}
|
}
|
||||||
@@ -61,18 +56,22 @@ fun ast_translation_unit_ptr(name: string): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj translation_unit (Object) {
|
obj translation_unit (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
var children: vector<*ast_node>
|
var children: vector<*ast_node>
|
||||||
var name: string
|
var name: string
|
||||||
fun construct(nameIn: string): *translation_unit {
|
fun construct(nameIn: string): *translation_unit {
|
||||||
|
scope.construct()
|
||||||
children.construct()
|
children.construct()
|
||||||
name.copy_construct(&nameIn)
|
name.copy_construct(&nameIn)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *translation_unit) {
|
fun copy_construct(old: *translation_unit) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
children.copy_construct(&old->children)
|
children.copy_construct(&old->children)
|
||||||
name.copy_construct(&old->name)
|
name.copy_construct(&old->name)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
children.destruct()
|
children.destruct()
|
||||||
name.destruct()
|
name.destruct()
|
||||||
}
|
}
|
||||||
@@ -91,18 +90,22 @@ fun ast_import_ptr(name: string): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj import (Object) {
|
obj import (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
var children: vector<*ast_node>
|
var children: vector<*ast_node>
|
||||||
var name: string
|
var name: string
|
||||||
fun construct(nameIn: string): *import {
|
fun construct(nameIn: string): *import {
|
||||||
|
scope.construct()
|
||||||
children.construct()
|
children.construct()
|
||||||
name.copy_construct(&nameIn)
|
name.copy_construct(&nameIn)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *import) {
|
fun copy_construct(old: *import) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
children.copy_construct(&old->children)
|
children.copy_construct(&old->children)
|
||||||
name.copy_construct(&old->name)
|
name.copy_construct(&old->name)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
children.destruct()
|
children.destruct()
|
||||||
name.destruct()
|
name.destruct()
|
||||||
}
|
}
|
||||||
@@ -121,12 +124,16 @@ fun ast_identifier_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj identifier (Object) {
|
obj identifier (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *identifier {
|
fun construct(): *identifier {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *identifier) {
|
fun copy_construct(old: *identifier) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref identifier) {
|
fun operator=(other: ref identifier) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -143,15 +150,19 @@ fun ast_type_def_ptr(name: string): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj type_def (Object) {
|
obj type_def (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
var name: string
|
var name: string
|
||||||
fun construct(nameIn: string): *type_def {
|
fun construct(nameIn: string): *type_def {
|
||||||
|
scope.construct()
|
||||||
name.copy_construct(&nameIn)
|
name.copy_construct(&nameIn)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *type_def) {
|
fun copy_construct(old: *type_def) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
name.copy_construct(&old->name)
|
name.copy_construct(&old->name)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
name.destruct()
|
name.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref type_def) {
|
fun operator=(other: ref type_def) {
|
||||||
@@ -169,15 +180,19 @@ fun ast_adt_def_ptr(name: string): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj adt_def (Object) {
|
obj adt_def (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
var name: string
|
var name: string
|
||||||
fun construct(nameIn: string): *adt_def {
|
fun construct(nameIn: string): *adt_def {
|
||||||
|
scope.construct()
|
||||||
name.copy_construct(&nameIn)
|
name.copy_construct(&nameIn)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *adt_def) {
|
fun copy_construct(old: *adt_def) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
name.copy_construct(&old->name)
|
name.copy_construct(&old->name)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
name.destruct()
|
name.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref adt_def) {
|
fun operator=(other: ref adt_def) {
|
||||||
@@ -195,12 +210,16 @@ fun ast_function_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj function (Object) {
|
obj function (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *function {
|
fun construct(): *function {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *function) {
|
fun copy_construct(old: *function) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref function) {
|
fun operator=(other: ref function) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -217,12 +236,16 @@ fun ast_code_block_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj code_block (Object) {
|
obj code_block (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *code_block {
|
fun construct(): *code_block {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *code_block) {
|
fun copy_construct(old: *code_block) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref code_block) {
|
fun operator=(other: ref code_block) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -232,72 +255,6 @@ obj code_block (Object) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun ast_typed_parameter_ptr(): *ast_node {
|
|
||||||
var to_ret.construct(): typed_parameter
|
|
||||||
var ptr = new<ast_node>()
|
|
||||||
ptr->copy_construct(&ast_node::typed_parameter(to_ret))
|
|
||||||
return ptr
|
|
||||||
}
|
|
||||||
obj typed_parameter (Object) {
|
|
||||||
fun construct(): *typed_parameter {
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
fun copy_construct(old: *typed_parameter) {
|
|
||||||
}
|
|
||||||
fun destruct() {
|
|
||||||
}
|
|
||||||
fun operator=(other: ref typed_parameter) {
|
|
||||||
destruct()
|
|
||||||
copy_construct(&other)
|
|
||||||
}
|
|
||||||
fun operator==(other: ref typed_parameter): bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun ast_expression_ptr(): *ast_node {
|
|
||||||
var to_ret.construct(): expression
|
|
||||||
var ptr = new<ast_node>()
|
|
||||||
ptr->copy_construct(&ast_node::expression(to_ret))
|
|
||||||
return ptr
|
|
||||||
}
|
|
||||||
obj expression (Object) {
|
|
||||||
fun construct(): *expression {
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
fun copy_construct(old: *expression) {
|
|
||||||
}
|
|
||||||
fun destruct() {
|
|
||||||
}
|
|
||||||
fun operator=(other: ref expression) {
|
|
||||||
destruct()
|
|
||||||
copy_construct(&other)
|
|
||||||
}
|
|
||||||
fun operator==(other: ref expression): bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun ast_boolean_expression_ptr(): *ast_node {
|
|
||||||
var to_ret.construct(): boolean_expression
|
|
||||||
var ptr = new<ast_node>()
|
|
||||||
ptr->copy_construct(&ast_node::boolean_expression(to_ret))
|
|
||||||
return ptr
|
|
||||||
}
|
|
||||||
obj boolean_expression (Object) {
|
|
||||||
fun construct(): *boolean_expression {
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
fun copy_construct(old: *boolean_expression) {
|
|
||||||
}
|
|
||||||
fun destruct() {
|
|
||||||
}
|
|
||||||
fun operator=(other: ref boolean_expression) {
|
|
||||||
destruct()
|
|
||||||
copy_construct(&other)
|
|
||||||
}
|
|
||||||
fun operator==(other: ref boolean_expression): bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun ast_statement_ptr(): *ast_node {
|
fun ast_statement_ptr(): *ast_node {
|
||||||
var to_ret.construct(): statement
|
var to_ret.construct(): statement
|
||||||
var ptr = new<ast_node>()
|
var ptr = new<ast_node>()
|
||||||
@@ -305,12 +262,16 @@ fun ast_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj statement (Object) {
|
obj statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *statement {
|
fun construct(): *statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *statement) {
|
fun copy_construct(old: *statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref statement) {
|
fun operator=(other: ref statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -327,12 +288,16 @@ fun ast_if_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj if_statement (Object) {
|
obj if_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *if_statement {
|
fun construct(): *if_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *if_statement) {
|
fun copy_construct(old: *if_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref if_statement) {
|
fun operator=(other: ref if_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -349,12 +314,16 @@ fun ast_match_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj match_statement (Object) {
|
obj match_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *match_statement {
|
fun construct(): *match_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *match_statement) {
|
fun copy_construct(old: *match_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref match_statement) {
|
fun operator=(other: ref match_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -371,12 +340,16 @@ fun ast_case_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj case_statement (Object) {
|
obj case_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *case_statement {
|
fun construct(): *case_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *case_statement) {
|
fun copy_construct(old: *case_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref case_statement) {
|
fun operator=(other: ref case_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -393,12 +366,16 @@ fun ast_while_loop_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj while_loop (Object) {
|
obj while_loop (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *while_loop {
|
fun construct(): *while_loop {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *while_loop) {
|
fun copy_construct(old: *while_loop) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref while_loop) {
|
fun operator=(other: ref while_loop) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -415,12 +392,16 @@ fun ast_for_loop_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj for_loop (Object) {
|
obj for_loop (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *for_loop {
|
fun construct(): *for_loop {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *for_loop) {
|
fun copy_construct(old: *for_loop) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref for_loop) {
|
fun operator=(other: ref for_loop) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -437,12 +418,16 @@ fun ast_return_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj return_statement (Object) {
|
obj return_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *return_statement {
|
fun construct(): *return_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *return_statement) {
|
fun copy_construct(old: *return_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref return_statement) {
|
fun operator=(other: ref return_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -459,12 +444,16 @@ fun ast_break_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj break_statement (Object) {
|
obj break_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *break_statement {
|
fun construct(): *break_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *break_statement) {
|
fun copy_construct(old: *break_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref break_statement) {
|
fun operator=(other: ref break_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -481,12 +470,16 @@ fun ast_continue_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj continue_statement (Object) {
|
obj continue_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *continue_statement {
|
fun construct(): *continue_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *continue_statement) {
|
fun copy_construct(old: *continue_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref continue_statement) {
|
fun operator=(other: ref continue_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -503,12 +496,16 @@ fun ast_defer_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj defer_statement (Object) {
|
obj defer_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *defer_statement {
|
fun construct(): *defer_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *defer_statement) {
|
fun copy_construct(old: *defer_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref defer_statement) {
|
fun operator=(other: ref defer_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -525,12 +522,16 @@ fun ast_assignment_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj assignment_statement (Object) {
|
obj assignment_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *assignment_statement {
|
fun construct(): *assignment_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *assignment_statement) {
|
fun copy_construct(old: *assignment_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref assignment_statement) {
|
fun operator=(other: ref assignment_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -547,12 +548,16 @@ fun ast_declaration_statement_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj declaration_statement (Object) {
|
obj declaration_statement (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *declaration_statement {
|
fun construct(): *declaration_statement {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *declaration_statement) {
|
fun copy_construct(old: *declaration_statement) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref declaration_statement) {
|
fun operator=(other: ref declaration_statement) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -591,12 +596,16 @@ fun ast_simple_passthrough_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj simple_passthrough (Object) {
|
obj simple_passthrough (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *simple_passthrough {
|
fun construct(): *simple_passthrough {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *simple_passthrough) {
|
fun copy_construct(old: *simple_passthrough) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref simple_passthrough) {
|
fun operator=(other: ref simple_passthrough) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -613,12 +622,16 @@ fun ast_passthrough_params_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj passthrough_params (Object) {
|
obj passthrough_params (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *passthrough_params {
|
fun construct(): *passthrough_params {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *passthrough_params) {
|
fun copy_construct(old: *passthrough_params) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref passthrough_params) {
|
fun operator=(other: ref passthrough_params) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -635,12 +648,16 @@ fun ast_in_passthrough_params_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj in_passthrough_params (Object) {
|
obj in_passthrough_params (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *in_passthrough_params {
|
fun construct(): *in_passthrough_params {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *in_passthrough_params) {
|
fun copy_construct(old: *in_passthrough_params) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref in_passthrough_params) {
|
fun operator=(other: ref in_passthrough_params) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -657,12 +674,16 @@ fun ast_out_passthrough_params_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj out_passthrough_params (Object) {
|
obj out_passthrough_params (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *out_passthrough_params {
|
fun construct(): *out_passthrough_params {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *out_passthrough_params) {
|
fun copy_construct(old: *out_passthrough_params) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref out_passthrough_params) {
|
fun operator=(other: ref out_passthrough_params) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -672,50 +693,6 @@ obj out_passthrough_params (Object) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun ast_opt_string_ptr(): *ast_node {
|
|
||||||
var to_ret.construct(): opt_string
|
|
||||||
var ptr = new<ast_node>()
|
|
||||||
ptr->copy_construct(&ast_node::opt_string(to_ret))
|
|
||||||
return ptr
|
|
||||||
}
|
|
||||||
obj opt_string (Object) {
|
|
||||||
fun construct(): *opt_string {
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
fun copy_construct(old: *opt_string) {
|
|
||||||
}
|
|
||||||
fun destruct() {
|
|
||||||
}
|
|
||||||
fun operator=(other: ref opt_string) {
|
|
||||||
destruct()
|
|
||||||
copy_construct(&other)
|
|
||||||
}
|
|
||||||
fun operator==(other: ref opt_string): bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun ast_param_assign_ptr(): *ast_node {
|
|
||||||
var to_ret.construct(): param_assign
|
|
||||||
var ptr = new<ast_node>()
|
|
||||||
ptr->copy_construct(&ast_node::param_assign(to_ret))
|
|
||||||
return ptr
|
|
||||||
}
|
|
||||||
obj param_assign (Object) {
|
|
||||||
fun construct(): *param_assign {
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
fun copy_construct(old: *param_assign) {
|
|
||||||
}
|
|
||||||
fun destruct() {
|
|
||||||
}
|
|
||||||
fun operator=(other: ref param_assign) {
|
|
||||||
destruct()
|
|
||||||
copy_construct(&other)
|
|
||||||
}
|
|
||||||
fun operator==(other: ref param_assign): bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fun ast_function_call_ptr(): *ast_node {
|
fun ast_function_call_ptr(): *ast_node {
|
||||||
var to_ret.construct(): function_call
|
var to_ret.construct(): function_call
|
||||||
var ptr = new<ast_node>()
|
var ptr = new<ast_node>()
|
||||||
@@ -723,12 +700,16 @@ fun ast_function_call_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj function_call (Object) {
|
obj function_call (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *function_call {
|
fun construct(): *function_call {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *function_call) {
|
fun copy_construct(old: *function_call) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref function_call) {
|
fun operator=(other: ref function_call) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -745,12 +726,16 @@ fun ast_value_ptr(): *ast_node {
|
|||||||
return ptr
|
return ptr
|
||||||
}
|
}
|
||||||
obj value (Object) {
|
obj value (Object) {
|
||||||
|
var scope: map<string, vector<*ast_node>>
|
||||||
fun construct(): *value {
|
fun construct(): *value {
|
||||||
|
scope.construct()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
fun copy_construct(old: *value) {
|
fun copy_construct(old: *value) {
|
||||||
|
scope.copy_construct(&old->scope)
|
||||||
}
|
}
|
||||||
fun destruct() {
|
fun destruct() {
|
||||||
|
scope.destruct()
|
||||||
}
|
}
|
||||||
fun operator=(other: ref value) {
|
fun operator=(other: ref value) {
|
||||||
destruct()
|
destruct()
|
||||||
@@ -764,15 +749,12 @@ obj value (Object) {
|
|||||||
fun get_ast_children(node: *ast_node): vector<*ast_node> {
|
fun get_ast_children(node: *ast_node): vector<*ast_node> {
|
||||||
match (*node) {
|
match (*node) {
|
||||||
ast_node::translation_unit(backing) return backing.children
|
ast_node::translation_unit(backing) return backing.children
|
||||||
ast_node::import(backing) return vector<*ast_node>()
|
ast_node::import(backing) return backing.children
|
||||||
ast_node::identifier(backing) return vector<*ast_node>()
|
ast_node::identifier(backing) return vector<*ast_node>()
|
||||||
ast_node::type_def(backing) return vector<*ast_node>()
|
ast_node::type_def(backing) return vector<*ast_node>()
|
||||||
ast_node::adt_def(backing) return vector<*ast_node>()
|
ast_node::adt_def(backing) return vector<*ast_node>()
|
||||||
ast_node::function(backing) return vector<*ast_node>()
|
ast_node::function(backing) return vector<*ast_node>()
|
||||||
ast_node::code_block(backing) return vector<*ast_node>()
|
ast_node::code_block(backing) return vector<*ast_node>()
|
||||||
ast_node::typed_parameter(backing) return vector<*ast_node>()
|
|
||||||
ast_node::expression(backing) return vector<*ast_node>()
|
|
||||||
ast_node::boolean_expression(backing) return vector<*ast_node>()
|
|
||||||
ast_node::statement(backing) return vector<*ast_node>()
|
ast_node::statement(backing) return vector<*ast_node>()
|
||||||
ast_node::if_statement(backing) return vector<*ast_node>()
|
ast_node::if_statement(backing) return vector<*ast_node>()
|
||||||
ast_node::match_statement(backing) return vector<*ast_node>()
|
ast_node::match_statement(backing) return vector<*ast_node>()
|
||||||
@@ -790,8 +772,6 @@ fun get_ast_children(node: *ast_node): vector<*ast_node> {
|
|||||||
ast_node::passthrough_params(backing) return vector<*ast_node>()
|
ast_node::passthrough_params(backing) return vector<*ast_node>()
|
||||||
ast_node::in_passthrough_params(backing) return vector<*ast_node>()
|
ast_node::in_passthrough_params(backing) return vector<*ast_node>()
|
||||||
ast_node::out_passthrough_params(backing) return vector<*ast_node>()
|
ast_node::out_passthrough_params(backing) return vector<*ast_node>()
|
||||||
ast_node::opt_string(backing) return vector<*ast_node>()
|
|
||||||
ast_node::param_assign(backing) return vector<*ast_node>()
|
|
||||||
ast_node::function_call(backing) return vector<*ast_node>()
|
ast_node::function_call(backing) return vector<*ast_node>()
|
||||||
ast_node::value(backing) return vector<*ast_node>()
|
ast_node::value(backing) return vector<*ast_node>()
|
||||||
}
|
}
|
||||||
@@ -805,9 +785,6 @@ fun get_ast_name(node: *ast_node): string {
|
|||||||
ast_node::adt_def(backing) return string("adt_def: ") + backing.name
|
ast_node::adt_def(backing) return string("adt_def: ") + backing.name
|
||||||
ast_node::function(backing) return string("function")
|
ast_node::function(backing) return string("function")
|
||||||
ast_node::code_block(backing) return string("code_block")
|
ast_node::code_block(backing) return string("code_block")
|
||||||
ast_node::typed_parameter(backing) return string("typed_parameter")
|
|
||||||
ast_node::expression(backing) return string("expression")
|
|
||||||
ast_node::boolean_expression(backing) return string("boolean_expression")
|
|
||||||
ast_node::statement(backing) return string("statement")
|
ast_node::statement(backing) return string("statement")
|
||||||
ast_node::if_statement(backing) return string("if_statement")
|
ast_node::if_statement(backing) return string("if_statement")
|
||||||
ast_node::match_statement(backing) return string("match_statement")
|
ast_node::match_statement(backing) return string("match_statement")
|
||||||
@@ -825,12 +802,40 @@ fun get_ast_name(node: *ast_node): string {
|
|||||||
ast_node::passthrough_params(backing) return string("passthrough_params")
|
ast_node::passthrough_params(backing) return string("passthrough_params")
|
||||||
ast_node::in_passthrough_params(backing) return string("in_passthrough_params")
|
ast_node::in_passthrough_params(backing) return string("in_passthrough_params")
|
||||||
ast_node::out_passthrough_params(backing) return string("out_passthrough_params")
|
ast_node::out_passthrough_params(backing) return string("out_passthrough_params")
|
||||||
ast_node::opt_string(backing) return string("opt_string")
|
|
||||||
ast_node::param_assign(backing) return string("param_assign")
|
|
||||||
ast_node::function_call(backing) return string("function_call")
|
ast_node::function_call(backing) return string("function_call")
|
||||||
ast_node::value(backing) return string("value")
|
ast_node::value(backing) return string("value")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun get_ast_scope(node: *ast_node): *map<string,vector<*ast_node>> {
|
||||||
|
match (*node) {
|
||||||
|
ast_node::translation_unit() return &node->translation_unit.scope
|
||||||
|
ast_node::import() return &node->import.scope
|
||||||
|
ast_node::identifier() return &node->identifier.scope
|
||||||
|
ast_node::type_def() return &node->type_def.scope
|
||||||
|
ast_node::adt_def() return &node->adt_def.scope
|
||||||
|
ast_node::function() return &node->function.scope
|
||||||
|
ast_node::code_block() return &node->code_block.scope
|
||||||
|
ast_node::statement() return &node->statement.scope
|
||||||
|
ast_node::if_statement() return &node->if_statement.scope
|
||||||
|
ast_node::match_statement() return &node->match_statement.scope
|
||||||
|
ast_node::case_statement() return &node->case_statement.scope
|
||||||
|
ast_node::while_loop() return &node->while_loop.scope
|
||||||
|
ast_node::for_loop() return &node->for_loop.scope
|
||||||
|
ast_node::return_statement() return &node->return_statement.scope
|
||||||
|
ast_node::break_statement() return &node->break_statement.scope
|
||||||
|
ast_node::continue_statement() return &node->continue_statement.scope
|
||||||
|
ast_node::defer_statement() return &node->defer_statement.scope
|
||||||
|
ast_node::assignment_statement() return &node->assignment_statement.scope
|
||||||
|
ast_node::declaration_statement() return &node->declaration_statement.scope
|
||||||
|
ast_node::if_comp() return null<map<string,vector<*ast_node>>>()
|
||||||
|
ast_node::simple_passthrough() return &node->simple_passthrough.scope
|
||||||
|
ast_node::passthrough_params() return &node->passthrough_params.scope
|
||||||
|
ast_node::in_passthrough_params() return &node->in_passthrough_params.scope
|
||||||
|
ast_node::out_passthrough_params() return &node->out_passthrough_params.scope
|
||||||
|
ast_node::function_call() return &node->function_call.scope
|
||||||
|
ast_node::value() return &node->value.scope
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun ast_to_dot(root: *ast_node): string {
|
fun ast_to_dot(root: *ast_node): string {
|
||||||
var ret = string("digraph Kaken {\n")
|
var ret = string("digraph Kaken {\n")
|
||||||
|
|||||||
@@ -38,16 +38,21 @@ obj ast_transformation (Object) {
|
|||||||
var name = concat_symbol_tree(get_node("identifier", child))
|
var name = concat_symbol_tree(get_node("identifier", child))
|
||||||
var type_def_node = ast_type_def_ptr(name)
|
var type_def_node = ast_type_def_ptr(name)
|
||||||
translation_unit->translation_unit.children.add(type_def_node)
|
translation_unit->translation_unit.children.add(type_def_node)
|
||||||
|
add_to_scope("~enclosing_scope", translation_unit, type_def_node)
|
||||||
|
add_to_scope(name, type_def_node, translation_unit)
|
||||||
// add to scope, the reverse
|
// add to scope, the reverse
|
||||||
// set up type - self-referential, traits, template, etc
|
// set up type - self-referential, traits, template, etc
|
||||||
} else if (child->data.name == "adt_def") {
|
} else if (child->data.name == "adt_def") {
|
||||||
var name = concat_symbol_tree(get_node("identifier", child))
|
var name = concat_symbol_tree(get_node("identifier", child))
|
||||||
var adt_def_node = ast_adt_def_ptr(name)
|
var adt_def_node = ast_adt_def_ptr(name)
|
||||||
translation_unit->translation_unit.children.add(adt_def_node)
|
translation_unit->translation_unit.children.add(adt_def_node)
|
||||||
|
add_to_scope("~enclosing_scope", translation_unit, adt_def_node)
|
||||||
|
add_to_scope(name, adt_def_node, translation_unit)
|
||||||
// add to scope, the reverse
|
// add to scope, the reverse
|
||||||
} else if (child->data.name == "if_comp") {
|
} else if (child->data.name == "if_comp") {
|
||||||
var if_comp_node = ast_if_comp_ptr()
|
var if_comp_node = ast_if_comp_ptr()
|
||||||
translation_unit->translation_unit.children.add(if_comp_node)
|
translation_unit->translation_unit.children.add(if_comp_node)
|
||||||
|
add_to_scope("~enclosing_scope", translation_unit, if_comp_node)
|
||||||
// add parent to scope?
|
// add parent to scope?
|
||||||
// do children...
|
// do children...
|
||||||
}
|
}
|
||||||
@@ -60,6 +65,9 @@ obj ast_transformation (Object) {
|
|||||||
var name = concat_symbol_tree(get_node("identifier", child))
|
var name = concat_symbol_tree(get_node("identifier", child))
|
||||||
var import_node = ast_import_ptr(name)
|
var import_node = ast_import_ptr(name)
|
||||||
translation_unit->translation_unit.children.add(import_node)
|
translation_unit->translation_unit.children.add(import_node)
|
||||||
|
add_to_scope("~enclosing_scope", translation_unit, import_node)
|
||||||
|
var outside_translation_unit = importer->import(name + ".krak")
|
||||||
|
add_to_scope(name, outside_translation_unit, translation_unit)
|
||||||
// call out to importer
|
// call out to importer
|
||||||
// go through what is imported - *, or individual names
|
// go through what is imported - *, or individual names
|
||||||
// for names undefined right now (i.e. not of a type), leave an empty vector?
|
// for names undefined right now (i.e. not of a type), leave an empty vector?
|
||||||
@@ -90,4 +98,14 @@ fun get_node(lookup: string, parent: *tree<symbol>): *tree<symbol> {
|
|||||||
fun get_nodes(lookup: string, parent: *tree<symbol>): vector<*tree<symbol>> {
|
fun get_nodes(lookup: string, parent: *tree<symbol>): vector<*tree<symbol>> {
|
||||||
return parent->children.filter(fun(node: *tree<symbol>):bool return node->data.name == lookup;)
|
return parent->children.filter(fun(node: *tree<symbol>):bool return node->data.name == lookup;)
|
||||||
}
|
}
|
||||||
|
fun add_to_scope(name: *char, to_add: *ast_node, add_to: *ast_node) {
|
||||||
|
add_to_scope(string(name), to_add, add_to)
|
||||||
|
}
|
||||||
|
fun add_to_scope(name: string, to_add: *ast_node, add_to: *ast_node) {
|
||||||
|
var add_to_map = get_ast_scope(add_to)
|
||||||
|
if (add_to_map->contains_key(name))
|
||||||
|
(*add_to_map)[name].add(to_add)
|
||||||
|
else
|
||||||
|
add_to_map->set(name, vector(to_add))
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ obj importer (Object) {
|
|||||||
parse.destruct()
|
parse.destruct()
|
||||||
ast_pass.destruct()
|
ast_pass.destruct()
|
||||||
}
|
}
|
||||||
fun import(file_name: string) {
|
fun import(file_name: string): *ast_node {
|
||||||
print("pre-parse: "); println(file_name)
|
print("pre-parse: "); println(file_name)
|
||||||
var parse_tree = parse.parse_input(read_file(file_name), file_name)
|
var parse_tree = parse.parse_input(read_file(file_name), file_name)
|
||||||
print("post-parse: "); println(file_name)
|
print("post-parse: "); println(file_name)
|
||||||
@@ -44,6 +44,7 @@ obj importer (Object) {
|
|||||||
var ast = ast_pass.first_pass(file_name, parse_tree, this)
|
var ast = ast_pass.first_pass(file_name, parse_tree, this)
|
||||||
print("post-ast: "); println(file_name)
|
print("post-ast: "); println(file_name)
|
||||||
write_file(file_name + ".ast.dot", ast_to_dot(ast))
|
write_file(file_name + ".ast.dot", ast_to_dot(ast))
|
||||||
|
return ast
|
||||||
}
|
}
|
||||||
fun trim(parse_tree: *tree<symbol>) {
|
fun trim(parse_tree: *tree<symbol>) {
|
||||||
remove_node(symbol("$NULL$", false), parse_tree)
|
remove_node(symbol("$NULL$", false), parse_tree)
|
||||||
@@ -93,7 +94,12 @@ obj importer (Object) {
|
|||||||
while(!to_process.empty()) {
|
while(!to_process.empty()) {
|
||||||
var node = to_process.pop()
|
var node = to_process.pop()
|
||||||
for (var i = 0; i < node->children.size; i++;) {
|
for (var i = 0; i < node->children.size; i++;) {
|
||||||
if (node->children[i]->data.equal_wo_data(remove)) {
|
if (!node->children[i] || node->children[i]->data.equal_wo_data(remove)) {
|
||||||
|
if (!node->children[i])
|
||||||
|
println("not because null")
|
||||||
|
else {
|
||||||
|
print("not because "); println(remove.name)
|
||||||
|
}
|
||||||
node->children.remove(i)
|
node->children.remove(i)
|
||||||
i--;
|
i--;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -12,37 +12,14 @@ fun main():int {
|
|||||||
|
|
||||||
var a.construct(): grammer
|
var a.construct(): grammer
|
||||||
|
|
||||||
var file_name = string("../krakenGrammer.kgm")
|
/*var file_name = string("../krakenGrammer.kgm")*/
|
||||||
|
var file_name = string("../simplifiedKrakenGrammer.kgm")
|
||||||
/*var file_name = string("grammer.kgm")*/
|
/*var file_name = string("grammer.kgm")*/
|
||||||
/*var file_name = string("grammer2.kgm")*/
|
|
||||||
/*var file_name = string("grammer3.kgm")*/
|
|
||||||
/*var file_name = string("grammer4.kgm")*/
|
|
||||||
|
|
||||||
var compiled_name = file_name + string(".comp_new")
|
var compiled_name = file_name + string(".comp_new")
|
||||||
var file_contents = read_file(file_name)
|
var file_contents = read_file(file_name)
|
||||||
var loaded_and_valid = false
|
var loaded_and_valid = false
|
||||||
|
|
||||||
/*
|
|
||||||
println("gonna serialize")
|
|
||||||
var s = serialize(file_contents)
|
|
||||||
println("gonna write")
|
|
||||||
write_file_binary(compiled_name, s)
|
|
||||||
println("gonna read")
|
|
||||||
var bin = read_file_binary(compiled_name)
|
|
||||||
println("gonna setup")
|
|
||||||
var pos = 0
|
|
||||||
var uns = string()
|
|
||||||
println("gonna unserialize")
|
|
||||||
unpack(uns, pos) = unserialize<string>(bin, pos)
|
|
||||||
println("gonna done")
|
|
||||||
|
|
||||||
return 0
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*a = load_grammer(file_contents)*/
|
|
||||||
/*println("grammer loaded, calculate_state_automaton")*/
|
|
||||||
/*a.calculate_first_set()*/
|
|
||||||
/*a.calculate_state_automaton()*/
|
|
||||||
if (file_exists(compiled_name)) {
|
if (file_exists(compiled_name)) {
|
||||||
println("cached file exists")
|
println("cached file exists")
|
||||||
var pos = 0
|
var pos = 0
|
||||||
@@ -79,7 +56,7 @@ fun main():int {
|
|||||||
write_file_binary(compiled_name, serialize(file_contents) + serialize(a))
|
write_file_binary(compiled_name, serialize(file_contents) + serialize(a))
|
||||||
println("done writing")
|
println("done writing")
|
||||||
}
|
}
|
||||||
println(a.to_string())
|
/*println(a.to_string())*/
|
||||||
var doFirstSet = fun() {
|
var doFirstSet = fun() {
|
||||||
println("///////////////////START FIRST SET/////////////")
|
println("///////////////////START FIRST SET/////////////")
|
||||||
println("//TERMINALS//")
|
println("//TERMINALS//")
|
||||||
@@ -105,16 +82,17 @@ fun main():int {
|
|||||||
}
|
}
|
||||||
/*doFirstSet()*/
|
/*doFirstSet()*/
|
||||||
|
|
||||||
|
println(a.to_string())
|
||||||
|
a.parse_table.print_string()
|
||||||
var lex = lexer(a.terminals)
|
var lex = lexer(a.terminals)
|
||||||
|
|
||||||
/*lex.set_input(read_file(string("test_grammer.krak")))*/
|
lex.set_input(read_file(string("to_parse.krak")))
|
||||||
/*lex.set_input(string("ccdahas spacedhas*/
|
/*lex.set_input(string("ccdahas spacedhas*/
|
||||||
/*returndaaaaaaaaaaaaaa"))*/
|
/*returndaaaaaaaaaaaaaa"))*/
|
||||||
//lex.set_input(string("hibyed"))
|
//lex.set_input(string("hibyed"))
|
||||||
println("woo lexing:")
|
println("woo lexing:")
|
||||||
/*range(8).for_each(fun(i: int) { println(lex.next().to_string()); } )*/
|
range(8).for_each(fun(i: int) { println(lex.next().to_string()); } )
|
||||||
/*range(80).for_each(fun(i: int) { println(lex.next().to_string()); } )*/
|
/*range(80).for_each(fun(i: int) { println(lex.next().to_string()); } )*/
|
||||||
/*println(a.to_string())*/
|
|
||||||
|
|
||||||
|
|
||||||
var parse.construct(a): parser
|
var parse.construct(a): parser
|
||||||
|
|||||||
@@ -1,12 +1 @@
|
|||||||
|
why {}
|
||||||
def not_int int
|
|
||||||
|
|
||||||
adt maybe {
|
|
||||||
no_int,
|
|
||||||
an_int: int
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main(): int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user