Warning, /frameworks/kservice/src/services/yacc.y is written in an unsupported language. File is not indexed.
0001 %{ 0002 #include <stdlib.h> 0003 #include <stdio.h> 0004 #include "ktraderparse_p.h" 0005 #include "yacc.h" 0006 0007 #define YYLTYPE_IS_TRIVIAL 0 0008 #define YYENABLE_NLS 0 0009 void yyerror(yyscan_t scanner, const char *s); 0010 int kiotraderlex(YYSTYPE * yylval, yyscan_t scanner); 0011 int kiotraderlex_init (yyscan_t* scanner); 0012 int kiotraderlex_destroy(yyscan_t scanner); 0013 0014 void KTraderParse_initFlex( const char *s, yyscan_t _scanner ); 0015 0016 %} 0017 0018 %code requires{ 0019 #ifndef YY_TYPEDEF_YY_SCANNER_T 0020 #define YY_TYPEDEF_YY_SCANNER_T 0021 typedef void *yyscan_t; 0022 #endif 0023 } 0024 0025 %union 0026 { 0027 char valb; 0028 int vali; 0029 double vald; 0030 char *name; 0031 void *ptr; 0032 } 0033 0034 %token NOT 0035 %token EQ 0036 %token EQI 0037 %token NEQ 0038 %token NEQI 0039 %token LEQ 0040 %token GEQ 0041 %token LE 0042 %token GR 0043 %token OR 0044 %token AND 0045 %token TOKEN_IN 0046 %token TOKEN_IN_SUBSTRING 0047 %token MATCH_INSENSITIVE 0048 %token MATCH_SUBSEQUENCE 0049 %token MATCH_SUBSEQUENCE_INSENSITIVE 0050 %token TOKEN_IN_INSENSITIVE 0051 %token TOKEN_IN_SUBSTRING_INSENSITIVE 0052 %token EXIST 0053 %token MAX 0054 %token MIN 0055 0056 %token <valb> VAL_BOOL 0057 %token <name> VAL_STRING 0058 %token <name> VAL_ID 0059 %token <vali> VAL_NUM 0060 %token <vald> VAL_FLOAT 0061 0062 %type <ptr> bool 0063 %type <ptr> bool_or 0064 %type <ptr> bool_and 0065 %type <ptr> bool_compare 0066 %type <ptr> expr_in 0067 %type <ptr> expr_twiddle 0068 %type <ptr> expr 0069 %type <ptr> term 0070 %type <ptr> factor_non 0071 %type <ptr> factor 0072 0073 %destructor { KTraderParse_destroy( $$ ); } bool_or 0074 %destructor { KTraderParse_destroy( $$ ); } bool_and 0075 %destructor { KTraderParse_destroy( $$ ); } bool_compare 0076 %destructor { KTraderParse_destroy( $$ ); } expr_in 0077 %destructor { KTraderParse_destroy( $$ ); } expr_twiddle 0078 %destructor { KTraderParse_destroy( $$ ); } expr 0079 %destructor { KTraderParse_destroy( $$ ); } term 0080 %destructor { KTraderParse_destroy( $$ ); } factor_non 0081 %destructor { KTraderParse_destroy( $$ ); } factor 0082 0083 %define api.pure 0084 0085 %lex-param { yyscan_t scanner } 0086 %parse-param { yyscan_t scanner } 0087 0088 /* Grammar follows */ 0089 0090 %% 0091 0092 constraint: /* empty */ { KTraderParse_setParseTree( 0L ); } 0093 | bool { KTraderParse_setParseTree( $<ptr>1 ); } 0094 ; 0095 0096 bool: bool_or { $$ = $<ptr>1; } 0097 ; 0098 0099 bool_or: bool_and OR bool_or { $$ = KTraderParse_newOR( $<ptr>1, $<ptr>3 ); } 0100 | bool_and { $$ = $<ptr>1; } 0101 ; 0102 0103 bool_and: bool_compare AND bool_and { $$ = KTraderParse_newAND( $<ptr>1, $<ptr>3 ); } 0104 | bool_compare { $$ = $<ptr>1; } 0105 ; 0106 0107 bool_compare: expr_in EQ expr_in { $$ = KTraderParse_newCMP( $<ptr>1, $<ptr>3, 1 ); } 0108 | expr_in EQI expr_in { $$ = KTraderParse_newCMP( $<ptr>1, $<ptr>3, 7 ); } 0109 | expr_in NEQ expr_in { $$ = KTraderParse_newCMP( $<ptr>1, $<ptr>3, 2 ); } 0110 | expr_in NEQI expr_in { $$ = KTraderParse_newCMP( $<ptr>1, $<ptr>3, 8 ); } 0111 | expr_in GEQ expr_in { $$ = KTraderParse_newCMP( $<ptr>1, $<ptr>3, 3 ); } 0112 | expr_in LEQ expr_in { $$ = KTraderParse_newCMP( $<ptr>1, $<ptr>3, 4 ); } 0113 | expr_in LE expr_in { $$ = KTraderParse_newCMP( $<ptr>1, $<ptr>3, 5 ); } 0114 | expr_in GR expr_in { $$ = KTraderParse_newCMP( $<ptr>1, $<ptr>3, 6 ); } 0115 | expr_in { $$ = $<ptr>1; } 0116 ; 0117 0118 expr_in: expr_twiddle TOKEN_IN VAL_ID { $$ = KTraderParse_newIN( $<ptr>1, KTraderParse_newID( $<name>3 ), 1 ); } 0119 | expr_twiddle TOKEN_IN_INSENSITIVE VAL_ID { $$ = KTraderParse_newIN( $<ptr>1, KTraderParse_newID( $<name>3 ), 0 ); } 0120 | expr_twiddle TOKEN_IN_SUBSTRING VAL_ID { $$ = KTraderParse_newSubstringIN( $<ptr>1, KTraderParse_newID( $<name>3 ), 1 ); } 0121 | expr_twiddle TOKEN_IN_SUBSTRING_INSENSITIVE VAL_ID { $$ = KTraderParse_newSubstringIN( $<ptr>1, KTraderParse_newID( $<name>3 ), 0 ); } 0122 | expr_twiddle { $$ = $<ptr>1; } 0123 ; 0124 0125 expr_twiddle: expr '~' expr { $$ = KTraderParse_newMATCH( $<ptr>1, $<ptr>3, 1 ); } 0126 | expr_twiddle MATCH_INSENSITIVE expr { $$ = KTraderParse_newMATCH( $<ptr>1, $<ptr>3, 0 ); } 0127 | expr_twiddle MATCH_SUBSEQUENCE expr { $$ = KTraderParse_newSubsequenceMATCH( $<ptr>1, $<ptr>3, 1 ); } 0128 | expr_twiddle MATCH_SUBSEQUENCE_INSENSITIVE expr { $$ = KTraderParse_newSubsequenceMATCH( $<ptr>1, $<ptr>3, 0 ); } 0129 | expr { $$ = $<ptr>1; } 0130 ; 0131 0132 expr: expr '+' term { $$ = KTraderParse_newCALC( $<ptr>1, $<ptr>3, 1 ); } 0133 | expr '-' term { $$ = KTraderParse_newCALC( $<ptr>1, $<ptr>3, 2 ); } 0134 | term { $$ = $<ptr>1; } 0135 ; 0136 0137 term: term '*' factor_non { $$ = KTraderParse_newCALC( $<ptr>1, $<ptr>3, 3 ); } 0138 | term '/' factor_non { $$ = KTraderParse_newCALC( $<ptr>1, $<ptr>3, 4 ); } 0139 | factor_non { $$ = $<ptr>1; } 0140 ; 0141 0142 factor_non: NOT factor { $$ = KTraderParse_newNOT( $<ptr>2 ); } 0143 | factor { $$ = $<ptr>1; } 0144 ; 0145 0146 factor: '(' bool_or ')' { $$ = KTraderParse_newBRACKETS( $<ptr>2 ); } 0147 | EXIST VAL_ID { $$ = KTraderParse_newEXIST( $<name>2 ); } 0148 | VAL_ID { $$ = KTraderParse_newID( $<name>1 ); } 0149 | VAL_NUM { $$ = KTraderParse_newNUM( $<vali>1 ); } 0150 | VAL_FLOAT { $$ = KTraderParse_newFLOAT( $<vald>1 ); } 0151 | VAL_STRING { $$ = KTraderParse_newSTRING( $<name>1 ); } 0152 | VAL_BOOL { $$ = KTraderParse_newBOOL( $<valb>1 ); } 0153 | MAX VAL_ID { $$ = KTraderParse_newMAX2( $<name>2 ); } 0154 | MIN VAL_ID { $$ = KTraderParse_newMIN2( $<name>2 ); } 0155 ; 0156 0157 /* End of grammar */ 0158 0159 %% 0160 0161 void yyerror ( yyscan_t scanner, const char *s ) /* Called by yyparse on error */ 0162 { 0163 (void) scanner; 0164 KTraderParse_error( s ); 0165 } 0166 0167 void KTraderParse_mainParse( const char *_code ) 0168 { 0169 yyscan_t scanner; 0170 kiotraderlex_init(&scanner); 0171 KTraderParse_initFlex(_code, scanner); 0172 kiotraderparse(scanner); 0173 kiotraderlex_destroy(scanner); 0174 }