/* * Copyright 1993, 2000 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ #include "Parse.hpp" #include "Jam.hpp" #include "Scan.hpp" #include "String.hpp" using Jam::String; namespace Jam { Parse* Parse::yypsave; } /* * parse.c - make and destroy parse trees as driven by the parser * * 09/07/00 (seiwald) - ref count on PARSE to avoid freeing when used, * as per Matt Armstrong. * 09/11/00 (seiwald) - structure reworked to reflect that (*func)() * returns a List *. */ namespace Jam { Parse::Parse( List *(*func)( Parse *p, LOL *args ), Parse *left, Parse *right, Parse *third, const char *string, const char *string1, const int num_ ) : num(num_) { this->func = func; this->left = left; this->right = right; this->third = third; this->string = string; this->string1 = string1; this->refs = 1; } void Parse::AddRef(void) { ++refs; } void Parse::Release(void) { if( --refs == 0 ) { delete this; } } void Parse::parse_file( const char *f ) { /* Suspend scan of current file */ /* and push this new file in the stream */ yyfparse((char*)f); /* Now parse each block of rules and execute it. */ /* Execute it outside of the parser so that recursive */ /* calls to yyrun() work (no recursive yyparse's). */ for(;;) { LOL l; Parse *p; /* $(<) and $(>) empty in outer scope. */ lol_init( &l ); /* Filled by yyparse() calling parse_save() */ yypsave = 0; /* If parse error or empty parse, outta here */ if( yyparse() || !( p = yypsave ) ) break; /* Run the parse tree. */ (*(p->func))( p, &l ); p->Release(); } } void Parse::parse_save( Parse *p ) { yypsave = p; } Parse::~Parse(void) { if( string ) { String::freestr( string ); } if( string1 ) { String::freestr( string1 ); } if( left ) { left->Release(); } if( right ) { right->Release(); } if( third ) { third->Release(); } delete this; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#8 | 1162 | bob_summerwill | Converted LIST into a List class, with all static methods. | ||
#7 | 1161 | bob_summerwill | Added a constructor and destructor to Parse. | ||
#6 | 1156 | bob_summerwill | Converted Parse into a class. | ||
#5 | 1153 | bob_summerwill | NewStr has been renamed as String. | ||
#4 | 1146 | bob_summerwill | Moved the NewStr global functions into a static class Jam::String. | ||
#3 | 1138 | bob_summerwill | Removed all extern "C" wrappers, so the program now has C++ linkage throughout, ready for refactoring. | ||
#2 | 1132 | bob_summerwill | All of the non-generated, non-platform-specific files are now mixed-case C++ source files. | ||
#1 | 1131 | bob_summerwill | More .C to .CPP conversions. | ||
//guest/bob_summerwill/jam/src/parse.c | |||||
#6 | 1130 | bob_summerwill | More .C to .CPP conversions. | ||
#5 | 1129 | bob_summerwill | Some const-correctness fixes. | ||
#4 | 1127 | bob_summerwill | More file renaming. | ||
#3 | 1126 | bob_summerwill | #include dependencies between headers are now modelled explicitly, with #includes as required in header files, rather than it being a client-code responsibility. | ||
#2 | 1120 | bob_summerwill | A fair-size chunk of char* const-correctness modifications. | ||
#1 | 1106 | bob_summerwill | Integrated Jam from "public" to "guest/bob_summerwill". | ||
//guest/perforce_software/jam/src/parse.c | |||||
#2 | 486 | Perforce staff |
Jam 2.3. See RELNOTES for a list of changes from 2.2.x. Just about every source file was touched when jam got ANSI-fied. |
||
#1 | 2 | laura | Add Jam/MR 2.2 source |