#ifndef PARSER_PARSER_H #define PARSER_PARSER_H #include #include #include #include #include "globals.h" // State of lexical parser (filename and position in file) struct lexical_state { std::string filename,curdir; unsigned int inclevel; unsigned int curline,curpos,curoffset; }; // Container for "static" parameters of lexical parser struct lexical_extra { std::string includedirs,moduledirs; struct lexical_state state; unsigned int maxinclevel; int retcode; VarType *vars; ExecType *tosave, *toprint; std::stack fds; std::stack states; ~lexical_extra() { while(fds.size()!=0) {fclose(fds.top()); fds.pop();} while(states.size()!=0) states.pop(); } void ParsePath(const std::string& path) { // !!!NONPORTABLE!!! if('/'==path[0]) state.curdir=path.substr(0,path.rfind('/')+1); // absolute path else if(std::string::npos!=path.rfind('/')) state.curdir+=path.substr(0,path.rfind('/')+1); // relative path state.filename=path.substr((path.rfind('/')!=std::string::npos)?(path.rfind('/')+1):0,std::string::npos); } }; #if !defined CONFLTYPE && !defined CONFLTYPE_IS_DECLARED typedef struct grammatic_location CONFLTYPE; #define CONFLTYPE_IS_DECLARED 1 #endif #endif