/* * Copyright 1993, 2000 Christopher Seiwald. * * This file is part of Jam - see jam.c for Copyright information. */ #include "Parse.hpp" #include "Jam.hpp" #include "NewStr.hpp" #include "Scan.hpp" /* * 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 *. */ static PARSE *yypsave; void 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 ); parse_free( p ); } } void parse_save( PARSE *p ) { yypsave = p; } PARSE * parse_make( LIST *(*func)( PARSE *p, LOL *args ), PARSE *left, PARSE *right, PARSE *third, const char *string, const char *string1, const int num ) { PARSE *p = (PARSE *)malloc( sizeof( PARSE ) ); p->func = func; p->left = left; p->right = right; p->third = third; p->string = string; p->string1 = string1; p->num = num; p->refs = 1; return p; } void parse_refer( PARSE *p ) { ++p->refs; } void parse_free( PARSE *p ) { if( --p->refs ) return; if( p->string ) freestr( p->string ); if( p->string1 ) freestr( p->string1 ); if( p->left ) parse_free( p->left ); if( p->right ) parse_free( p->right ); if( p->third ) parse_free( p->third ); free( (char *)p ); }
# | 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 |