diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..7de8506
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+syntaxParser
\ No newline at end of file
diff --git a/.idea/SyntaxParser.iml b/.idea/SyntaxParser.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/.idea/SyntaxParser.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/deployment.xml b/.idea/deployment.xml
new file mode 100644
index 0000000..e54e1ea
--- /dev/null
+++ b/.idea/deployment.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..68c5ff3
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..79b3c94
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..c748bcd
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cmake-build-debug/SyntaxOut.txt b/cmake-build-debug/SyntaxOut.txt
new file mode 100644
index 0000000..dd23d8f
--- /dev/null
+++ b/cmake-build-debug/SyntaxOut.txt
@@ -0,0 +1,728 @@
+struct_type
+| member_list
+| | type_spec<>
+| | | base_type_spec<>
+| | | | floating_pt_type
+| | declarators<>
+| | | declarator
+| | | | more_declarator<>
+| | | more_declarators<>
+| | member_list
+| | | type_spec<>
+| | | | base_type_spec<>
+| | | | | floating_pt_type
+| | | declarators<>
+| | | | declarator
+| | | | | more_declarator<>
+| | | | more_declarators
+| | | | | declarator
+| | | | | | more_declarator<>
+| | | | | more_declarators
+| | | | | | declarator
+| | | | | | | more_declarator<>
+| | | | | | more_declarators<>
+| | | member_list
+| | | | type_spec<>
+| | | | | base_type_spec<>
+| | | | | | floating_pt_type
+| | | | declarators<>
+| | | | | declarator
+| | | | | | more_declarator<>
+| | | | | more_declarators<>
+| | | | member_list
+| | | | | type_spec<>
+| | | | | | struct_type
+| | | | | | | member_list
+| | | | | | | | type_spec<>
+| | | | | | | | | base_type_spec<>
+| | | | | | | | | | integer_type<>
+| | | | | | | | | | | signed_int
+| | | | | | | | declarators<>
+| | | | | | | | | declarator
+| | | | | | | | | | more_declarator<>
+| | | | | | | | | more_declarators<>
+| | | | | | | | member_list
+| | | | | | | | | type_spec<>
+| | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | signed_int
+| | | | | | | | | declarators<>
+| | | | | | | | | | declarator
+| | | | | | | | | | | more_declarator<>
+| | | | | | | | | | more_declarators<>
+| | | | | | | | | member_list
+| | | | | | | | | | type_spec<>
+| | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | signed_int
+| | | | | | | | | | declarators<>
+| | | | | | | | | | | declarator
+| | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | more_declarators
+| | | | | | | | | | | | declarator
+| | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | member_list
+| | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | signed_int
+| | | | | | | | | | | declarators<>
+| | | | | | | | | | | | declarator
+| | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | member_list
+| | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | | signed_int
+| | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | member_list
+| | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | | | signed_int
+| | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | member_list
+| | | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | | | | signed_int
+| | | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | | member_list<>
+| | | | | | | more_struct_type<>
+| | | | | declarators<>
+| | | | | | declarator
+| | | | | | | more_declarator<>
+| | | | | | more_declarators
+| | | | | | | declarator
+| | | | | | | | more_declarator<>
+| | | | | | | more_declarators<>
+| | | | | member_list
+| | | | | | type_spec<>
+| | | | | | | struct_type
+| | | | | | | | member_list
+| | | | | | | | | type_spec<>
+| | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | unsigned_int
+| | | | | | | | | declarators<>
+| | | | | | | | | | declarator
+| | | | | | | | | | | more_declarator<>
+| | | | | | | | | | more_declarators<>
+| | | | | | | | | member_list
+| | | | | | | | | | type_spec<>
+| | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | unsigned_int
+| | | | | | | | | | declarators<>
+| | | | | | | | | | | declarator
+| | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | more_declarators<>
+| | | | | | | | | | member_list
+| | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | unsigned_int
+| | | | | | | | | | | declarators<>
+| | | | | | | | | | | | declarator
+| | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | more_declarators
+| | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | member_list
+| | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | | unsigned_int
+| | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | member_list
+| | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | | | unsigned_int
+| | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | more_declarators
+| | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | member_list
+| | | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | | | | unsigned_int
+| | | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | | member_list
+| | | | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | | | | | unsigned_int
+| | | | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | | | member_list<>
+| | | | | | | | more_struct_type<>
+| | | | | | declarators<>
+| | | | | | | declarator
+| | | | | | | | more_declarator<>
+| | | | | | | more_declarators
+| | | | | | | | declarator
+| | | | | | | | | more_declarator<>
+| | | | | | | | more_declarators<>
+| | | | | | member_list
+| | | | | | | type_spec<>
+| | | | | | | | base_type_spec
+| | | | | | | declarators<>
+| | | | | | | | declarator
+| | | | | | | | | more_declarator<>
+| | | | | | | | | | exp_list
+| | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | multi_sign
+| | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | more_or_expr
+| | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | more_or_expr
+| | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | more_or_expr<>
+| | | | | | | | more_declarators<>
+| | | | | | | member_list
+| | | | | | | | type_spec<>
+| | | | | | | | | base_type_spec
+| | | | | | | | declarators<>
+| | | | | | | | | declarator
+| | | | | | | | | | more_declarator<>
+| | | | | | | | | | | exp_list
+| | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | more_and_expr
+| | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | more_or_expr
+| | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | more_shift_expr
+| | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | more_shift_expr
+| | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | more_or_expr
+| | | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | unary_declare<>
+| | | | | | | | | | | | | | | | | | | | | | BOOLEAN_VALUE
+| | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | more_xor_expr
+| | | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | unary_declare<>
+| | | | | | | | | | | | | | | | | | | | | | | BOOLEAN_VALUE
+| | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | | more_or_expr
+| | | | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_sign_2
+| | | | | | | | | | | | | | | | | | | | | | unary_declare<>
+| | | | | | | | | | | | | | | | | | | | | | | BOOLEAN_VALUE
+| | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | | more_xor_expr
+| | | | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_sign_2
+| | | | | | | | | | | | | | | | | | | | | | | unary_declare<>
+| | | | | | | | | | | | | | | | | | | | | | | | BOOLEAN_VALUE
+| | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | | | more_or_expr<>
+| | | | | | | | | more_declarators<>
+| | | | | | | | member_list
+| | | | | | | | | type_spec<>
+| | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | signed_int
+| | | | | | | | | declarators<>
+| | | | | | | | | | declarator
+| | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | exp_list
+| | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | shift_sign
+| | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | more_or_expr
+| | | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | shift_sign
+| | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | | more_or_expr
+| | | | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_sign
+| | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_sign
+| | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | unary_sign
+| | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | | | more_or_expr
+| | | | | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | multi_sign
+| | | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | multi_sign
+| | | | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | | | | more_or_expr<>
+| | | | | | | | | | more_declarators<>
+| | | | | | | | | member_list
+| | | | | | | | | | type_spec<>
+| | | | | | | | | | | base_type_spec
+| | | | | | | | | | declarators<>
+| | | | | | | | | | | declarator
+| | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | exp_list
+| | | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | more_and_expr
+| | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | more_shift_expr
+| | | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | more_xor_expr
+| | | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_sign_2
+| | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | | shift_sign
+| | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | more_shift_expr
+| | | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | | | shift_sign
+| | | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2
+| | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | multi_sign
+| | | | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | multi_sign
+| | | | | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign
+| | | | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign
+| | | | | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | | more_or_expr<>
+| | | | | | | | | | | more_declarators<>
+| | | | | | | | | | member_list
+| | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | struct_type
+| | | | | | | | | | | | | member_list
+| | | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | | | floating_pt_type
+| | | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | | member_list
+| | | | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | | | base_type_spec<>
+| | | | | | | | | | | | | | | | | integer_type<>
+| | | | | | | | | | | | | | | | | | signed_int
+| | | | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | | | member_list
+| | | | | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | | | | struct_type
+| | | | | | | | | | | | | | | | | | member_list
+| | | | | | | | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | | | | | | | base_type_spec
+| | | | | | | | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | | | | | | | | exp_list
+| | | | | | | | | | | | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | more_shift_expr
+| | | | | | | | | | | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | more_or_expr<>
+| | | | | | | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | | | | | | | member_list
+| | | | | | | | | | | | | | | | | | | | type_spec<>
+| | | | | | | | | | | | | | | | | | | | | base_type_spec
+| | | | | | | | | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | | | | | | | | | exp_list
+| | | | | | | | | | | | | | | | | | | | | | | | or_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | xor_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | and_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | shift_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | add_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_sign_2<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unary_declare
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | more_unary_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | | more_multi_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | | more_add_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | | more_shift_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | | more_and_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | | more_xor_expr<>
+| | | | | | | | | | | | | | | | | | | | | | | | more_or_expr<>
+| | | | | | | | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | | | | | | | | member_list<>
+| | | | | | | | | | | | | | | | | | more_struct_type<>
+| | | | | | | | | | | | | | | | declarators<>
+| | | | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | | | more_declarators
+| | | | | | | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | | | | | | member_list<>
+| | | | | | | | | | | | | more_struct_type<>
+| | | | | | | | | | | declarators<>
+| | | | | | | | | | | | declarator
+| | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | more_declarators
+| | | | | | | | | | | | | declarator
+| | | | | | | | | | | | | | more_declarator<>
+| | | | | | | | | | | | | more_declarators<>
+| | | | | | | | | | | member_list<>
+| more_struct_type
diff --git a/include/SyntaxParser.h b/include/SyntaxParser.h
index 1b4b32c..0cb0354 100644
--- a/include/SyntaxParser.h
+++ b/include/SyntaxParser.h
@@ -12,6 +12,7 @@
#include
#include
+#include
@@ -22,6 +23,8 @@ class SyntaxParser {
std::wofstream output;
+ std::wofstream treeOutput;
+
const GrammarResourcePool *pool;
const AnalyseTableGenerator *atg;
@@ -32,6 +35,8 @@ class SyntaxParser {
std::stack status_stack;
+ std::stack tree_stack;
+
std::vector lines_index;
std::wstringstream string_buffer;
@@ -42,21 +47,27 @@ class SyntaxParser {
static std::pair get_token_info(const std::wstring &token);
+ SyntaxTree syntaxTree;
+
public:
SyntaxParser(const GrammarResourcePool *pool, const AnalyseTableGenerator *atg):
input("tokenOut.txt", std::ios::binary),
pool(pool),
atg(atg),
- output("SyntaxOut.txt", std::ios::binary){
+ output("AnalyseOut.txt", std::ios::binary),
+ treeOutput("SyntaxOut.txt", std::ios::binary){
auto* codeCvtToUTF8= new std::codecvt_utf8;
input.imbue(std::locale(input.getloc(), codeCvtToUTF8));
output.imbue(std::locale(output.getloc(), codeCvtToUTF8));
+ treeOutput.imbue(std::locale(output.getloc(), codeCvtToUTF8));
}
~SyntaxParser() {
+ input.close();
output.close();
+ treeOutput.close();
}
// 得到所有的产生式
@@ -69,9 +80,12 @@ public:
// 自底向上语法分析
void parse();
+ void printError(std::wofstream &errOutput);
+
void printError();
void printDone();
+
};
diff --git a/include/SyntaxTree.h b/include/SyntaxTree.h
new file mode 100644
index 0000000..5c7fbb1
--- /dev/null
+++ b/include/SyntaxTree.h
@@ -0,0 +1,69 @@
+//
+// Created by Administrator on 2021/5/12.
+//
+
+#ifndef SYNTAXPARSER_SYNTAXTREE_H
+#define SYNTAXPARSER_SYNTAXTREE_H
+
+#include
+#include
+#include
+#include
+#include
+
+class TreeNode {
+ const int nodeType;
+ TreeNode *father = nullptr;
+ std::vector infoVec;
+ std::vector children;
+
+public:
+
+ explicit TreeNode(int nodeType) : nodeType(nodeType) {
+
+ }
+
+ void addInfo(const std::wstring& info) {
+ infoVec.push_back(info);
+ }
+
+ void setFather(TreeNode *fatherNode) {
+ if(fatherNode == this) {
+ throw std::runtime_error("Illegal Tree Structure");
+ }
+ if(std::find(fatherNode->children.begin(), fatherNode->children.end(), this) == fatherNode->children.end()) {
+ fatherNode->children.push_back(this);
+ }
+ this->father = fatherNode;
+ }
+
+ const std::vector &getChildren() {
+ return children;
+ }
+
+ const std::vector &getInfoVec() {
+ return infoVec;
+ }
+};
+
+class SyntaxTree {
+
+ TreeNode *root = nullptr;
+
+ void do_tree_node_print(TreeNode *thisNode, std::wofstream &stream);
+public:
+
+ std::stack tabStack;
+
+ const int spacesInTab = 4;
+
+ void setRoot(TreeNode *node) {
+ this->root = node;
+ }
+
+ void print(std::wofstream &stream);
+
+};
+
+
+#endif //SYNTAXPARSER_SYNTAXTREE_H
diff --git a/src/SyntaxParser.cpp b/src/SyntaxParser.cpp
index a10e370..9627dad 100644
--- a/src/SyntaxParser.cpp
+++ b/src/SyntaxParser.cpp
@@ -14,7 +14,7 @@ void SyntaxParser::parse() {
auto *p_step = atg->findActionStep(status_stack.top(), tokens_queue.front());
if(p_step == nullptr) {
- printError();
+ printError(output);
return;
}
@@ -22,15 +22,24 @@ void SyntaxParser::parse() {
output << "MOVE IN" << "(AUTOMATA STATUS " << status_stack.top() <<"): ";
printSymbol(tokens_queue.front());
+ auto *node = new TreeNode(tokens_queue.front());
+
+ auto *p_symbol = pool->getSymbol(tokens_queue.front());
+ if(p_symbol->terminator) {
+ node->addInfo(L"terminator");
+ }
+ node->addInfo(p_symbol->name);
+
status_stack.push(p_step->target.index);
analyse_stack.push(tokens_queue.front());
+ tree_stack.push(node);
if(_line_index > max_line_index) {
string_buffer.str(L"");
string_buffer.clear();
max_line_index = lines_index[now_line++];
}
- string_buffer << pool->getSymbol(tokens_queue.front())->name << " ";
+ string_buffer << p_symbol->name << " ";
tokens_queue.pop();
_line_index++;
}
@@ -41,13 +50,41 @@ void SyntaxParser::parse() {
printProduction(p_pdt);
output << "]";
+ std::stack temp_stack;
+
for(int i : p_pdt->right) {
if(i == 0)
continue;
analyse_stack.pop();
status_stack.pop();
+ temp_stack.push(tree_stack.top());
+ tree_stack.pop();
}
+ auto *fatherNode = new TreeNode(p_pdt->left);
+
+ fatherNode->addInfo(pool->getSymbol(p_pdt->left)->name);
+
+ // std::wcout << fatherNode->getInfoVec()[0] << std::endl;
+
+ while(!temp_stack.empty()) {
+
+ // std::wcout << temp_stack.top()->getInfoVec()[0] << std::endl;
+
+ const auto &childInfo = temp_stack.top()->getInfoVec();
+ if(childInfo[0] == L"terminator") {
+ for(int i = 1; i < childInfo.size() ; i++) {
+ fatherNode->addInfo(childInfo[i]);
+ }
+ delete temp_stack.top();
+ } else {
+ temp_stack.top()->setFather(fatherNode);
+ }
+ temp_stack.pop();
+ }
+
+ // std::wcout << std::endl;
+
auto *p_goto_step =
atg->findGotoStep(status_stack.top(), p_pdt->left);
@@ -57,9 +94,12 @@ void SyntaxParser::parse() {
}
analyse_stack.push(p_pdt->left);
+ tree_stack.push(fatherNode);
status_stack.push(p_goto_step->target.index);
} else if (p_step->action == ACC) {
+ syntaxTree.setRoot(tree_stack.top());
+ tree_stack.pop();
output << "ACC";
printDone();
return;
@@ -148,16 +188,23 @@ void SyntaxParser::printDone() {
output << std::endl;
output << "------------------------------------------------------" << std::endl;
output << "Syntax Parser Work Done, No Error Found." << std::endl << std::endl;
+
+ syntaxTree.print(treeOutput);
+}
+
+void SyntaxParser::printError(std::wofstream &errOutput) {
+ std::wstring temp_line = string_buffer.str();
+ errOutput << std::endl;
+ errOutput << "------------------------------------------------------" << std::endl;
+ errOutput.fill('-');
+ errOutput.width(24);
+ errOutput << "Syntax Parser Found Error: " << std::endl
+ << "At [Line " << now_line << "]: " << temp_line
+ << "<- Next Token{" << pool->getSymbol(tokens_queue.front())->name << "}" << std::endl;
+ errOutput << "AUTOMATA STATUS " << status_stack.top() << std::endl;
}
void SyntaxParser::printError() {
- std::wstring temp_line = string_buffer.str();
- output << std::endl;
- output << "------------------------------------------------------" << std::endl;
- output.fill('-');
- output.width(24);
- output << "Syntax Parser Found Error: " << std::endl
- << "At [Line " << now_line << "]: " << temp_line
- << "<- Next Token{" << pool->getSymbol(tokens_queue.front())->name << "}" << std::endl;
- output << "AUTOMATA STATUS " << status_stack.top() << std::endl;
+ printError(output);
+ printError(treeOutput);
}
diff --git a/src/SyntaxTree.cpp b/src/SyntaxTree.cpp
new file mode 100644
index 0000000..c180fb5
--- /dev/null
+++ b/src/SyntaxTree.cpp
@@ -0,0 +1,52 @@
+//
+// Created by Administrator on 2021/5/12.
+//
+
+#include "SyntaxTree.h"
+
+void SyntaxTree::do_tree_node_print(TreeNode *thisNode, std::wofstream &stream) {
+
+ tabStack.push(tabStack.top() + 1);
+
+ for(int i = tabStack.top() * spacesInTab; i > 0; i--) {
+ if(i % spacesInTab == 0) {
+ stream << L'|';
+ }
+ stream << L' ';
+ }
+
+
+ int count = 0;
+ for(auto &info : thisNode->getInfoVec()) {
+ if(count++ != 0) {
+ if(count != 2) {
+ stream << L", ";
+ }
+ stream << info;
+ } else {
+ stream << info << L'<';
+ }
+ }
+
+ stream << L'>';
+
+ stream << L'\n';
+
+ if(!thisNode->getChildren().empty()) {
+ for (auto &node : thisNode->getChildren()) {
+ do_tree_node_print(node, stream);
+ }
+ }
+
+ tabStack.pop();
+}
+
+void SyntaxTree::print(std::wofstream &stream) {
+
+ if(this->root == nullptr) return;
+
+ tabStack.push(-1);
+
+ do_tree_node_print(root, stream);
+
+}