summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eshtrans/backend/codegen.esh10
-rw-r--r--eshtrans/backend/main.esh1
-rw-r--r--eshtrans/frontend/lexer.esh8
-rw-r--r--eshtrans/frontend/parser.esh1
-rw-r--r--eshtrans/tokens.esh4
5 files changed, 21 insertions, 3 deletions
diff --git a/eshtrans/backend/codegen.esh b/eshtrans/backend/codegen.esh
index 8d77ce9..a9c3cef 100644
--- a/eshtrans/backend/codegen.esh
+++ b/eshtrans/backend/codegen.esh
@@ -109,3 +109,13 @@ sh_parse_stack()
done
codegen_sub "${array}"
}
+
+sh_set_tu_id()
+{
+ local toks="${1}"
+
+ tu_id="$(printf '%s' "${toks}" | sha256sum -)"
+ tu_id="${tu_id% -}"
+
+ return 0
+}
diff --git a/eshtrans/backend/main.esh b/eshtrans/backend/main.esh
index 884a2c3..485e9be 100644
--- a/eshtrans/backend/main.esh
+++ b/eshtrans/backend/main.esh
@@ -23,6 +23,7 @@ sh_codegen()
local toks="${1}"
shift 1
+ sh_set_tu_id "${toks}"
if printf '%s' "${toks}" | sh_parse_stack; then
return 0
else
diff --git a/eshtrans/frontend/lexer.esh b/eshtrans/frontend/lexer.esh
index 92c806c..8f83a1a 100644
--- a/eshtrans/frontend/lexer.esh
+++ b/eshtrans/frontend/lexer.esh
@@ -915,7 +915,7 @@ accept()
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_FOR|T_LBRACE|T_RBRACE|T_BANG|T_IN|T_STATIC|T_RETURN)
dbg "looking for reserved word $t, have '$tok'"
if ! [ "x${tok%%${US}*}" = "x${t}" ]; then
# Reserved words are recognized as literal
@@ -968,7 +968,8 @@ accept()
# reserved words.
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; do
+ T_LBRACE T_RBRACE T_BANG T_IN \
+ T_STATIC T_RETURN; do
if [ "x${tok#T_WORD${US}}" = \
"x$(toktext "${rw}")" ]; then
tok="${rw}"
@@ -986,7 +987,8 @@ accept()
# Verify that the word doesn't match any reserved words.
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; do
+ T_LBRACE T_RBRACE T_BANG T_IN \
+ T_STATIC 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 449c5ba..a29bc5c 100644
--- a/eshtrans/frontend/parser.esh
+++ b/eshtrans/frontend/parser.esh
@@ -398,6 +398,7 @@ do_group()
simple_command()
{
ptrace_begn simple_command
+ accept T_STATIC
if cmd_prefix; then
if cmd_word; then
cmd_suffix
diff --git a/eshtrans/tokens.esh b/eshtrans/tokens.esh
index 9da8bb8..9f68ca6 100644
--- a/eshtrans/tokens.esh
+++ b/eshtrans/tokens.esh
@@ -64,6 +64,8 @@ tokname()
T_RBRACE) n='"}"';;
T_BANG) n='"!"';;
T_IN) n='"in"';;
+ T_STATIC) n='"static"';;
+ T_RETURN) n='"return"';;
# Special symbols
T_NAME) n='parameter name';;
T_FNAME) n='function name';;
@@ -124,6 +126,8 @@ toktext()
T_RBRACE) n='}';;
T_BANG) n='!';;
T_IN) n='in';;
+ T_STATIC) n='static';;
+ T_RETURN) n='return';;
# Special symbols
T_NAME) n="${t#*${US}}";;
T_FNAME) n="${t#*${US}}";;