[template-glib] expr-scanner.l: use @ to escape reserved words
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib] expr-scanner.l: use @ to escape reserved words
- Date: Wed, 4 May 2022 18:52:17 +0000 (UTC)
commit b75b466cad0e81e921c679ee4f2e937e23b54437
Author: Christian Hergert <chergert redhat com>
Date: Wed May 4 11:15:13 2022 -0700
expr-scanner.l: use @ to escape reserved words
Without this, you can't call a function called "require" on a GObject as
the require keyword would have higher priority. To use the reserved keyword
you can now instead use the following, similar to C♯.
obj.@require(args)
src/tmpl-expr-scanner.l | 6 ++++++
1 file changed, 6 insertions(+)
---
diff --git a/src/tmpl-expr-scanner.l b/src/tmpl-expr-scanner.l
index 404d3e6..6e1368b 100644
--- a/src/tmpl-expr-scanner.l
+++ b/src/tmpl-expr-scanner.l
@@ -78,6 +78,12 @@ TmplExprParser *parser = yyextra;
/* string literals */
L?\"(\\.|[^\\"])*\" { yylval->s = yytext; return STRING_LITERAL; }
+ /* @ to escape reserved keywords */
+@[a-zA-Z_][a-zA-Z0-9_]* {
+ yylval->s = g_strdup (yytext+1);
+ return NAME;
+}
+
/* names */
[a-zA-Z_][a-zA-Z0-9_]* {
yylval->s = g_strdup (yytext);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]