Warning, /graphics/kst-plot/src/libkstmath/escan.l is written in an unsupported language. File is not indexed.
0001 %option noyywrap 0002 %x DATA 0003 %{ 0004 #include <stdlib.h> 0005 #include <stdio.h> 0006 #include <string.h> 0007 #include "eparse.h" 0008 #include "eparse-eh.h" 0009 0010 int bracketCount = 0; 0011 char dataSpec[1024]; 0012 char *dataSpecPtr; 0013 //void yyerror(Kst::ObjectStore *store, const char *s); 0014 #define YY_DECL int yylex(Kst::ObjectStore *store) 0015 0016 %} 0017 0018 Number (0|[1-9][0-9]*)([\.][0-9]+)?([eE][\+\-]?[0-9]+)? 0019 Id [A-Za-z]+ 0020 0021 %% 0022 0023 {Number} { 0024 yylval.number = atof(yytext); 0025 /*printf("Found a number %.15f\n", yylval.number);*/ 0026 return T_NUMBER; 0027 } 0028 0029 0030 {Id} { 0031 yylval.data = strdup(yytext); 0032 /*printf("Found an ID [%s]\n", yylval.data);*/ 0033 return T_IDENTIFIER; 0034 } 0035 0036 <DATA>. { 0037 switch (*yytext) { 0038 case '[': 0039 ++bracketCount; 0040 *dataSpecPtr = *yytext; 0041 ++dataSpecPtr; 0042 break; 0043 case ']': 0044 if (--bracketCount == 0) { 0045 *dataSpecPtr = 0; 0046 yylval.data = strdup(dataSpec); 0047 if (dataSpecPtr == dataSpec) { 0048 yyerror(store, "Empty data reference."); 0049 yy_flush_buffer(YY_CURRENT_BUFFER); 0050 BEGIN(INITIAL); 0051 return T_INVALID; 0052 } 0053 BEGIN(INITIAL); 0054 return T_DATA; 0055 } 0056 *dataSpecPtr = *yytext; 0057 ++dataSpecPtr; 0058 break; 0059 default: 0060 *dataSpecPtr = *yytext; 0061 ++dataSpecPtr; 0062 break; 0063 } 0064 } 0065 0066 <DATA><<EOF>> { 0067 yyerror(store, "Invalid data reference."); 0068 yy_flush_buffer(YY_CURRENT_BUFFER); 0069 BEGIN(INITIAL); 0070 return T_INVALID; 0071 } 0072 0073 "[" { 0074 bracketCount = 1; 0075 dataSpecPtr = dataSpec; 0076 *dataSpecPtr = 0; 0077 BEGIN(DATA); 0078 } 0079 0080 "]" { 0081 yyerror(store, "Unmatched ']'."); 0082 yy_flush_buffer(YY_CURRENT_BUFFER); 0083 return T_INVALID; 0084 } 0085 0086 "!" return T_NOT; 0087 0088 "&" return T_AND; 0089 0090 "|" return T_OR; 0091 0092 "&&" return T_LAND; 0093 0094 "||" return T_LOR; 0095 0096 "<" return T_LT; 0097 0098 "<=" return T_LE; 0099 0100 ">" return T_GT; 0101 0102 ">=" return T_GE; 0103 0104 "=" return T_EQ; 0105 0106 "==" return T_EQ; 0107 0108 "!=" return T_NE; 0109 0110 "+" return T_ADD; 0111 0112 "-" return T_SUBTRACT; 0113 0114 "*" return T_MULTIPLY; 0115 0116 "/" return T_DIVIDE; 0117 0118 "%" return T_MOD; 0119 0120 "^" return T_EXP; 0121 0122 "(" return T_OPENPAR; 0123 0124 ")" return T_CLOSEPAR; 0125 0126 "," return T_COMMA; 0127 0128 [ \t] {} 0129 0130 . { 0131 /*printf("Found char '%c'\n", yytext[0]);*/ 0132 yylval.character = yytext[0]; 0133 return T_INVALID; 0134 } 0135 0136 0137 <<EOF>> { 0138 /*printf("yyterminate\n");*/ 0139 yyterminate(); 0140 } 0141 0142 %% 0143