added VARREF in lexer matching $[a-zA-Z_][a-zA-Z_0-9]*, added VarRefNode class
git-svn-id: svn://anubis/fart/branches/scene-file-scripting@325 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
35d6e536ae
commit
442a7bdeda
@ -168,10 +168,7 @@ class IdentifierNode : public Node
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IdentifierNode(const std::string & str) { m_string = str; }
|
IdentifierNode(const std::string & str) { m_string = str; }
|
||||||
std::string getString()
|
std::string getString() { return m_string; }
|
||||||
{
|
|
||||||
return m_string;
|
|
||||||
}
|
|
||||||
protected:
|
protected:
|
||||||
std::string m_string;
|
std::string m_string;
|
||||||
};
|
};
|
||||||
@ -442,5 +439,14 @@ class BinOpNode : public ExpressionNode
|
|||||||
refptr<Node> two;
|
refptr<Node> two;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VarRefNode : public Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VarRefNode(const std::string & str) { m_string = str; }
|
||||||
|
std::string getString() { return m_string; }
|
||||||
|
protected:
|
||||||
|
std::string m_string;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -85,6 +85,10 @@ width return WIDTH;
|
|||||||
*yylval = new IdentifierNode(yytext);
|
*yylval = new IdentifierNode(yytext);
|
||||||
return IDENTIFIER;
|
return IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
\$[a-zA-Z_][a-zA-Z_0-9]* {
|
||||||
|
*yylval = new VarRefNode(yytext+1);
|
||||||
|
return VARREF;
|
||||||
|
}
|
||||||
|
|
||||||
#.*\n yylloc->first_line++; yylloc->last_line++;
|
#.*\n yylloc->first_line++; yylloc->last_line++;
|
||||||
\n yylloc->first_line++; yylloc->last_line++;
|
\n yylloc->first_line++; yylloc->last_line++;
|
||||||
|
@ -101,6 +101,7 @@ static refptr<Node> parsed_scene_node;
|
|||||||
%token WIDTH;
|
%token WIDTH;
|
||||||
|
|
||||||
%token IDENTIFIER;
|
%token IDENTIFIER;
|
||||||
|
%token VARREF;
|
||||||
|
|
||||||
%left PLUS MINUS
|
%left PLUS MINUS
|
||||||
%left TIMES DIVIDE
|
%left TIMES DIVIDE
|
||||||
@ -583,6 +584,7 @@ term: factor { $$ = $1; }
|
|||||||
;
|
;
|
||||||
|
|
||||||
factor: number { $$ = $1; }
|
factor: number { $$ = $1; }
|
||||||
|
| VARREF { $$ = $1; }
|
||||||
| LPAREN expression RPAREN { $$ = $2; }
|
| LPAREN expression RPAREN { $$ = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user