aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build.l18
-rw-r--r--src/build.y74
2 files changed, 46 insertions, 46 deletions
diff --git a/src/build.l b/src/build.l
index 7b770f7..30c79a6 100644
--- a/src/build.l
+++ b/src/build.l
@@ -118,36 +118,36 @@ int iStrDepth = 0;
118 118
119"true" { 119"true" {
120 yylval->bVal = true; 120 yylval->bVal = true;
121 return BOOL; 121 return LTR_BOOL;
122} 122}
123"false" { 123"false" {
124 yylval->bVal = false; 124 yylval->bVal = false;
125 return BOOL; 125 return LTR_BOOL;
126} 126}
127 127
128[a-zA-Z_][a-zA-Z0-9_]*: { 128[a-zA-Z_][a-zA-Z0-9_]*: {
129 yytext[yyleng-1] = '\0'; 129 yytext[yyleng-1] = '\0';
130 yylval->sVal = rstrdup( yytext ); 130 yylval->sVal = rstrdup( yytext );
131 return PROFILE; 131 return LTR_PROFILE;
132} 132}
133 133
134[a-zA-Z_][a-zA-Z0-9_]* { 134[a-zA-Z_][a-zA-Z0-9_]* {
135 yylval->sVal = rstrdup( yytext ); 135 yylval->sVal = rstrdup( yytext );
136 if( b.isKeyword( yylval->sVal ) ) 136 if( b.isKeyword( yylval->sVal ) )
137 return KEYWORD; 137 return LTR_KEYWORD;
138 else if( b.isCond( yylval->sVal ) ) 138 else if( b.isCond( yylval->sVal ) )
139 return CONDITION; 139 return LTR_CONDITION;
140 return UNDEF; 140 return LTR_UNDEF;
141} 141}
142 142
143-?([1-9][0-9]*)|(0) { 143-?([1-9][0-9]*)|(0) {
144 yylval->iVal = strtol( yytext, NULL, 10 ); 144 yylval->iVal = strtol( yytext, NULL, 10 );
145 return INT; 145 return LTR_INT;
146} 146}
147 147
148(0\.0+)|(-?(([1-9][0-9]*)|(0))\.[0-9]*) { 148(0\.0+)|(-?(([1-9][0-9]*)|(0))\.[0-9]*) {
149 yylval->fVal = strtof( yytext, NULL ); 149 yylval->fVal = strtof( yytext, NULL );
150 return FLOAT; 150 return LTR_FLOAT;
151} 151}
152 152
153\" { 153\" {
@@ -198,7 +198,7 @@ int iStrDepth = 0;
198 { 198 {
199 BEGIN( INITIAL ); 199 BEGIN( INITIAL );
200 yylval->sVal = fstrdup( sBuf ); 200 yylval->sVal = fstrdup( sBuf );
201 return STRING; 201 return LTR_STRING;
202 } 202 }
203} 203}
204 204
diff --git a/src/build.y b/src/build.y
index 5a5e938..ae8a696 100644
--- a/src/build.y
+++ b/src/build.y
@@ -25,16 +25,16 @@ void yyerror( YYLTYPE *locp, yyscan_t yyscanner, BuildParser &bld, const char *m
25 bool bVal; 25 bool bVal;
26} 26}
27 27
28%token <sVal> STRING "string literal" 28%token <sVal> LTR_STRING "string literal"
29%token <sVal> KEYWORD "keyword" 29%token <sVal> LTR_KEYWORD "keyword"
30%token <sVal> CONDITION "condition term" 30%token <sVal> LTR_CONDITION "condition term"
31%token <sVal> VARIABLE "variable name" 31%token <sVal> LTR_VARIABLE "variable name"
32%token <sVal> FUNCTION "function name" 32%token <sVal> LTR_FUNCTION "function name"
33%token <sVal> UNDEF "undefined identifier" 33%token <sVal> LTR_UNDEF "undefined identifier"
34%token <sVal> PROFILE "profile execute" 34%token <sVal> LTR_PROFILE "profile execute"
35%token <iVal> INT "integer literal" 35%token <iVal> LTR_INT "integer literal"
36%token <fVal> FLOAT "floating point literal" 36%token <fVal> LTR_FLOAT "floating point literal"
37%token <bVal> BOOL "boolean literal" 37%token <bVal> LTR_BOOL "boolean literal"
38 38
39%token TOK_TARGET "target" 39%token TOK_TARGET "target"
40%token TOK_INPUT "input" 40%token TOK_INPUT "input"
@@ -96,13 +96,13 @@ void yyerror( YYLTYPE *locp, yyscan_t yyscanner, BuildParser &bld, const char *m
96%left '(' ')' '{' '}' '[' ']' 96%left '(' ')' '{' '}' '[' ']'
97%left IINEG IINOT 97%left IINEG IINOT
98 98
99%destructor { delete[] $$; } STRING 99%destructor { delete[] $$; } LTR_STRING
100%destructor { delete[] $$; } KEYWORD 100%destructor { delete[] $$; } LTR_KEYWORD
101%destructor { delete[] $$; } CONDITION 101%destructor { delete[] $$; } LTR_CONDITION
102%destructor { delete[] $$; } VARIABLE 102%destructor { delete[] $$; } LTR_VARIABLE
103%destructor { delete[] $$; } FUNCTION 103%destructor { delete[] $$; } LTR_FUNCTION
104%destructor { delete[] $$; } UNDEF 104%destructor { delete[] $$; } LTR_UNDEF
105%destructor { delete[] $$; } PROFILE 105%destructor { delete[] $$; } LTR_PROFILE
106 106
107%% /* Grammar rules */ 107%% /* Grammar rules */
108 108
@@ -140,23 +140,23 @@ root_sub_exprs:
140 | root export 140 | root export
141 ; 141 ;
142 142
143include: TOK_INCLUDE STRING ';' { bld.include( $2, yyscanner, &yylloc ); } 143include: TOK_INCLUDE LTR_STRING ';' { bld.include( $2, yyscanner, &yylloc ); }
144 ; 144 ;
145 145
146/* 146/*
147 * data related 147 * data related
148 */ 148 */
149 149
150string: STRING { bld.xAst.addNode( @1, AstNode::typeString, $1 ); } 150string: LTR_STRING { bld.xAst.addNode( @1, AstNode::typeString, $1 ); }
151 ; 151 ;
152 152
153int: INT { bld.xAst.addNode( @1, AstNode::typeInt, $1 ); } 153int: LTR_INT { bld.xAst.addNode( @1, AstNode::typeInt, $1 ); }
154 ; 154 ;
155 155
156float: FLOAT { bld.xAst.addNode( @1, AstNode::typeFloat, $1 ); } 156float: LTR_FLOAT { bld.xAst.addNode( @1, AstNode::typeFloat, $1 ); }
157 ; 157 ;
158 158
159bool: BOOL { bld.xAst.addNode( @1, AstNode::typeBool, (bool)$1 ); } 159bool: LTR_BOOL { bld.xAst.addNode( @1, AstNode::typeBool, (bool)$1 ); }
160 ; 160 ;
161 161
162null: TOK_NULL { bld.xAst.addNode( @1, AstNode::typeNull ); } 162null: TOK_NULL { bld.xAst.addNode( @1, AstNode::typeNull ); }
@@ -168,7 +168,7 @@ literal: string
168 | null 168 | null
169 ; 169 ;
170 170
171variable: UNDEF { bld.xAst.addNode( @1, AstNode::typeVariable, $1 ); } 171variable: LTR_UNDEF { bld.xAst.addNode( @1, AstNode::typeVariable, $1 ); }
172 172
173list_core: 173list_core:
174 | { bld.xAst.openBranch(); } expr 174 | { bld.xAst.openBranch(); } expr
@@ -199,9 +199,9 @@ value: value_core value_mods
199 * misc global things 199 * misc global things
200 */ 200 */
201 201
202notify: TOK_ERROR STRING ';' { bld.xAst.addNode( @$,AstNode::typeError, $2 ); } 202notify: TOK_ERROR LTR_STRING ';' { bld.xAst.addNode( @$,AstNode::typeError, $2 ); }
203 | TOK_WARNING STRING ';' { bld.xAst.addNode( @$, AstNode::typeWarning, $2 ); } 203 | TOK_WARNING LTR_STRING ';' { bld.xAst.addNode( @$, AstNode::typeWarning, $2 ); }
204 | TOK_NOTICE STRING ';' { bld.xAst.addNode( @$, AstNode::typeNotice, $2 ); } 204 | TOK_NOTICE LTR_STRING ';' { bld.xAst.addNode( @$, AstNode::typeNotice, $2 ); }
205 ; 205 ;
206/* 206/*
207set_rhs: '=' { bld.xAst.addNode( AstNode::typeOpEq ); } value 207set_rhs: '=' { bld.xAst.addNode( AstNode::typeOpEq ); } value
@@ -245,7 +245,7 @@ func_param_list: { bld.xAst.openBranch(); } expr
245 | func_param_list ',' { bld.xAst.openBranch(); } expr 245 | func_param_list ',' { bld.xAst.openBranch(); } expr
246 ; 246 ;
247 247
248function: UNDEF '(' { 248function: LTR_UNDEF '(' {
249 bld.xAst.addNode( @$, AstNode::typeFunction ); 249 bld.xAst.addNode( @$, AstNode::typeFunction );
250 bld.xAst.openBranch(); 250 bld.xAst.openBranch();
251 bld.xAst.addNode( @$, AstNode::typeString, $1 ); 251 bld.xAst.addNode( @$, AstNode::typeString, $1 );
@@ -254,7 +254,7 @@ function: UNDEF '(' {
254 } 254 }
255 ; 255 ;
256 256
257function_no_input: UNDEF '(' { 257function_no_input: LTR_UNDEF '(' {
258 bld.xAst.addNode( @$, AstNode::typeNull ); 258 bld.xAst.addNode( @$, AstNode::typeNull );
259 bld.xAst.addNode( @$, AstNode::typeFunction ); 259 bld.xAst.addNode( @$, AstNode::typeFunction );
260 bld.xAst.openBranch(); 260 bld.xAst.openBranch();
@@ -285,17 +285,17 @@ type: TOK_STRING { bld.xAst.addNode( @1, AstNode::typeTypeString ); }
285 285
286expr: value 286expr: value
287 | '(' expr ')' 287 | '(' expr ')'
288 | UNDEF '=' { 288 | LTR_UNDEF '=' {
289 bld.xAst.addNode( @$, AstNode::typeVariableRef, $1 ); 289 bld.xAst.addNode( @$, AstNode::typeVariableRef, $1 );
290 } expr { 290 } expr {
291 bld.xAst.addNode( @3, AstNode::typeOpEq ); 291 bld.xAst.addNode( @3, AstNode::typeOpEq );
292 } 292 }
293 | UNDEF OP_ADDSETP { 293 | LTR_UNDEF OP_ADDSETP {
294 bld.xAst.addNode( @$, AstNode::typeVariableRef, $1 ); 294 bld.xAst.addNode( @$, AstNode::typeVariableRef, $1 );
295 } expr { 295 } expr {
296 bld.xAst.addNode( @3, AstNode::typeOpPlusEq ); 296 bld.xAst.addNode( @3, AstNode::typeOpPlusEq );
297 } 297 }
298 | UNDEF OP_ADDSETR { 298 | LTR_UNDEF OP_ADDSETR {
299 bld.xAst.addNode( @$, AstNode::typeVariableRef, $1 ); 299 bld.xAst.addNode( @$, AstNode::typeVariableRef, $1 );
300 } expr { 300 } expr {
301 bld.xAst.addNode( @3, AstNode::typeOpPlusEqRaw ); 301 bld.xAst.addNode( @3, AstNode::typeOpPlusEqRaw );
@@ -436,7 +436,7 @@ function_for: for_base '{' function_exprs '}' { bld.xAst.closeNode(); }
436 * functions 436 * functions
437 */ 437 */
438 438
439function_def: TOK_FUNCTION UNDEF { 439function_def: TOK_FUNCTION LTR_UNDEF {
440 bld.xAst.addNode( @1, AstNode::typeFunctionDef ); 440 bld.xAst.addNode( @1, AstNode::typeFunctionDef );
441 bld.xAst.openBranch(); 441 bld.xAst.openBranch();
442 bld.xAst.addNode( @2, AstNode::typeString, $2 ); 442 bld.xAst.addNode( @2, AstNode::typeString, $2 );
@@ -481,7 +481,7 @@ return: TOK_RETURN {
481 * Actions, they're basically functions, no parameters 481 * Actions, they're basically functions, no parameters
482 */ 482 */
483 483
484action_def: TOK_ACTION STRING { 484action_def: TOK_ACTION LTR_STRING {
485 bld.xAst.addNode( @$, AstNode::typeActionDef ); 485 bld.xAst.addNode( @$, AstNode::typeActionDef );
486 bld.xAst.openBranch(); 486 bld.xAst.openBranch();
487 bld.xAst.addNode( @1, AstNode::typeString, $2 ); 487 bld.xAst.addNode( @1, AstNode::typeString, $2 );
@@ -564,7 +564,7 @@ target_rule: TOK_RULE {
564 } 564 }
565 ; 565 ;
566 566
567condition: TOK_CONDITION CONDITION ';' { 567condition: TOK_CONDITION LTR_CONDITION ';' {
568 bld.xAst.addNode( @$, AstNode::typeCondition, $2 ); 568 bld.xAst.addNode( @$, AstNode::typeCondition, $2 );
569 } 569 }
570 | TOK_CONDITION TOK_ALWAYS ';'{ 570 | TOK_CONDITION TOK_ALWAYS ';'{
@@ -603,7 +603,7 @@ rule_exprs:
603 ; 603 ;
604 604
605rule_input_func: function 605rule_input_func: function
606 | STRING { 606 | LTR_STRING {
607 /* In this case, when the input is just a string, 607 /* In this case, when the input is just a string,
608 lets actually turn it into a call to the matches function. 608 lets actually turn it into a call to the matches function.
609 */ 609 */
@@ -671,7 +671,7 @@ config_exprs:
671 | config_exprs cache 671 | config_exprs cache
672 ; 672 ;
673 673
674display: TOK_DISPLAY STRING ';' { 674display: TOK_DISPLAY LTR_STRING ';' {
675 bld.xAst.addNode( @$, AstNode::typeDisplay, $2 ); 675 bld.xAst.addNode( @$, AstNode::typeDisplay, $2 );
676 } 676 }
677 ; 677 ;
@@ -720,7 +720,7 @@ cache: TOK_CACHE TOK_ALWAYS ';'
720/* 720/*
721 * target/profile execute 721 * target/profile execute
722 */ 722 */
723process_target: PROFILE 723process_target: LTR_PROFILE
724 { 724 {
725 bld.xAst.addNode( @$, AstNode::typeProcessTarget ); 725 bld.xAst.addNode( @$, AstNode::typeProcessTarget );
726 bld.xAst.openBranch(); 726 bld.xAst.openBranch();