Untitled

 avatar
unknown
c_cpp
a year ago
959 B
5
Indexable
%{
#include<iostream>
#include<string>
#include<vector>

extern "C" {
	int yyparse();
	int yylex();
}

%union{
struct Node{
	char *token;
	int noterminal, h;
	Node *ch[15];
	Node():token(NULL), noterminal(0), h(0){memset(ch, 0, sizeof(ch));}
	Node(char *yytext):token(NULL), noterminal(0), h(0){
		memset(ch, 0, sizeof(ch));
		int sz = strlen(yytext) + 1;
		token = new char[sz];
		memcpy(token, yytext, sz);
	}
};
}
#define YYSTYPE Node*



-----------------------------------

%{
#include<iostream>
#include<string>
#include<vector>

extern "C" {
	int yyparse();
	int yylex();
}

struct Node{
	char *token;
	int noterminal, h;
	Node *ch[15];
	Node():token(NULL), noterminal(0), h(0){memset(ch, 0, sizeof(ch));}
	Node(char *yytext):token(NULL), noterminal(0), h(0){
		memset(ch, 0, sizeof(ch));
		int sz = strlen(yytext) + 1;
		token = new char[sz];
		memcpy(token, yytext, sz);
	}
};
#define YYSTYPE Node*
Editor is loading...
Leave a Comment