[template-glib] expr: add support or linewise comments
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib] expr: add support or linewise comments
- Date: Wed, 4 May 2022 22:07:20 +0000 (UTC)
commit 2749e786050b00d8febe62cdf906df6ad4dd393f
Author: Christian Hergert <chergert redhat com>
Date: Wed May 4 15:01:17 2022 -0700
expr: add support or linewise comments
Like python you can do # some comment
src/tmpl-expr-scanner.l | 3 ++-
tests/test1.script | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/tmpl-expr-scanner.l b/src/tmpl-expr-scanner.l
index 72ad036..4f92739 100644
--- a/src/tmpl-expr-scanner.l
+++ b/src/tmpl-expr-scanner.l
@@ -114,7 +114,8 @@ L?\"(\\.|[^\\"])*\" { yylval->s = copy_literal (yytext); return STRING_LITERAL;
"."?[0-9]+{EXP}? { yylval->d = atof(yytext); return NUMBER; }
"//".*
-[ \t] /* ignore whitespace */
+[ \t] /* ignore whitespace */
+#[^\n]* /* ignore line comments */
"\n" { return EOL; }
<<EOF>> { parser->reached_eof = TRUE; return EOL; }
. {
diff --git a/tests/test1.script b/tests/test1.script
index 0f99478..5f89abd 100644
--- a/tests/test1.script
+++ b/tests/test1.script
@@ -18,6 +18,8 @@ assert(abc == "abc")
assert(abc != "abc\n")
assert(abc != "def")
+# we can't do builtins yet w/ >1 param so this is a
+# very bad pow() implementation that works on integers only.
func pow(a,b) = while b > 1 do a = a * a; b = b - 1;
assert(pow(2,3) == 8)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]