From ef56ac3105dbd72cc5989edef9bbbb3fedfe6449 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 4 Jan 2012 23:30:24 -0700 Subject: Demo is being reworked. Fixed comment handling. --- src/options.cpp | 2 ++ src/parser.l | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/options.cpp b/src/options.cpp index 23a98a8..f5fb127 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -25,10 +25,12 @@ void Options::parse( int argc, char *argv[] ) " - Simple, Textual, Adventure Game Environment"); opt.addHelpBanner("usage: " + Bu::String(argv[0]) + " [options] \n"); + opt.addOption( Bu::slot( this, &Options::version ), "version", "Show full version info." ); opt.addOption( Bu::slot( this, &Options::builtins ), "builtins", "List available builtins." ); + opt.addHelpOption('h', "help"); opt.setNonOption( Bu::slot( this, &Options::nonOption ) ); opt.parse( argc, argv ); diff --git a/src/parser.l b/src/parser.l index e0bc340..7957c53 100644 --- a/src/parser.l +++ b/src/parser.l @@ -55,14 +55,15 @@ false { yylval->bValue = false; return tokBool; } null { return tokNull; } "<<" { BEGIN( sitname ); } -[- a-zA-Z0-9]+ { yylval->sValue = new Bu::String( yytext ); return tokSituationName; } +[-_ a-zA-Z0-9]+ { yylval->sValue = new Bu::String( yytext ); return tokSituationName; } ">>" { BEGIN( INITIAL ); } . REJECT; -"//"[^\n]* {} +"//"[^\n]*\n? {} -"/\*" { BEGIN( comment ); } -"\*/" { BEGIN( INITIAL ); } +"/*" { BEGIN( comment ); } +"*/" { BEGIN( INITIAL ); } +[\n\r] {} . {} [a-zA-Z_][a-zA-Z0-9_]* { yylval->sValue = new Bu::String( yytext ); return tokIdent; } @@ -112,4 +113,7 @@ null { return tokNull; } yylloc->first_line = yylloc->last_line; } +\r { } +. { throw Bu::ExceptionBase("Invalid character found '%s'", yytext ); } + %% -- cgit v1.2.3