summaryrefslogtreecommitdiff
path: root/examples/testxxLexer.l
diff options
context:
space:
mode:
authorWill Estes <wlestes@users.sourceforge.net>2001-05-01 20:47:11 +0000
committerWill Estes <wlestes@users.sourceforge.net>2001-05-01 20:47:11 +0000
commit2eae8800306d74d3507eee2464630a085b211779 (patch)
treea892110dd6ff826cf3691ce0b38615ed6d1fc061 /examples/testxxLexer.l
parent26e78464e71e0d03bf16cda54bcf06a6785e727c (diff)
downloadflex-git-2eae8800306d74d3507eee2464630a085b211779.tar.gz
adding the rest of vern's filesflex-2-5-5b
Diffstat (limited to 'examples/testxxLexer.l')
-rw-r--r--examples/testxxLexer.l58
1 files changed, 58 insertions, 0 deletions
diff --git a/examples/testxxLexer.l b/examples/testxxLexer.l
new file mode 100644
index 0000000..9421541
--- /dev/null
+++ b/examples/testxxLexer.l
@@ -0,0 +1,58 @@
+ // An example of using the flex C++ scanner class.
+
+%option C++ noyywrap
+
+%{
+int mylineno = 0;
+%}
+
+string \"[^\n"]+\"
+
+ws [ \t]+
+
+alpha [A-Za-z]
+dig [0-9]
+name ({alpha}|{dig}|\$)({alpha}|{dig}|\_|\.|\-|\/|\$)*
+num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)?
+num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
+number {num1}|{num2}
+
+%%
+
+{ws} /* skip blanks and tabs */
+
+"/*" {
+ int c;
+
+ while((c = yyinput()) != 0)
+ {
+ if(c == '\n')
+ ++mylineno;
+
+ else if(c == '*')
+ {
+ if((c = yyinput()) == '/')
+ break;
+ else
+ unput(c);
+ }
+ }
+ }
+
+{number} cout << "number " << YYText() << '\n';
+
+\n mylineno++;
+
+{name} cout << "name " << YYText() << '\n';
+
+{string} cout << "string " << YYText() << '\n';
+
+%%
+
+int main( int /* argc */, char** /* argv */ )
+ {
+ FlexLexer* lexer = new yyFlexLexer;
+ while(lexer->yylex() != 0)
+ ;
+ return 0;
+ }