diff options
author | P. J. McDermott <pj@pehjota.net> | 2017-02-08 23:12:06 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2017-02-08 23:12:06 (EST) |
commit | 958ce6861a0a174245e8a60379eeffa45c49bb87 (patch) | |
tree | ba4eef1a04a73679a86d0a1f4fdfa2c431596653 /eshtrans/frontend | |
parent | cd70253021852f0c200e2ecb87b726961eddf90e (diff) | |
download | eggshell-958ce6861a0a174245e8a60379eeffa45c49bb87.zip eggshell-958ce6861a0a174245e8a60379eeffa45c49bb87.tar.gz eggshell-958ce6861a0a174245e8a60379eeffa45c49bb87.tar.bz2 |
eshtrans/frontend: Replace printf calls with array
This should run faster, due to the reduced forks and I/O calls, but it
doesn't seem to.
Also, this messes up the order of tokens.
Diffstat (limited to 'eshtrans/frontend')
-rw-r--r-- | eshtrans/frontend/lexer.esh | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/eshtrans/frontend/lexer.esh b/eshtrans/frontend/lexer.esh index 8ce6510..5854a35 100644 --- a/eshtrans/frontend/lexer.esh +++ b/eshtrans/frontend/lexer.esh @@ -30,6 +30,7 @@ here_queue= here_awaiting_end= here_awaiting_word= tok= +tokc= #dbg() #{ @@ -856,6 +857,7 @@ run_sublexer() here_queue='' here_awaiting_end=false here_awaiting_word=false + tokc=0 lbufi="${i}" lsetc @@ -872,6 +874,10 @@ run_sublexer() ;; esac + eval "printf '%s' \"$(printf '${tokv_%d}' $(awk \ + -v end=${tokc} \ + 'BEGIN { for (i = 0; i < end; ++i) print(i); }'))\"" + printf "${RS}%d${RS}%d" ${lineno} ${lbufi} return 0 } @@ -894,6 +900,7 @@ run_lexer() here_queue='' here_awaiting_end=false here_awaiting_word=false + tokc=0 # Read file into array eval "$(printf '%s' "${buf}" | awk -v FS='' -v j=0 \ @@ -922,6 +929,10 @@ run_lexer() synexp '' fi + eval "printf '%s' \"$(printf '${tokv_%d}' $(awk \ + -v end=${tokc} \ + 'BEGIN { for (i = 0; i < end; ++i) print(i); }'))\"" + return 0 } @@ -1069,7 +1080,8 @@ accept() esac #dbg "accept $t" - printf '%s' "${tok}${RS}" + eval "tokv_${tokc}=\${tok}\${RS}" + tokc=$((${tokc} + 1)) next return 0 } |