Warning, /frameworks/kuserfeedback/src/common/surveytargetexpressionparser.y is written in an unsupported language. File is not indexed.

0001 %{
0002 /*
0003     SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
0004 
0005     SPDX-License-Identifier: MIT
0006 */
0007 
0008 #include "surveytargetexpression.h"
0009 #include "surveytargetexpressionparser_p.h"
0010 #include "surveytargetexpressionscanner.h"
0011 
0012 #include <stdio.h>
0013 
0014 using namespace KUserFeedback;
0015 
0016 void yyerror(KUserFeedback::SurveyTargetExpression **expression, yyscan_t scanner, char const* msg)
0017 {
0018     Q_UNUSED(expression);
0019     Q_UNUSED(scanner);
0020     printf("PARSER ERROR: %s\n", msg);
0021 }
0022 
0023 %}
0024 
0025 %code requires {
0026 
0027 #ifndef YY_TYPEDEF_YY_SCANNER_T
0028 #define YY_TYPEDEF_YY_SCANNER_T
0029 typedef void* yyscan_t;
0030 #endif
0031 
0032 }
0033 
0034 %define api.pure
0035 %lex-param { yyscan_t scanner }
0036 %parse-param { KUserFeedback::SurveyTargetExpression **expression }
0037 %parse-param { yyscan_t scanner }
0038 
0039 %union {
0040     int intVal;
0041     double doubleVal;
0042     bool boolVal;
0043     char *str;
0044     KUserFeedback::SurveyTargetExpression *expression;
0045 }
0046 
0047 %left T_OP_OR
0048 %left T_OP_AND
0049 
0050 %token T_OP_EQ
0051 %token T_OP_NEQ
0052 %token T_OP_GT
0053 %token T_OP_GE
0054 %token T_OP_LT
0055 %token T_OP_LE
0056 
0057 %token T_DOT
0058 %token T_LPAREN
0059 %token T_RPAREN
0060 %token T_LBRACKET
0061 %token T_RBRACKET
0062 
0063 %token <doubleVal> T_DOUBLE
0064 %token <intVal> T_INTEGER
0065 %token <boolVal> T_BOOLEAN
0066 %token <str> T_STRING
0067 %token <str> T_IDENTIFIER
0068 
0069 %type <expression> Expr
0070 %type <expression> Term
0071 %type <expression> Value
0072 
0073 %destructor { free($$); } <str>
0074 %destructor { delete $$; } <expression>
0075 
0076 
0077 %%
0078 
0079 Input: Expr { *expression = $1; }
0080     ;
0081 
0082 Expr: Term { printf("TERM "); $$ = $1; }
0083     | T_LPAREN Expr[E] T_RPAREN { $$ = $E; }
0084     | Expr[L] T_OP_AND Expr[R] %prec T_OP_AND { $$ = new SurveyTargetExpression(SurveyTargetExpression::OpLogicAnd, $L, $R); }
0085     | Expr[L] T_OP_OR Expr[R]  %prec T_OP_OR  { $$ = new SurveyTargetExpression(SurveyTargetExpression::OpLogicOr, $L, $R); }
0086 ;
0087 
0088 Term: Value[L] T_OP_EQ Value[R] { $$ = new SurveyTargetExpression(SurveyTargetExpression::OpEqual, $L, $R); }
0089     | Value[L] T_OP_NEQ Value[R] { $$ = new SurveyTargetExpression(SurveyTargetExpression::OpNotEqual, $L, $R); }
0090     | Value[L] T_OP_GT Value[R] { $$ = new SurveyTargetExpression(SurveyTargetExpression::OpGreater, $L, $R); }
0091     | Value[L] T_OP_GE Value[R] { $$ = new SurveyTargetExpression(SurveyTargetExpression::OpGreaterEqual, $L, $R); }
0092     | Value[L] T_OP_LT Value[R] { $$ = new SurveyTargetExpression(SurveyTargetExpression::OpLess, $L, $R); }
0093     | Value[L] T_OP_LE Value[R] { $$ = new SurveyTargetExpression(SurveyTargetExpression::OpLessEqual, $L, $R); }
0094 ;
0095 
0096 Value: T_IDENTIFIER[S] T_DOT T_IDENTIFIER[E] {
0097         $$ = new SurveyTargetExpression(QString::fromUtf8($S), QVariant(), QString::fromUtf8($E));
0098         free($S);
0099         free($E);
0100     }
0101     | T_IDENTIFIER[S] T_LBRACKET T_INTEGER[I] T_RBRACKET T_DOT T_IDENTIFIER[E] {
0102         $$ = new SurveyTargetExpression(QString::fromUtf8($S), $I, QString::fromUtf8($E));
0103         free($S);
0104         free($E);
0105     }
0106     | T_IDENTIFIER[S] T_LBRACKET T_STRING[K] T_RBRACKET T_DOT T_IDENTIFIER[E] {
0107         $$ = new SurveyTargetExpression(QString::fromUtf8($S), QString::fromUtf8($K), QString::fromUtf8($E));
0108         free($S);
0109         free($K);
0110         free($E);
0111     }
0112     | T_DOUBLE { $$ = new SurveyTargetExpression($1); }
0113     | T_INTEGER { $$ = new SurveyTargetExpression($1); }
0114     | T_BOOLEAN { $$ = new SurveyTargetExpression($1); }
0115     | T_STRING { $$ = new SurveyTargetExpression(QString::fromUtf8($1)); free($1); }
0116 ;
0117 
0118 %%