[pure-lang-svn] SF.net SVN: pure-lang: [222] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-06-14 08:23:55
|
Revision: 222 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=222&view=rev Author: agraef Date: 2008-06-14 01:24:02 -0700 (Sat, 14 Jun 2008) Log Message: ----------- Add -x option, shebang support. Modified Paths: -------------- pure/trunk/lexer.ll pure/trunk/pure.cc Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-06-14 07:41:05 UTC (rev 221) +++ pure/trunk/lexer.ll 2008-06-14 08:24:02 UTC (rev 222) @@ -154,6 +154,7 @@ {blank}+ yylloc->step(); [\n]+ yylloc->lines(yyleng); yylloc->step(); +^"#!".* | "//".* yylloc->step(); "/*" BEGIN(comment); Modified: pure/trunk/pure.cc =================================================================== --- pure/trunk/pure.cc 2008-06-14 07:41:05 UTC (rev 221) +++ pure/trunk/pure.cc 2008-06-14 08:24:02 UTC (rev 222) @@ -31,11 +31,13 @@ #define COPYRIGHT "Copyright (c) 2008 by Albert Graef" #define USAGE \ "Usage: pure [-h] [-i] [-n] [-q] [-v[level]] [script ...] [-- args ...]\n\ + pure [-h] [-i] [-n] [-q] [-v[level]] -x script [args ...]\n\ -h: Print this message and exit.\n\ -i: Force interactive mode (read commands from stdin).\n\ -n: Suppress automatic inclusion of the prelude.\n\ -q: Quiet startup (suppresses sign-on message).\n\ -v: Set verbosity level (useful for debugging purposes).\n\ +-x: Execute script with given command line arguments.\n\ --: Stop option processing, pass remaining args in argv variable.\n\ Environment:\n\ PURELIB: Directory to search for source scripts including the prelude.\n\ @@ -214,6 +216,9 @@ interp.error(prog + ": invalid option " + *args); return 1; } + } else if (*args == string("-x")) { + while (*++args) myargs.push_back(*args); + break; } else if (*args == string("--")) { while (*++args) myargs.push_back(*args); break; @@ -244,6 +249,12 @@ string s = string(*argv).substr(2); if (!s.empty()) level = (uint8_t)strtoul(s.c_str(), 0, 0); interp.verbose = level; + } else if (*argv == string("-x")) { + if (*++argv) { + if (count++ == 0) interp.modname = *argv; + interp.run(*argv); + } + break; } else if (*argv == string("--")) break; else if (**argv == '-') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |