static int CPPline(yystypepp * yylvalpp) { int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if(token=='\n'){ DecLineNumber(); CPPErrorToInfoLog("#line"); IncLineNumber(); return token; } else if (token == CPP_INTCONSTANT) { yylvalpp->sc_int=atoi(yylvalpp->symbol_name); SetLineNumber(yylvalpp->sc_int); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if (token == CPP_INTCONSTANT) { yylvalpp->sc_int=atoi(yylvalpp->symbol_name); SetStringNumber(yylvalpp->sc_int); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if(token!='\n') CPPErrorToInfoLog("#line"); } else if (token == '\n'){ return token; } else{ CPPErrorToInfoLog("#line"); } } else{ CPPErrorToInfoLog("#line"); } return token; }
static int CPPline(yystypepp * yylvalpp) { int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if(token=='\n'){ DecLineNumber(); CPPErrorToInfoLog("#line"); IncLineNumber(); return token; } else if (token == CPP_INTCONSTANT) { yylvalpp->sc_int=atoi(yylvalpp->symbol_name); SetLineNumber(yylvalpp->sc_int); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); // Modified for HLSL, which allows #line X "str", whereas GLSL is #line X Y if (token == CPP_STRCONSTANT) { token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); if(token!='\n') CPPErrorToInfoLog("#line"); } else if (token == '\n'){ return token; } else{ CPPErrorToInfoLog("#line"); } } else{ CPPErrorToInfoLog("#line"); } return token; }
/* * str_getch() * takes care of reading from multiple strings. * returns the next-char from the input stream. * returns EOF when the complete shader is parsed. */ static int str_getch(StringInputSrc *in) { for(;;){ if (*in->p){ if (*in->p == '\n') { in->base.line++; IncLineNumber(); } return *in->p++; } if(++(cpp->PaWhichStr) < cpp->PaArgc){ free(in); SetStringNumber(cpp->PaWhichStr); SetLineNumber(1); ScanFromString(cpp->PaArgv[cpp->PaWhichStr]); in=(StringInputSrc*)cpp->currentInput; continue; } else{ cpp->currentInput = in->base.prev; cpp->PaWhichStr=0; free(in); return EOF; } } } // str_getch
static int lex(InputSrc* in, yystypepp* yylvalpp) { InputSrcLexer* src = ((InputSrcLexer *)in); pp::Token token; int ret = src->lexer->lex(&token); switch (ret) { case 0: // EOF delete src->lexer; free(src); cpp->currentInput = 0; ret = EOF; break; case pp::Token::IDENTIFIER: if (CopySymbolName(token.value, yylvalpp)) { yylvalpp->sc_ident = LookUpAddString(atable, token.value.c_str()); } ret = CPP_IDENTIFIER; break; case pp::Token::CONST_INT: if (CopySymbolName(token.value, yylvalpp)) { yylvalpp->sc_int = atoi(token.value.c_str()); } ret = CPP_INTCONSTANT; break; case pp::Token::CONST_FLOAT: CopySymbolName(token.value, yylvalpp); ret = CPP_FLOATCONSTANT; break; case pp::Token::OP_INC: ret = CPP_INC_OP; break; case pp::Token::OP_DEC: ret = CPP_DEC_OP; break; case pp::Token::OP_RIGHT: ret = CPP_RIGHT_OP; break; case pp::Token::OP_LE: ret = CPP_LE_OP; break; case pp::Token::OP_GE: ret = CPP_GE_OP; break; case pp::Token::OP_EQ: ret = CPP_EQ_OP; break; case pp::Token::OP_NE: ret = CPP_NE_OP; break; case pp::Token::OP_AND: ret = CPP_AND_OP; break; case pp::Token::OP_XOR: ret = CPP_XOR_OP; break; case pp::Token::OP_OR: ret = CPP_OR_OP; break; case pp::Token::OP_ADD_ASSIGN: ret = CPP_ADD_ASSIGN; break; case pp::Token::OP_SUB_ASSIGN: ret = CPP_SUB_ASSIGN; break; case pp::Token::OP_MUL_ASSIGN: ret = CPP_MUL_ASSIGN; break; case pp::Token::OP_DIV_ASSIGN: ret = CPP_DIV_ASSIGN; break; case pp::Token::OP_MOD_ASSIGN: ret = CPP_MOD_ASSIGN; break; case pp::Token::OP_LEFT_ASSIGN: ret = CPP_LEFT_ASSIGN; break; case pp::Token::OP_RIGHT_ASSIGN: ret = CPP_RIGHT_ASSIGN; break; case pp::Token::OP_AND_ASSIGN: ret = CPP_AND_ASSIGN; break; case pp::Token::OP_XOR_ASSIGN: ret = CPP_XOR_ASSIGN; break; case pp::Token::OP_OR_ASSIGN: ret = CPP_OR_ASSIGN; break; default: break; } SetLineNumber(token.location.line); SetStringNumber(token.location.string); return ret; }