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)
commit44bdf1fdef42582250ccdb308fbf28a3de3de119
tree44df61fdb3d5c77008e29fdbd90227ccf5b3662a
parent30bc90adf58250e95857191911d5cf87b18e7f7a
In ansi_c:
* 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