From 9874562545d93582a75bc2e6d58fc772e981a3ba Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 25 May 2021 19:58:05 +0200 Subject: lexer: implement raw code mode Enabling raw code mode allows writing ucode scripts without any template tag decorations (that is, without the need to provide an initial opening '{%' tag). Signed-off-by: Jo-Philipp Wich --- main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 4b34ef2..5d14c83 100644 --- a/main.c +++ b/main.c @@ -40,7 +40,7 @@ print_usage(const char *app) { printf( "== Usage ==\n\n" - " # %s [-d] [-l] [-r] [-S] [-e '[prefix=]{\"var\": ...}'] [-E [prefix=]env.json] {-i | -s \"ucode script...\"}\n" + " # %s [-d] [-l] [-r] [-S] [-R] [-e '[prefix=]{\"var\": ...}'] [-E [prefix=]env.json] {-i | -s \"ucode script...\"}\n" " -h, --help Print this help\n" " -i file Specify an ucode script to parse\n" " -s \"ucode script...\" Specify an ucode fragment to parse\n" @@ -48,6 +48,7 @@ print_usage(const char *app) " -l Do not strip leading block whitespace\n" " -r Do not trim trailing block newlines\n" " -S Enable strict mode\n" + " -R Enable raw code mode\n" " -e Set global variables from given JSON object\n" " -E Set global variables from given JSON file\n" " -m Preload given module\n", @@ -214,7 +215,7 @@ main(int argc, char **argv) goto out; } - while ((opt = getopt(argc, argv, "hlrSe:E:i:s:m:")) != -1) + while ((opt = getopt(argc, argv, "hlrSRe:E:i:s:m:")) != -1) { switch (opt) { case 'h': @@ -262,6 +263,10 @@ main(int argc, char **argv) config.strict_declarations = true; break; + case 'R': + config.raw_mode = true; + break; + case 'e': c = strchr(optarg, '='); -- cgit v1.2.3