aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-07-26 23:00:55 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-08-02 15:52:18 +0800
commitf3a533ddaec1c7b7258145aea38ab698da8fb545 (patch)
treea2a37bfbe21a06856a028b3b5859e00ecbbcacff
parentCore: do not declare $* to be read-only (diff)
downloadlibbash-f3a533ddaec1c7b7258145aea38ab698da8fb545.tar.gz
libbash-f3a533ddaec1c7b7258145aea38ab698da8fb545.tar.bz2
libbash-f3a533ddaec1c7b7258145aea38ab698da8fb545.zip
Parser: make the lexer code thread-safe
-rw-r--r--bashast/bashast.g27
1 files changed, 22 insertions, 5 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 9c248e4..bb70aec 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -127,18 +127,31 @@ tokens{
BUILTIN_LOGIC;
}
-@lexer::members
+@lexer::context
{
#ifdef OUTPUT_C
- bool double_quoted = false;
-#else
- boolean double_quoted = false;
+ bool double_quoted;
+ int paren_level;
+#endif
+}
+
+@lexer::apifuncs
+{
+#ifdef OUTPUT_C
+ ctx->double_quoted = false;
+ ctx->paren_level = 0;
+#endif
+}
+@lexer::members
+{
+#ifndef OUTPUT_C
+ boolean double_quoted = false;
+ int paren_level = 0;
int LA(int index) {
return input.LA(index);
}
#endif
- int paren_level = 0;
}
#ifdef OUTPUT_C
@includes {
@@ -149,6 +162,10 @@ tokens{
C_INCLUDE #include "core/exceptions.h"
}
+@lexer::postinclude {
+ #define double_quoted ctx->double_quoted
+ #define paren_level ctx->paren_level
+}
#endif
@members
{