In ansi_c: master
authorNick Downing <nick@ndcode.org>
Wed, 27 Dec 2023 13:44:43 +0000 (00:44 +1100)
committerNick Downing <nick@ndcode.org>
Wed, 27 Dec 2023 13:44:43 +0000 (00:44 +1100)
* First cut at pretty printer, fix minor inconsistencies in ansi_c.[ty]
* Rationalize how ParameterDeclaration is handled in both the parser (convert to a name, type pair as soon as it is parsed and then use this later to build the TypeFunctionANSI), and the pretty printer (attach the names to the parameters)
* Add expression precedence in the pretty printer
* Add declarator precedence in the pretty printer
* Add indenting in the pretty printer
* Fix a bug which prevented the -> operator from pretty printing correctly
* Fix a bug which prevented (void) argument list from pretty printing correctly
* Rationalize new scopes so they are only defined by an ItemList which can be either a TranslationUnit or a BlockItemList, make the definitions of enums, structs and unions from each new scope be output at the start of the ItemList
* In pretty printer, improve how base types are generated and structs printed
* Add stack-based VM for testing
* In /vm_asm.py, add the ability to assemble float128 numbers
* In /vm_test.asm, add more test routines
* In /vm_test.asm add floating-point printing routine, in /vm.c fix order of operands for the non-commutative operators sub(.r), div(.r|.u|.u.r) and relational operators, in /vm.c and /vm_asm.py add the forgotten mod(.r|.u|.u.r) operator (%)
* In /vm_test.asm add square-root calculation routine
* In /vm_test.asm use "offpc label@" instead of "imm.i32 label" for a significant space saving, in /vm_asm.py improve the listing file with auto operands
* In /vm_asm.py implement imm.iXX and imm.fXX constant optimization using cvt.XX
* Rename /vm_test.asm to /vm_test_128.asm, implement 64-bit and 32-bit versions
* In /pretty_print.t reorder the methods so that e.g. InitDeclaratorList comes after InitDeclarator (my script had placed these backwards when one was a prefix of another) and fix a bug with StatementFor occurring twice, in /*.[ty] change ArrayOrStructOrUnion to ArrayOrStruct and StatementIfElse to StatementIf, in /ansi_c.y fix bugs with missing %space before (?E{MemberIdentifier}IDENTIFIER)
* Make typedef processing occur by intercepting yylex(), it is much simpler
* New way of tracking typedef names so that the full scope analysis can be moved out of the parser and into a separate pass, rationalize DeclaratorFunction and TypeFunction everywhere so that both have derived classes for ANSI or KAndR
* New scope analysis in a separate module (clobbers the type analysis currently)
* Move code out of ansi_c.t into base_type.py, calc_type.py, calc_value.py, declarator.py, storage_class.py
* Add location tracking, syntax error and invalid character reporting
* Modify scope_analysis() to process the tree in strict pre-order
* Implement post_process() which recurses through the tree calling scope_analysis(), the scope_analysis() routine now just processes one node with no recursion
* Add type_analysis() method, called from post_process() in post-order
* Make type_analysis() also call calc_type() and add_cast() on Expression nodes
* Add post_process.Context object, to track return type and switch case type
* In /post_process.py and /type_analysis.py implement initializer stack, in /ansi_c.[ty] and /pretty_print.t remove the InitializerOrExpression base class in favour of wrapping initializer expressions in an extra InitializerExpression node
* Move ExpressionCall parameters coercion from calc_type() into type_analysis()
* Add value_analysis() method, called from post_process() after type_analysis()
* Set up a way of comparing the old scope/type/value analysis result with the new, fix a large number of bugs in both the old and the new so that they match up
* Remove old scope/type/value analysis, fix omissions where Declaration.storage_class was not set and formal parameters were not analyzed by new type analysis

In pilex:
* Fix an error recovery routine that seems to not run often

In pitree:
* Add location tracking, syntax error and invalid character reporting

In piyacc:
* Fix location for one error message
* Fix location tracking bugs (i) cursor was not initialized with input file name, (ii) id_loc and other places were corrupted by taking a reference to y_tab.yylloc rather than a copy, (iii) lex_yy.scanner_cursor was not put back when putting back text in state SC_AFTER_IDENTIFIER, (iv) line and column should be 1-based
* In /ndcode/piyacc/generate_py.py, remove a workaround that set yylval, yylloc before yychar = lex_yy.yylex(), as the relevant code is meant to match the yychar = lex_yy.yylex() call in the skeleton which doesn't have th workaround anymore
* Make syntax error call yyerror() rather than raising a Python exception

ansi_c
pilex
pitree
piyacc

diff --git a/ansi_c b/ansi_c
index c39842f..73f08e9 160000 (submodule)
--- a/ansi_c
+++ b/ansi_c
@@ -1 +1 @@
-Subproject commit c39842fe67772cf9f1f3ee5bcd4e6bcfd8cdb650
+Subproject commit 73f08e94567082fada05b723c8d6e5fb51511d92
diff --git a/pilex b/pilex
index d770ec4..b86581a 160000 (submodule)
--- a/pilex
+++ b/pilex
@@ -1 +1 @@
-Subproject commit d770ec46e9e4d24230a26396b8ed8d8ae1070b24
+Subproject commit b86581a189e4b0a7f225bf2f53cb6ebe6d0cdf3f
diff --git a/pitree b/pitree
index 8b06583..7cfa2ca 160000 (submodule)
--- a/pitree
+++ b/pitree
@@ -1 +1 @@
-Subproject commit 8b0658375b7ff477857dd2ff17a586e03cca2cbe
+Subproject commit 7cfa2cacfbd39fb61f5ddbf395ee2f8ed9e46ebf
diff --git a/piyacc b/piyacc
index 09a46ef..97733cd 160000 (submodule)
--- a/piyacc
+++ b/piyacc
@@ -1 +1 @@
-Subproject commit 09a46ef2a86c22a07e18824fd3e02bdad315413e
+Subproject commit 97733cda2bc0cacc5d7d77cb3ab0cbd8e953a162