From 1778852e86d710c5d28d46031b59e186a429dd38 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 28 Feb 2016 23:28:01 -0500 Subject: eshtrans: Support parameter lists --- (limited to 'eshtrans/frontend') 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 -- cgit v0.9.1