本文整理汇总了C++中parsetree_t类的典型用法代码示例。如果您正苦于以下问题:C++ parsetree_t类的具体用法?C++ parsetree_t怎么用?C++ parsetree_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了parsetree_t类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: statement
void parser_t::statement()
{
parsetree.push(NT_Statement);
switch(scanner.next_token())
{
case T_label:
label();
break;
case T_goto:
jump();
outSave += ";\n";
break;
case T_m:
assignments();
outSave += ";\n";
break;
case T_print:
print();
outSave += ";\n";
break;
default:
syntax_error(NT_Statement);
break;
}
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:27,代码来源:calc.cpp
示例2: Assignment
void parser_t::Assignment(){
parsetree.push(NT_Assignment);
switch( scanner.next_token() )
{
case T_opensquare:
cerr<<"m";
eat_token(T_opensquare);
cerr<<"[ ";
Expression();
scanner.next_token();
eat_token(T_closesquare);
cerr<<" ] ";
scanner.next_token();
eat_token(T_equals);
cerr<<" = ";
Expression();
cerr<<"; \n";
scanner.next_token();
break;
// case T_eof:
// parsetree.drawepsilon();
// break;
default:
syntax_error(NT_Assignment);
break;
}
//now that we are done with List, we can pop it from the data
//stucture that is tracking it for drawing the parse tree
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:35,代码来源:calc.cpp
示例3: TermP
void parser_t::TermP(){
parsetree.push(NT_TermP);
switch( scanner.next_token() )
{
case T_times:
eat_token(T_times);
cerr<<" * ";
Factor();
TermP();
break;
case T_divide:
eat_token(T_divide);
cerr<<" / ";
Factor();
TermP();
break;
case T_eof:
parsetree.drawepsilon();
break;
default:
parsetree.drawepsilon();
// syntax_error(NT_ExpressionP);
break;
}
//now that we are done with List, we can pop it from the data
//stucture that is tracking it for drawing the parse tree
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:35,代码来源:calc.cpp
示例4: Jump_
// Jump_ -> "if" Expression | epsilon
void parser_t::Jump_(std::string label_name)
{
std::string exp;
parsetree.push(NT_Jump_);
switch(scanner.next_token()) {
case T_if:
// conditional jump
eat_token(T_if);
exp = Expression();
fprintf(stderr, "\tif (%s) goto label%s;", exp.c_str(), label_name.c_str());
break;
case T_m:
case T_label:
case T_goto:
case T_equals:
case T_print:
case T_eof:
fprintf(stderr, "\tgoto label%s;", label_name.c_str());
parsetree.drawepsilon();
// From follow set
break;
default:
syntax_error(NT_Jump_);
}
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:28,代码来源:calc.cpp
示例5: MoreStatement
void parser_t::MoreStatement(){
parsetree.push(NT_MoreStatement);
switch(scanner.next_token()){
case T_label:
case T_m:
case T_goto:
case T_print:
Statement();
MoreStatement();
break;
case T_eof:
parsetree.drawepsilon();
break;
default:
syntax_error(NT_MoreStatement);
break;
}
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:27,代码来源:calc.cpp
示例6: Start
//Here is an example
void parser_t::Start()
{
//push this non-terminal onto the parse tree.
//the parsetree class is just for drawing the finished
//parse tree, and should in should have no effect the actual
//parsing of the data
parsetree.push(NT_Start);
switch( scanner.next_token() )
{
case T_plus:
eat_token(T_plus);
Start();
break;
case T_eof:
parsetree.drawepsilon();
break;
default:
syntax_error(NT_Start);
break;
}
//now that we are done with List, we can pop it from the data
//stucture that is tracking it for drawing the parse tree
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:27,代码来源:calc.cpp
示例7: Statements
void parser_t::Statements()
{
//push this non-terminal onto the parse tree.
//the parsetree class is just for drawing the finished
//parse tree, and should in should have no effect the actual
//parsing of the data
parsetree.push(NT_Statements);
bool thereIsMore = true;
switch( scanner.next_token() )
{
case T_label:
case T_goto:
case T_m:
case T_print:
Statement();
Statements();
break;
case T_eof:
thereIsMore = false;
break;
default:
syntax_error(NT_Statements);
break;
}
//now that we are done with List, we can pop it from the data
//stucture that is tracking it for drawing the parse tree
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:30,代码来源:calc.cpp
示例8: Factor
void parser_t::Factor()
{
//push this non-terminal onto the parse tree.
//the parsetree class is just for drawing the finished
//parse tree, and should in should have no effect the actual
//parsing of the data
parsetree.push(NT_Factor);
switch( scanner.next_token() )
{
case T_num:
eat_token(T_num);
if(scanner.next_token()==T_power)
{
powBuffer=scanner.numberList[numberListSpot];
}
else
cerr << scanner.numberList[numberListSpot];
numberListSpot++;
break;
case T_m:
eat_token(T_m);
cerr << "m";
if (scanner.next_token() == T_opensquare)
{
eat_token(T_opensquare);
cerr << "[";
Expression();
if(scanner.next_token() == T_closesquare)
{
eat_token(T_closesquare);
cerr << "]";
}
else
syntax_error(NT_Factor);
}
else
syntax_error(NT_Factor);
break;
case T_openparen:
eat_token(T_openparen);
cerr << "(";
Expression();
if (scanner.next_token() == T_closeparen)
{
eat_token(T_closeparen);
cerr << ")";
}
else
syntax_error(NT_Factor);
break;
default:
syntax_error(NT_Factor);
break;
}
//now that we are done with List, we can pop it from the data
//stucture that is tracking it for drawing the parse tree
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:60,代码来源:calc.cpp
示例9: Jump
void parser_t::Jump()
{
//push this non-terminal onto the parse tree.
//the parsetree class is just for drawing the finished
//parse tree, and should in should have no effect the actual
//parsing of the data
parsetree.push(NT_Jump);
if(scanner.next_token() == T_goto)
{
eat_token(T_goto);
if(scanner.next_token() == T_num)
{
eat_token(T_num);
int labelNum = scanner.numberList[numberListSpot];
numberListSpot++;
JumpP(labelNum);
}
else
syntax_error(NT_Jump);
}
else
syntax_error(NT_Jump);
//now that we are done with List, we can pop it from the data
//stucture that is tracking it for drawing the parse tree
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:29,代码来源:calc.cpp
示例10: numend
void parser_t::numend(string& expString)
{
parsetree.push(NT_NumEnd);
switch(scanner.next_token())
{
case T_openparen:
//cout <<"here";
eat_token(T_openparen);
expString += "(";
//cout<< "ga";
expString += expression();
//cout <<"wtfffff";
eat_token(T_closeparen);
expString += ")";
break;
case T_m:
eat_token(T_m);
eat_token(T_opensquare);
expString += "m[";
expString += expression();
eat_token(T_closesquare);
expString += "]";
break;
case T_num:
//cout <<"num found";
eat_token(T_num);
expString += scanner.numString();
break;
default:
syntax_error(NT_NumEnd);
break;
}
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:34,代码来源:calc.cpp
示例11: Power
void parser_t::Power()
{
//push this non-terminal onto the parse tree.
//the parsetree class is just for drawing the finished
//parse tree, and should in should have no effect the actual
//parsing of the data
parsetree.push(NT_Power);
switch( scanner.next_token() )
{
case T_num:
Factor();
PowerP();
break;
case T_m:
Factor();
PowerP();
break;
case T_openparen:
Factor();
PowerP();
break;
default:
syntax_error(NT_Power);
break;
}
//now that we are done with List, we can pop it from the data
//stucture that is tracking it for drawing the parse tree
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:31,代码来源:calc.cpp
示例12: expImouto
bool parser_t::expImouto(string& expString)
{
parsetree.push(NT_Exp);
bool rr = false;
switch(scanner.next_token())
{
case T_power:
eat_token(T_power);
expString += ",";
numend(expString);
expString += ")";
rr = true;
break;
case T_eof:
parsetree.drawepsilon();
break;
case T_times:
case T_divide:
case T_plus:
case T_minus:
case T_closeparen:
case T_closesquare:
case T_label:
case T_goto:
case T_m:
case T_print:
parsetree.drawepsilon();
break;
default:
syntax_error(NT_Exp);
break;
}
parsetree.pop();
return rr;
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:35,代码来源:calc.cpp
示例13: expressionImouto
void parser_t::expressionImouto(string& expString)
{
parsetree.push(NT_ExpressionImouto);
switch(scanner.next_token())
{
case T_plus:
eat_token(T_plus);
expString += "+";
furu(expString);
expressionImouto(expString);
break;
case T_minus:
eat_token(T_minus);
expString += "-";
furu(expString);
expressionImouto(expString);
break;
case T_eof:
parsetree.drawepsilon();
break;
case T_closeparen:
case T_closesquare:
case T_label:
case T_goto:
case T_m:
case T_print:
parsetree.drawepsilon();
break;
default:
syntax_error(NT_ExpressionImouto);
}
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:33,代码来源:calc.cpp
示例14: jumpImouto
void parser_t::jumpImouto()
{
parsetree.push(NT_JumpImouto);
switch(scanner.next_token())
{
case T_if:
eat_token(T_if);
outSave += "if(";
outSave += expression();
outSave += ")";
break;
case T_eof:
parsetree.drawepsilon();
break;
case T_label:
case T_goto:
case T_m:
case T_print:
break;
default:
syntax_error(NT_JumpImouto);
break;
}
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:25,代码来源:calc.cpp
示例15: Rel
int parser_t::Rel(int v)
{
parsetree.push(NT_Rel);
switch( scanner.next_token() )
{
case T_num:
v = RelP(Expr(v));
break;
case T_lt:
eat_token(T_lt);
if (v < Expr(v)) v = 1;
else v = 0;
break;
case T_gt:
eat_token(T_gt);
if (v > Expr(v)) v = 1;
else v = 0;
break;
case T_eq:
eat_token(T_eq);
if (v == Expr(v)) v = 1;
else v = 0;
break;
case T_openparen:
v = RelP(Expr(v));
break;
default:
syntax_error(NT_Rel);
break;
}
parsetree.pop();
return v;
}
开发者ID:mcmhav,项目名称:transUCSB,代码行数:33,代码来源:calc.cpp
示例16: Statements
void parser_t::Statements()
{
parsetree.push(NT_Statements);
Statement();
Derivestate();
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:7,代码来源:calc.cpp
示例17: Expr
int parser_t::Expr(int v)
{
parsetree.push(NT_Expr);
switch (scanner.next_token())
{
case T_num:
v = ExprP(Term(v));
break;
case T_plus:
eat_token(T_plus);
v += Term(v);
v = ExprP(v);
break;
case T_minus:
eat_token(T_minus);
v -= Term(v);
v = ExprP(v);
break;
case T_openparen:
eat_token(T_openparen);
v = ExprP(v);
eat_token(T_closeparen);
break;
default:
syntax_error(NT_Expr);
break;
}
parsetree.pop();
return v;
}
开发者ID:mcmhav,项目名称:transUCSB,代码行数:30,代码来源:calc.cpp
示例18: Statement
void parser_t::Statement(){
parsetree.push(NT_Statement);
switch(scanner.next_token())
{
case T_eof:
parsetree.drawepsilon();
break;
case T_m:
cerr<<"m";
Assignment();
break;
case T_label:
cerr<<"L";
Label();
break;
case T_goto:
cerr<<"goto";
Jump();
break;
case T_print:
cerr<<"printf()";
Print();
break;
default:
syntax_error(NT_Statement);
break;
}
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:29,代码来源:calc.cpp
示例19: Start
//Here is an example
void parser_t::Start()
{
//push this non-terminal onto the parse tree.
//the parsetree class is just for drawing the finished
//parse tree, and should in should have no effect the actual
//parsing of the data
parsetree.push(NT_Start);
fprintf(stderr, "int main()\n");
fprintf(stderr, "{\n");
fprintf(stderr, "\tint m[101];\n");
fprintf(stderr, "\n");
switch( scanner.next_token() )
{
case T_label:
case T_goto:
case T_m:
case T_print:
Statements();
break;
case T_eof:
parsetree.drawepsilon();
break;
default:
syntax_error(NT_Start);
break;
}
//now that we are done with List, we can pop it from the data
//stucture that is tracking it for drawing the parse tree
parsetree.pop();
fprintf(stderr, "}\n");
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:36,代码来源:calc.cpp
示例20: Derivestate
void parser_t::Derivestate(){
parsetree.push(NT_Derivestate);
switch(scanner.next_token())
{
case T_label:
Statement();
Derivestate();
break;
case T_goto:
Statement();
Derivestate();
break;
case T_m:
Statement();
Derivestate();
break;
case T_print:
Statement();
Derivestate();
break;
case T_eof:
eat_token(scanner.next_token());
// parsetree.drawepsilon();
// cout<<"done"<<endl;
break;
default:
syntax_error(NT_Derivestate);
break;
}
parsetree.pop();
}
开发者ID:fenghuo,项目名称:AutoGrading,代码行数:33,代码来源:calc.cpp
注:本文中的parsetree_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论