diff options
author | P. J. McDermott <pj@pehjota.net> | 2016-02-28 23:28:01 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2016-02-28 23:28:01 (EST) |
commit | 1778852e86d710c5d28d46031b59e186a429dd38 (patch) | |
tree | 9d0610d266a1c6e3deb56b3948863972a90fba2f /eshtrans/frontend | |
parent | 222ad7c5b260afb6394e39c2bdbd69a92cf4a7d5 (diff) | |
download | eggshell-1778852e86d710c5d28d46031b59e186a429dd38.zip eggshell-1778852e86d710c5d28d46031b59e186a429dd38.tar.gz eggshell-1778852e86d710c5d28d46031b59e186a429dd38.tar.bz2 |
eshtrans: Support parameter lists
Diffstat (limited to 'eshtrans/frontend')
-rw-r--r-- | eshtrans/frontend/lexer.esh | 22 | ||||
-rw-r--r-- | eshtrans/frontend/parser.esh | 7 |
2 files changed, 28 insertions, 1 deletions
diff --git a/eshtrans/frontend/lexer.esh b/eshtrans/frontend/lexer.esh index 6eb168a..275e928 100644 --- a/eshtrans/frontend/lexer.esh +++ b/eshtrans/frontend/lexer.esh @@ -221,6 +221,11 @@ next() next_io return ;; + ',') + lgetc + tok=T_COMMA + return + ;; *) next_word return @@ -438,7 +443,7 @@ scan_word() lines=$((${lines} + 1)) word="${word}${c}" ;; - ' '|"${HT}"|'&'|'|'|';'|'('|')'|'<'|'>') + ' '|"${HT}"|'&'|'|'|';'|'('|')'|'<'|'>'|',') if ! ${in_param} && ! ${quoted}; then break fi @@ -949,6 +954,21 @@ accept() tok="${t}" fi ;; + T_TYPE) + # Types are recognized as literal T_WORDs. + if ! [ "x${tok%%${US}*}" = 'xT_WORD' ]; then + return 1 + fi + # Validate type. + case "${tok#*${US}}" in + 'bool'|'int'|'string') + ;; + *) + return 1 + ;; + esac + tok="T_TYPE${US}${tok#T_WORD${US}}" + ;; T_NAME) # Names are recognized as literal T_WORDs. if ! [ "x${tok%%${US}*}" = 'xT_WORD' ]; then diff --git a/eshtrans/frontend/parser.esh b/eshtrans/frontend/parser.esh index 7966fb6..2607d96 100644 --- a/eshtrans/frontend/parser.esh +++ b/eshtrans/frontend/parser.esh @@ -421,6 +421,13 @@ simple_command() return 0 elif accept T_FNAME; then if accept T_LPAREN; then + if accept T_TYPE; then + expect T_NAME + while accept T_COMMA; do + expect T_TYPE + expect T_NAME + done + fi expect T_RPAREN if linebreak && function_body; then #ptrace_pass simple_command |