Last active
August 18, 2016 12:12
-
-
Save ponyatov/bfc2134eb58fb18046e3b350eaf9adf6 to your computer and use it in GitHub Desktop.
parser-enabled program required #includes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _H_HPP | |
#define _H_HPP | |
// required includes | |
#include <iostream> | |
#include <cstdlib> | |
#include <vector> | |
#include <map> | |
using namespace std; | |
#include "meta.hpp" | |
// algebraic data type (base class) | |
struct Sym { | |
string tag; // item class/type/tag | |
string val; // item value (can be any type in inherited classes + head() overloaded) | |
Sym(string,string); // tag:value constructor | |
Sym(string); // lexer constructor (see TAG() macro) | |
vector<Sym*> nest; void push(Sym*); // Sym object can store <nested elements> | |
virtual string dump(int=0); // \ dump Sym object in nested tree form | |
virtual string head(); // <T:V> header | |
string pad(int); // / tree padding function | |
} | |
extern map<string,Sym*> glob; // global symbol table | |
extern void glob_init(); | |
// lexer/parser interface | |
extern int yylex(); | |
extern int yylineno; | |
extern char* yytext; | |
#define TOC(C,X) { yylval.o = new C(yytext); return X; } | |
extern int yyparse(); | |
extern void yyerror(string); | |
#include "ypp.tab.hpp" | |
#endif // _H_HPP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment