Changeset cbd1ba8


Ignore:
Timestamp:
Dec 19, 2022, 11:51:04 AM (19 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
d0bdb18
Parents:
c63f470
Message:

Moved parsing code out of main into the parsing directly, as an organizational improvement. The new files use the new naming convention, and should be converted to the new AST.

Location:
src
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/module.mk

    rc63f470 rcbd1ba8  
    3030       Parser/parserutility.cc \
    3131       Parser/parserutility.h \
     32       Parser/RunParser.cpp \
     33       Parser/RunParser.hpp \
    3234       Parser/StatementNode.cc \
    3335       Parser/TypeData.cc \
  • src/main.cc

    rc63f470 rcbd1ba8  
    5959#include "InitTweak/GenInit.h"              // for genInit
    6060#include "MakeLibCfa.h"                     // for makeLibCfa
    61 #include "Parser/ParseNode.h"               // for DeclarationNode, buildList
    62 #include "Parser/TypedefTable.h"            // for TypedefTable
     61#include "Parser/RunParser.hpp"             // for buildList, dumpParseTree,...
    6362#include "ResolvExpr/CandidatePrinter.hpp"  // for printCandidates
    6463#include "ResolvExpr/Resolver.h"            // for resolve
     
    109108        Stats::Time::StopBlock();
    110109
    111 LinkageSpec::Spec linkage = LinkageSpec::Cforall;
    112 TypedefTable typedefTable;
    113 DeclarationNode * parseTree = nullptr;                                  // program parse tree
    114 
    115110static bool waiting_for_gdb = false;                                    // flag to set cfa-cpp to wait for gdb on start
    116111
     
    118113
    119114static void parse_cmdline( int argc, char * argv[] );
    120 static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit = false );
    121115static void dump( list< Declaration * > & translationUnit, ostream & out = cout );
    122116static void dump( ast::TranslationUnit && transUnit, ostream & out = cout );
     
    301295
    302296                if ( parsep ) {
    303                         parseTree->printList( cout );
    304                         delete parseTree;
    305                         return EXIT_SUCCESS;
    306                 } // if
    307 
    308                 buildList( parseTree, translationUnit );
    309                 delete parseTree;
    310                 parseTree = nullptr;
     297                        dumpParseTree( cout );
     298                        return EXIT_SUCCESS;
     299                } // if
     300
     301                translationUnit = buildUnit();
    311302
    312303                if ( astp ) {
     
    748739} // parse_cmdline
    749740
    750 static void parse( FILE * input, LinkageSpec::Spec linkage, bool shouldExit ) {
    751         extern int yyparse( void );
    752         extern FILE * yyin;
    753         extern int yylineno;
    754 
    755         ::linkage = linkage;                                                            // set globals
    756         yyin = input;
    757         yylineno = 1;
    758         int parseStatus = yyparse();
    759 
    760         fclose( input );
    761         if ( shouldExit || parseStatus != 0 ) {
    762                 exit( parseStatus );
    763         } // if
    764 } // parse
    765 
    766741static bool notPrelude( Declaration * decl ) {
    767742        return ! LinkageSpec::isBuiltin( decl->get_linkage() );
Note: See TracChangeset for help on using the changeset viewer.