summaryrefslogtreecommitdiffstats
path: root/eshtrans
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-02-22 19:53:13 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-02-22 19:53:33 (EST)
commit43a8cf835bf017b3362f5dd02efa74f69537462d (patch)
tree46157eb8528f6bbf05f82f9cdceb486958755da7 /eshtrans
parentdd634f296ae9c40b7e85cc51f17869eaeca6568e (diff)
downloadeggshell-43a8cf835bf017b3362f5dd02efa74f69537462d.zip
eggshell-43a8cf835bf017b3362f5dd02efa74f69537462d.tar.gz
eggshell-43a8cf835bf017b3362f5dd02efa74f69537462d.tar.bz2
eshtrans: Add T_LOCAL
Diffstat (limited to 'eshtrans')
-rw-r--r--eshtrans/frontend/lexer.esh11
-rw-r--r--eshtrans/frontend/parser.esh2
-rw-r--r--eshtrans/tokens.esh2
3 files changed, 9 insertions, 6 deletions
diff --git a/eshtrans/frontend/lexer.esh b/eshtrans/frontend/lexer.esh
index b7d0886..5a8bd56 100644
--- a/eshtrans/frontend/lexer.esh
+++ b/eshtrans/frontend/lexer.esh
@@ -913,9 +913,10 @@ accept()
dbg "looking for $t, current tok ${tok%%${US}*}"
case "${t}" in
- T_IF|T_THEN|T_ELSE|T_ELIF|T_FI|\
- T_DO|T_DONE|T_CASE|T_ESAC|T_WHILE|T_UNTIL|\
- T_FOR|T_LBRACE|T_RBRACE|T_BANG|T_IN|T_STATIC|T_RETURN)
+ T_IF|T_THEN|T_ELSE|T_ELIF|T_FI|T_DO|T_DONE|\
+ T_CASE|T_ESAC|T_WHILE|T_UNTIL|T_FOR|\
+ T_LBRACE|T_RBRACE|T_BANG|T_IN|\
+ T_STATIC|T_LOCAL|T_RETURN)
dbg "looking for reserved word $t, have '$tok'"
if ! [ "x${tok%%${US}*}" = "x${t}" ]; then
# Reserved words are recognized as literal
@@ -969,7 +970,7 @@ accept()
for rw in T_IF T_THEN T_ELSE T_ELIF T_FI T_DO T_DONE \
T_CASE T_ESAC T_WHILE T_UNTIL T_FOR \
T_LBRACE T_RBRACE T_BANG T_IN \
- T_STATIC T_RETURN; do
+ T_STATIC T_LOCAL T_RETURN; do
if [ "x${tok#T_WORD${US}}" = \
"x$(toktext "${rw}")" ]; then
tok="${rw}"
@@ -988,7 +989,7 @@ accept()
for rw in T_IF T_THEN T_ELSE T_ELIF T_FI T_DO T_DONE \
T_CASE T_ESAC T_WHILE T_UNTIL T_FOR \
T_LBRACE T_RBRACE T_BANG T_IN \
- T_STATIC T_RETURN; do
+ T_STATIC T_LOCAL T_RETURN; do
if [ "x${tok#T_WORD${US}}" = \
"x$(toktext "${rw}")" ]; then
tok="${rw}"
diff --git a/eshtrans/frontend/parser.esh b/eshtrans/frontend/parser.esh
index e993221..e967fc7 100644
--- a/eshtrans/frontend/parser.esh
+++ b/eshtrans/frontend/parser.esh
@@ -404,7 +404,7 @@ do_group()
simple_command()
{
ptrace_begn simple_command
- if accept T_RETURN; then
+ if accept T_LOCAL || accept T_RETURN; then
cmd_suffix
ptrace_pass simple_command
return 0
diff --git a/eshtrans/tokens.esh b/eshtrans/tokens.esh
index a4dee4f..edb5f76 100644
--- a/eshtrans/tokens.esh
+++ b/eshtrans/tokens.esh
@@ -65,6 +65,7 @@ tokname()
T_BANG) n='"!"';;
T_IN) n='"in"';;
T_STATIC) n='"static"';;
+ T_LOCAL) n='"local"';;
T_RETURN) n='"return"';;
# Special symbols
T_NAME) n='parameter name';;
@@ -130,6 +131,7 @@ toktext()
T_BANG) n='!';;
T_IN) n='in';;
T_STATIC) n='static';;
+ T_LOCAL) n='__local';;
T_RETURN) n='return';;
# Special symbols
T_NAME) n="${t#*${US}}";;