summaryrefslogtreecommitdiff
path: root/src/intersim2/config.l
diff options
context:
space:
mode:
authorDongdong Li <[email protected]>2013-08-08 00:15:58 -0800
committerAndrew Boktor <[email protected]>2014-08-14 13:50:58 -0700
commit7f49fe9feb174d34efc2a011bad79b38522a360b (patch)
treeab5b7b66e40315a81871acbf386722981020f866 /src/intersim2/config.l
parent5f91e7435742bab74dfbeca18afc63e466498f36 (diff)
Intesim2 Integration
Details: See Review 80001 https://gpgpu-sim-code-review.appspot.com/80001/ [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 16747]
Diffstat (limited to 'src/intersim2/config.l')
-rw-r--r--src/intersim2/config.l54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/intersim2/config.l b/src/intersim2/config.l
new file mode 100644
index 0000000..4df14c7
--- /dev/null
+++ b/src/intersim2/config.l
@@ -0,0 +1,54 @@
+%{
+
+#include "y.tab.h"
+
+static unsigned int lineno = 1;
+
+void config_error(char * msg, int lineno);
+void yyerror(char * msg);
+
+extern int config_input(char *, int);
+#undef YY_INPUT
+#define YY_INPUT(b, r, ms) (r = config_input(b, ms))
+
+%}
+
+Digit [0-9]
+Exponent [eE][+-]?{Digit}+
+DblConst ({Digit}*\.)?{Digit}+{Exponent}?
+StrConst [A-Za-z_\-/\.][A-Za-z0-9_\-/\.\+(\{\,)\}]*
+
+%%
+
+ /* Ignore comments and all spaces */
+
+\/\/[^\n]* ;
+[ \t\r]* ;
+
+\n { lineno++; }
+
+ /* Commands */
+
+\{[A-Za-z0-9_\-\.(\{\,)\}]+(\,[A-Za-z0-9_\-\.(\{\,)\}]+)*\} { yylval.name = strdup( yytext ); return STR; }
+
+-?[0-9]+ { yylval.num = atoi( yytext ); return NUM; }
+
+-?[0-9]*\.[0-9]+ { yylval.fnum = atof( yytext ); return FNUM; }
+
+-?{DblConst} { yylval.fnum = atof( yytext ); return FNUM;}
+
+{StrConst} { yylval.name = strdup( yytext ); return STR; }
+
+. { return yytext[0]; }
+
+%%
+
+void yyerror( char * msg )
+{
+ config_error( msg, lineno );
+}
+
+int yywrap()
+{
+ return 1;
+}