aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-06-26 20:27:46 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-06-26 20:27:46 +0800
commitb7ff827783049072f8afefad626522e39c092511 (patch)
treea780e7b362036388040f990f372a64496a8e67a2
parentMerge remote-tracking branch 'mu/fix_arithmetic' (diff)
parentParser: use lexer rule to parse singled quoted string (diff)
downloadlibbash-b7ff827783049072f8afefad626522e39c092511.tar.gz
libbash-b7ff827783049072f8afefad626522e39c092511.tar.bz2
libbash-b7ff827783049072f8afefad626522e39c092511.zip
Merge branch 'mu/native_code'
Conflicts: Makefile.am bashast/features_script/features.sh.ast bashast/gunit/simp_command.gunit scripts/command_execution.bash test/verify_error_output_test.sh
-rw-r--r--.gitignore8
-rw-r--r--Makefile.am55
-rw-r--r--bashast/bashast.g114
-rw-r--r--bashast/features_script/features.sh.ast2
-rw-r--r--bashast/features_script/features.sh.tokens2
-rw-r--r--bashast/features_script/features.sh.walker.tokens2
-rw-r--r--bashast/gunit/arith_main.gunit2
-rw-r--r--bashast/gunit/array.gunit2
-rw-r--r--bashast/gunit/assoc_array.gunit2
-rw-r--r--bashast/gunit/brace.gunit2
-rw-r--r--bashast/gunit/command_sub.gunit4
-rw-r--r--bashast/gunit/comment.gunit2
-rw-r--r--bashast/gunit/compound.gunit4
-rw-r--r--bashast/gunit/cond_main.gunit2
-rw-r--r--bashast/gunit/continued_lines.gunit5
-rw-r--r--bashast/gunit/expansions.gunit2
-rw-r--r--bashast/gunit/fname.gunit14
-rw-r--r--bashast/gunit/function.gunit2
-rw-r--r--bashast/gunit/list.gunit4
-rw-r--r--bashast/gunit/param_main.gunit4
-rw-r--r--bashast/gunit/pipeline.gunit2
-rw-r--r--bashast/gunit/process_substitution.gunit2
-rw-r--r--bashast/gunit/redir.gunit6
-rw-r--r--bashast/gunit/simp_command.gunit3
-rw-r--r--bashast/gunit/simp_prog.gunit2
-rw-r--r--bashast/libbashWalker.g10
-rw-r--r--scripts/command_execution.bash1
-rw-r--r--scripts/command_execution.bash.result1
-rw-r--r--scripts/here_document.ast3
-rw-r--r--scripts/here_document.sh5
-rw-r--r--test/post_check.cpp4
-rwxr-xr-xtest/verify_here_document.sh3
32 files changed, 200 insertions, 76 deletions
diff --git a/.gitignore b/.gitignore
index 4c665a8..7a07a66 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+*.bak
*.swp
*.swo
*.o
@@ -6,6 +7,8 @@
*.lo
*.log
*.class
+*.java
+*.tokens
.deps
.libs
.dirstamp
@@ -26,9 +29,9 @@ instruo
long.sh
massif.out
libbash.g
-libbash.tokens
+java_libbash.g
libbash.tokens.md5
-bashast.tokens
+libbashWalker.h.md5
bashast/.DS_Store
bashast/*.ebuild
bashast/c_runtime
@@ -42,7 +45,6 @@ libbashLexer.*
libbashParser.*
libbashWalker.h
libbashWalker.cpp
-libbashWalker.tokens
*.pdf
*.aux
config.*
diff --git a/Makefile.am b/Makefile.am
index 403ecf4..3622ab9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -72,7 +72,7 @@ EBUILD_RESULT = scripts/sunpinyin-2.0.3-r1.ebuild.result
TESTS = $(GUNIT_TESTS) $(BASH_TESTS) $(EBUILD_TESTS)
# these get cleaned so only add autogenerated stuff or modify CLEANFILES
-check_JAVA = bashast/bashastLexer.java bashast/bashastParser.java
+check_JAVA = bashast/java_libbashLexer.java bashast/java_libbashParser.java
AM_JAVACFLAGS = -source 1.4 -classpath @antlr_cp@
AM_CXXFLAGS = -std=c++0x
@@ -92,7 +92,10 @@ AM_CPPFLAGS += -D_GLIBCXX_DEBUG
endif
if HAVE_GTEST
-TESTS += cppunittests test/ast_printer_test.sh test/verify_bashs_test.sh test/verify_error_output_test.sh
+TESTS += cppunittests \
+ test/ast_printer_test.sh \
+ test/verify_bashs_test.sh \
+ test/verify_error_output_test.sh
check_PROGRAMS = cppunittests
cppunittests_SOURCES = test/run_tests.cpp \
@@ -149,24 +152,31 @@ ast_printer_LDFLAGS = -static
# linking will fail
ast_printer_CPPFLAGS = $(AM_CPPFLAGS) -U_GLIBCXX_DEBUG $(BOOST_CPPFLAGS)
-GENERATED_PARSER_C = libbashLexer.c libbashParser.c
-GENERATED_PARSER_H = libbashLexer.h libbashParser.h
+GENERATED_LEXER_CPP = libbashLexer.cpp
+GENERATED_LEXER_H = libbashLexer.h
+GENERATED_PARSER_CPP = libbashParser.cpp
+GENERATED_PARSER_H = libbashParser.h
GENERATED_WALKER_CPP = libbashWalker.cpp
GENERATED_WALKER_H = libbashWalker.h
-BUILT_SOURCES = $(GENERATED_PARSER_C) \
+BUILT_SOURCES = $(GENERATED_PARSER_CPP) \
$(GENERATED_PARSER_H) \
+ $(GENERATED_LEXER_CPP) \
+ $(GENERATED_LEXER_H) \
$(GENERATED_WALKER_CPP) \
$(GENERATED_WALKER_H) \
$(check_JAVA)
-CLEANFILES = $(GENERATED_PARSER_C) \
+CLEANFILES = $(GENERATED_PARSER_CPP) \
$(GENERATED_PARSER_H) \
+ $(GENERATED_LEXER_CPP) \
+ $(GENERATED_LEXER_H) \
$(GENERATED_WALKER_CPP) \
$(GENERATED_WALKER_H) \
$(check_JAVA) \
libbash.g \
+ java_libbash.g \
libbash.tokens \
libbash.tokens.md5 \
- bashast/bashast.tokens \
+ bashast/java_libbash.tokens \
libbashWalker.tokens \
javagrammar.run \
cgrammar.run \
@@ -229,7 +239,16 @@ libcppbash_la_SOURCES = src/common.h \
# separate library because we need per file CXXFLAGS
# as antlr generated code does not pass our strict developer
# warning settings
-noinst_LTLIBRARIES = libwalker.la
+noinst_LTLIBRARIES = libparser.la libwalker.la
+libparser_la_SOURCES = $(GENERATED_PARSER_CPP) \
+ $(GENERATED_PARSER_H) \
+ $(GENERATED_LEXER_CPP) \
+ $(GENERATED_LEXER_H)
+
+libparser_la_CXXFLAGS = -std=c++0x \
+ -fvisibility=hidden \
+ -fvisibility-inlines-hidden
+
libwalker_la_SOURCES = $(GENERATED_WALKER_CPP) \
$(GENERATED_WALKER_H)
@@ -246,7 +265,7 @@ if DEVELOPER_MODE
libcppbash_la_CXXFLAGS += -Wconversion -Wsign-conversion
endif
libcppbash_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
-libcppbash_la_LIBADD = libwalker.la
+libcppbash_la_LIBADD = libparser.la libwalker.la
EXTRA_DIST = bashast/bashast.g \
bashast/libbashWalker.g \
@@ -284,12 +303,14 @@ ANTLR = @JAVA@ -classpath @antlr_cp@ org.antlr.Tool
cgrammar.run: libbash.g
$(AM_V_at)touch $@.tmp
$(AM_V_GEN)$(ANTLR) -fo . $<
+ $(AM_V_at)mv libbashParser.{c,cpp}
+ $(AM_V_at)mv libbashLexer.{c,cpp}
$(AM_V_at)mv $@.tmp $@
libbash.g: bashast/bashast.g
- $(AM_V_at)sed -e 's/ASTLabelType = CommonTree;/ASTLabelType = pANTLR3_BASE_TREE;/g' \
- -e 's/language = Java;/language = C;/g' \
- -e 's/grammar bashast;/grammar libbash;/g' $< > $@
+ $(AM_V_at)$(CC) -E -x c++ -D OUTPUT_C $< > $@
+ $(AM_V_at)sed -i '/^#.*/d' $@
+ $(AM_V_at)sed -i 's/C_INCLUDE \(.*\)/\1/' $@
# http://www.kolpackov.net/pipermail/notes/2004-September.txt
libbash.tokens.md5: libbash.tokens
@@ -304,14 +325,20 @@ walker.run: bashast/libbashWalker.g libbash.tokens.md5
$(AM_V_at)mv libbashWalker.{c,cpp}
$(AM_V_at)mv $@.tmp $@
-$(GENERATED_PARSER_C): cgrammar.run
+$(GENERATED_PARSER_CPP): cgrammar.run
$(GENERATED_PARSER_H): cgrammar.run
+$(GENERATED_LEXER_CPP): cgrammar.run
+$(GENERATED_LEXER_H): cgrammar.run
libbash.tokens: cgrammar.run
$(GENERATED_WALKER_CPP): walker.run
$(GENERATED_WALKER_H): walker.run
-javagrammar.run: bashast/bashast.g
+java_libbash.g: bashast/bashast.g
+ $(AM_V_at)$(CC) -E -x c++ -D OUTPUT_JAVA $< > $@
+ $(AM_V_at)sed -i '/^#.*/d' $@
+
+javagrammar.run: java_libbash.g
$(AM_V_at)touch $@.tmp
$(AM_V_GEN)$(ANTLR) -fo bashast $<
$(AM_V_at)mv $@.tmp $@
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 1a73c4b..8903c02 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -16,14 +16,23 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-grammar bashast;
+#ifdef OUTPUT_C
+grammar libbash;
+#else
+grammar java_libbash;
+#endif
options
{
backtrack = true;
output = AST;
+ memoize = true;
+#ifdef OUTPUT_C
+ language = C;
+ ASTLabelType = pANTLR3_BASE_TREE;
+#else
language = Java;
ASTLabelType = CommonTree;
- memoize = true;
+#endif
}
tokens{
ARG;
@@ -76,8 +85,8 @@ tokens{
CHARACTER_CLASS;
EQUIVALENCE_CLASS;
COLLATING_SYMBOL;
- SINGLE_QUOTED_STRING;
DOUBLE_QUOTED_STRING;
+ SINGLE_QUOTED_STRING;
VARIABLE_DEFINITIONS;
// parameter expansion operators
USE_DEFAULT_WHEN_UNSET;
@@ -104,6 +113,50 @@ tokens{
BUILTIN_LOGIC;
}
+@lexer::members
+{
+#ifdef OUTPUT_C
+ bool double_quoted = false;
+#else
+ boolean double_quoted = false;
+#endif
+}
+
+#ifdef OUTPUT_C
+@includes {
+ C_INCLUDE #include <iostream>
+ C_INCLUDE #include <string>
+
+ C_INCLUDE #include <boost/numeric/conversion/cast.hpp>
+}
+@members
+{
+ static std::string get_string(pANTLR3_COMMON_TOKEN token)
+ {
+ if(!token || !token->start)
+ return "";
+ // Use reinterpret_cast here because we have to cast C code.
+ // The real type here is int64_t which is used as a pointer.
+ // token->stop - token->start + 1 should be bigger than 0.
+ return std::string(reinterpret_cast<const char *>(token->start),
+ boost::numeric_cast<unsigned>(token->stop - token->start + 1));
+ }
+
+ static bool is_here_end(plibbashParser ctx, const std::string& here_doc_word, int number_of_tokens_in_word)
+ {
+ std::string word;
+ for(int i = 1; i <= number_of_tokens_in_word; ++i)
+ word += get_string(LT(i));
+ return (word == here_doc_word);
+ }
+
+ static void free_redirect_atom(plibbashParser_redirect_atom_SCOPE scope)
+ {
+ (&(scope->here_doc_word))->std::string::~string();
+ }
+}
+#endif
+
start : (flcomment)? EOL* clist BLANK* (SEMIC|AMP|EOL)? EOF -> clist;
//Because the comment token doesn't handle the first comment in a file if it's on the first line, have a parser rule for it
flcomment
@@ -153,19 +206,49 @@ bash_command_arguments
bash_command_arguments_atom
: brace_expansion|LBRACE|RBRACE|fname_part;
redirect: (BLANK!* redirect_atom)*;
-redirect_atom: here_string_op^ BLANK!* fname
- | here_doc_op^ BLANK!* fname EOL! heredoc
+redirect_atom
+#ifdef OUTPUT_C
+scope {
+ std::string here_doc_word;
+ int number_of_tokens_in_word;
+}
+@init {
+ // http://antlr.1301665.n2.nabble.com/C-target-initialization-of-return-scope-structures-td5078478.html
+ new (&($redirect_atom::here_doc_word)) std::string;
+ $redirect_atom::number_of_tokens_in_word = 0;
+ ctx->plibbashParser_redirect_atomTop->free = &free_redirect_atom;
+}
+#endif
+ : HERE_STRING_OP^ BLANK!* fname
+#ifdef OUTPUT_C
+ | here_doc_op BLANK* here_doc_begin redirect?
+#else
+ | here_doc_op BLANK* n=NAME redirect?
+#endif
+ EOL heredoc -> ^(here_doc_op ^(STRING heredoc) redirect?)
| redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest)
| process_substitution;
+#ifdef OUTPUT_C
+here_doc_begin
+ :( {
+ if(LA(1) != BLANK && LA(1) != EOL)
+ {
+ $redirect_atom::here_doc_word += get_string(LT(1));
+ ++$redirect_atom::number_of_tokens_in_word;
+ }
+ } (~(EOL|BLANK)))+;
+here_doc_end
+ : ({ ($redirect_atom::number_of_tokens_in_word) != 0 }? => .{ ($redirect_atom::number_of_tokens_in_word)--; })+;
+heredoc : ({ !is_here_end(ctx, $redirect_atom::here_doc_word, $redirect_atom::number_of_tokens_in_word) }? => .)+ here_doc_end!;
+#else
+heredoc : (fname_part EOL!)*;
+#endif
redir_dest
: file_desc_as_file //handles file descriptors
| fname; //path to a file
file_desc_as_file
: DIGIT -> ^(FILE_DESCRIPTOR DIGIT)
| DIGIT MINUS -> ^(FILE_DESCRIPTOR_MOVE DIGIT);
-heredoc : (fname EOL!)*;
-here_string_op
- : HERE_STRING_OP;
here_doc_op
: LSHIFT MINUS -> OP["<<-"]
| LSHIFT -> OP["<<"];
@@ -438,7 +521,7 @@ nqstr_part
| arithmetic_expansion
| brace_expansion
| dqstr
- | sqstr
+ | SINGLE_QUOTED_STRING_TOKEN -> ^(SINGLE_QUOTED_STRING SINGLE_QUOTED_STRING_TOKEN)
| str_part
| pattern_match_trigger
| BANG;
@@ -452,10 +535,6 @@ dqstr_part
| ESC TICK -> TICK
| ESC DOLLAR -> DOLLAR
| ~(DOLLAR|TICK|DQUOTE);
-//single quoted string rule, no expansions
-sqstr_part
- : ~SQUOTE*;
-sqstr : SQUOTE sqstr_part SQUOTE -> ^(SINGLE_QUOTED_STRING sqstr_part);
//certain tokens that trigger pattern matching
pattern_match_trigger
: LSQUARE
@@ -571,7 +650,7 @@ function: FUNCTION BLANK+ function_name ((BLANK* parens wspace*)|wspace) compoun
//does not contain a dollar sign, nor is quoted in any way. Nor
//does it consist of all digits.
function_name
- : (NUMBER|DIGIT)? ~(DOLLAR|SQUOTE|DQUOTE|LPAREN|RPAREN|BLANK|EOL|NUMBER|DIGIT) ~(DOLLAR|SQUOTE|DQUOTE|LPAREN|RPAREN|BLANK|EOL)*;
+ : (NUMBER|DIGIT)? ~(DOLLAR|SQUOTE|DQUOTE|LPAREN|RPAREN|BLANK|EOL|NUMBER|DIGIT|SINGLE_QUOTED_STRING_TOKEN) ~(DOLLAR|SQUOTE|DQUOTE|LPAREN|RPAREN|BLANK|EOL)*;
parens : LPAREN BLANK* RPAREN;
name : NAME
| LETTER
@@ -583,7 +662,7 @@ esc_char: ESC (DIGIT DIGIT? DIGIT?|LETTER ALPHANUM ALPHANUM?|.);
//****************
COMMENT
- : (BLANK|EOL) '#' ~('\n'|'\r')* {$channel=HIDDEN;}
+ : { !double_quoted }?=> (BLANK|EOL) '#' ~('\n'|'\r')* {$channel=HIDDEN;}
;
//Bash "reserved words"
BANG : '!';
@@ -646,8 +725,9 @@ SEMIC : ';';
DOUBLE_SEMIC
: ';;';
PIPE : '|';
-DQUOTE : '"';
-SQUOTE : '\'';
+DQUOTE : '"' { double_quoted = !double_quoted; };
+SQUOTE : { double_quoted }? => '\'';
+SINGLE_QUOTED_STRING_TOKEN : { !double_quoted }? => '\'' .* '\'';
COMMA : ',';
//Because bash isn't exactly whitespace dependent... need to explicitly handle blanks
BLANK : (' '|'\t')+;
diff --git a/bashast/features_script/features.sh.ast b/bashast/features_script/features.sh.ast
index 4191c85..ad37b9c 100644
--- a/bashast/features_script/features.sh.ast
+++ b/bashast/features_script/features.sh.ast
@@ -1 +1 @@
-(LIST (COMMAND (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING $ failedtests))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests))))))) (COMMAND (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMMAND (ARITHMETIC_EXPRESSION (* 5 4))) (COMMAND (ARITHMETIC_EXPRESSION (** 5 4))) (COMMAND (ARITHMETIC_EXPRESSION (+ (VAR_REF failedtests) (/ 5 4)))) (COMMAND (ARITHMETIC_EXPRESSION (+ (VAR_REF z) (MINUS_SIGN 3)))))))) (COMMAND (function (STRING arrays) (SUBSHELL (LIST (COMMAND (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (COMMAND (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d))))) (COMMAND (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3)))) (COMMAND (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING (BRACE_EXP (STRING a) (STRING b))) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (COMMAND (case (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf))))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))) (COMMAND (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each))))) (COMMAND (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1)))) (COMMAND (select each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null)))))) (COMMAND (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))))) (COMMAND (until (LIST (COMMAND (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile)))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile))))) (COMMAND (while (LIST (COMMAND (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))) (COMMAND (IF_STATEMENT (if (LIST (COMMAND (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (COMMAND (VARIABLE_DEFINITIONS (= asdf (STRING parameters)))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (COMMAND (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
+(LIST (COMMAND (function (STRING lots_o_echo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING The number of tests that have failed : (VAR_REF failedtests)))) (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING '$failedtests'))) (COMMAND (STRING echo) (STRING (VAR_REF failedtests))))))) (COMMAND (function (STRING do_some_arith) (CURRENT_SHELL (LIST (COMMAND (ARITHMETIC_EXPRESSION (* 5 4))) (COMMAND (ARITHMETIC_EXPRESSION (** 5 4))) (COMMAND (ARITHMETIC_EXPRESSION (+ (VAR_REF failedtests) (/ 5 4)))) (COMMAND (ARITHMETIC_EXPRESSION (+ (VAR_REF z) (MINUS_SIGN 3)))))))) (COMMAND (function (STRING arrays) (SUBSHELL (LIST (COMMAND (VARIABLE_DEFINITIONS (= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d))))) (COMMAND (STRING echo) (STRING (VAR_REF (asdf 3)))) (COMMAND (VARIABLE_DEFINITIONS (= foo (ARRAY (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING 6))))) (STRING b) (STRING c) (STRING d))))) (COMMAND (VARIABLE_DEFINITIONS (= (arr (VAR_REF foo)) (STRING 3)))) (COMMAND (VARIABLE_DEFINITIONS (= bar (ARRAY (STRING a) (STRING b) (= 5 (STRING c)))))))))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING a) (STRING b)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (.. a d)))) (COMMAND (STRING echo) (STRING (BRACE_EXP (STRING (BRACE_EXP (STRING a) (STRING b))) (STRING c) (STRING d)))) (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c)))) (COMMAND (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING foobar)))))) (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING gunit) (REDIR >> (STRING filelist)))) (COMMAND (case (STRING (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING asdf))))) (CASE_PATTERN (STRING gz) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING yay)))) (CASE_PATTERN (STRING bzip) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING three)))) (CASE_PATTERN (STRING MATCH_ALL) CASE_COMMAND (LIST (COMMAND (STRING echo) (STRING woo)))))) (COMMAND (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (VAR_REF each))) (COMMAND (STRING cat) (STRING each))))) (COMMAND (CFOR (FOR_INIT (+ 5 3)) (FOR_COND (+ 6 2)) (LIST (COMMAND (STRING echo) (STRING yay))) (FOR_MOD (+ 3 1)))) (COMMAND (select each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING output)))))) (LIST (COMMAND (STRING echo) (STRING asdf) (STRING 2) (REDIR > (STRING / dev / null)))))) (COMMAND (IF_STATEMENT (if (LIST (COMMAND (STRING echo) (STRING yay2))) (LIST (COMMAND (STRING echo) (STRING yay)))))) (COMMAND (until (LIST (COMMAND (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile)))))) (LIST (COMMAND (STRING touch) (STRING this / is . afile))))) (COMMAND (while (LIST (COMMAND (COMPOUND_COND (BUILTIN_TEST (n (STRING foobar)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))) (COMMAND (IF_STATEMENT (if (LIST (COMMAND (COMPOUND_COND (BUILTIN_TEST (eq (STRING 5) (STRING 6)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING something ' s wrong))))))) (COMMAND (STRING echo) (STRING this) (STRING command) (STRING has) (STRING multiple) (STRING arguments)) (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words))))) (|| (&& (&& (&& (COMMAND (STRING cd) (STRING build)) (COMMAND (STRING . / configure))) (COMMAND (STRING make))) (COMMAND (STRING make_install))) (COMMAND (STRING echo) (STRING fail))) (COMMAND (STRING cd) (STRING / usr / bin)) (| (COMMAND (STRING ls) (STRING - al)) (COMMAND (STRING grep) (STRING more))) (COMMAND (VARIABLE_DEFINITIONS (= asdf (STRING parameters)))) (COMMAND (STRING (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))))) (COMMAND (STRING (VAR_REF (OFFSET asdf 8)))) (COMMAND (STRING (VAR_REF (! asdf *)))) (COMMAND (STRING (VAR_REF (! asdf @)))) (COMMAND (STRING (VAR_REF (# foo)))) (COMMAND (STRING (VAR_REF (REPLACE_FIRST replaice (STRING with) (STRING pattern))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF (LAZY_REMOVE_AT_END asdf (STRING bar))))) (COMMAND (STRING (VAR_REF 1)) (STRING (VAR_REF @)) (STRING (VAR_REF *))) (COMMAND (STRING (VAR_REF ?))) (COMMAND (STRING (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))))) (COMMAND (STRING (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))))) (COMMAND (VARIABLE_DEFINITIONS (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))))) (| (COMMAND (STRING cat) (STRING asdf)) (COMMAND (STRING grep) (STRING three) (STRING 2) (REDIR >& (FILE_DESCRIPTOR 1)) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING asdf) (REDIR >> (STRING APPEND))) (COMMAND (STRING echo) (STRING cat) (<<< (STRING word))))
diff --git a/bashast/features_script/features.sh.tokens b/bashast/features_script/features.sh.tokens
index 797f232..104a000 100644
--- a/bashast/features_script/features.sh.tokens
+++ b/bashast/features_script/features.sh.tokens
@@ -24,7 +24,7 @@
24 COMMENTEOL
25 FUNCTION BLANK NAME LPAREN RPAREN BLANK LBRACE EOL
26 BLANK NAME BLANK DQUOTE NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME COLON BLANK DOLLAR NAME DQUOTE EOL
-27 BLANK NAME BLANK SQUOTE DOLLAR NAME SQUOTE EOL
+27 BLANK NAME BLANK SINGLE_QUOTED_STRING_TOKEN EOL
28 BLANK NAME BLANK DOLLAR NAME EOL
29 RBRACE EOL
30
diff --git a/bashast/features_script/features.sh.walker.tokens b/bashast/features_script/features.sh.walker.tokens
index 255caa7..14b0536 100644
--- a/bashast/features_script/features.sh.walker.tokens
+++ b/bashast/features_script/features.sh.walker.tokens
@@ -1,2 +1,2 @@
-LIST DOWN COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP CURRENT_SHELL DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME COLON BLANK VAR_REF DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN SINGLE_QUOTED_STRING DOWN DOLLAR NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME UP UP UP UP UP UP UP COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP CURRENT_SHELL DOWN LIST DOWN COMMAND DOWN ARITHMETIC_EXPRESSION DOWN TIMES DOWN DIGIT DIGIT UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN EXP DOWN DIGIT DIGIT UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN PLUS DOWN VAR_REF DOWN NAME UP SLASH DOWN DIGIT DIGIT UP UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN PLUS DOWN VAR_REF DOWN LETTER UP MINUS_SIGN DOWN DIGIT UP UP UP UP UP UP UP UP COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP SUBSHELL DOWN LIST DOWN COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME DOWN DIGIT UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DIGIT UP UP UP UP UP STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME DOWN VAR_REF DOWN NAME UP UP STRING DOWN DIGIT UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP EQUALS DOWN DIGIT STRING DOWN LETTER UP UP UP UP UP UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN DOTDOT DOWN LETTER LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN STRING DOWN BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN LETTER BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP REDIR DOWN OP STRING DOWN NAME UP UP UP UP COMMAND DOWN CASE DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP CASE_PATTERN DOWN STRING DOWN NAME UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP CASE_PATTERN DOWN STRING DOWN NAME UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP CASE_PATTERN DOWN STRING DOWN MATCH_ALL UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP COMMAND DOWN FOR DOWN NAME STRING DOWN COMMAND_SUB DOWN LIST DOWN PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN CFOR DOWN FOR_INIT DOWN PLUS DOWN DIGIT DIGIT UP UP FOR_COND DOWN PLUS DOWN DIGIT DIGIT UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP FOR_MOD DOWN PLUS DOWN DIGIT DIGIT UP UP UP UP COMMAND DOWN SELECT DOWN NAME STRING DOWN COMMAND_SUB DOWN LIST DOWN PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN DIGIT UP REDIR DOWN GREATER_THAN STRING DOWN SLASH NAME SLASH NAME UP UP UP UP UP UP COMMAND DOWN IF_STATEMENT DOWN IF DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP COMMAND DOWN UNTIL DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN KEYWORD_TEST DOWN LETTER DOWN STRING DOWN NAME SLASH NAME DOT NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME SLASH NAME DOT NAME UP UP UP UP UP COMMAND DOWN WHILE DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN BUILTIN_TEST DOWN LETTER DOWN STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME BLANK NAME UP UP UP UP UP UP COMMAND DOWN IF_STATEMENT DOWN IF DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN BUILTIN_TEST DOWN NAME DOWN STRING DOWN DIGIT UP STRING DOWN DIGIT UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME SQUOTE LETTER BLANK NAME UP UP UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP PROCESS_SUBSTITUTION DOWN LESS_THAN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN SLASH NAME SLASH NAME SLASH NAME SLASH NAME DOT NAME UP UP UP UP UP LOGICOR DOWN LOGICAND DOWN LOGICAND DOWN LOGICAND DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN DOT SLASH NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN SLASH NAME SLASH NAME UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN MINUS NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME STRING DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN USE_DEFAULT_WHEN_UNSET_OR_NULL DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN OFFSET DOWN NAME DIGIT UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN BANG DOWN NAME TIMES UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN BANG DOWN NAME AT UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN POUND DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_FIRST DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_START DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_START DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_END DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_END DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN DIGIT UP UP STRING DOWN VAR_REF DOWN AT UP UP STRING DOWN VAR_REF DOWN TIMES UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN QMARK UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_ALL DOWN NAME STRING DOWN DOT UP STRING DOWN UNDERSCORE UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_START DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_END DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME STRING DOWN VAR_REF DOWN REPLACE_FIRST DOWN NAME STRING DOWN NAME MINUS UP UP UP UP UP UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN DIGIT UP REDIR DOWN OP FILE_DESCRIPTOR DOWN DIGIT UP UP REDIR DOWN GREATER_THAN STRING DOWN SLASH NAME SLASH NAME UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP REDIR DOWN OP STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP HERE_STRING_OP DOWN STRING DOWN NAME UP UP UP UP
+LIST DOWN COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP CURRENT_SHELL DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME BLANK NAME COLON BLANK VAR_REF DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN SINGLE_QUOTED_STRING DOWN SINGLE_QUOTED_STRING_TOKEN UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME UP UP UP UP UP UP UP COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP CURRENT_SHELL DOWN LIST DOWN COMMAND DOWN ARITHMETIC_EXPRESSION DOWN TIMES DOWN DIGIT DIGIT UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN EXP DOWN DIGIT DIGIT UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN PLUS DOWN VAR_REF DOWN NAME UP SLASH DOWN DIGIT DIGIT UP UP UP UP COMMAND DOWN ARITHMETIC_EXPRESSION DOWN PLUS DOWN VAR_REF DOWN LETTER UP MINUS_SIGN DOWN DIGIT UP UP UP UP UP UP UP UP COMMAND DOWN FUNCTION DOWN STRING DOWN NAME UP SUBSHELL DOWN LIST DOWN COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME DOWN DIGIT UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DIGIT UP UP UP UP UP STRING DOWN LETTER UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME DOWN VAR_REF DOWN NAME UP UP STRING DOWN DIGIT UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME ARRAY DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP EQUALS DOWN DIGIT STRING DOWN LETTER UP UP UP UP UP UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN DOTDOT DOWN LETTER LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN BRACE_EXP DOWN STRING DOWN BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN LETTER BRACE_EXP DOWN STRING DOWN LETTER UP STRING DOWN LETTER UP UP UP UP COMMAND DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP REDIR DOWN OP STRING DOWN NAME UP UP UP UP COMMAND DOWN CASE DOWN STRING DOWN COMMAND_SUB DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP CASE_PATTERN DOWN STRING DOWN NAME UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP CASE_PATTERN DOWN STRING DOWN NAME UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP CASE_PATTERN DOWN STRING DOWN MATCH_ALL UP CASE_COMMAND LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP COMMAND DOWN FOR DOWN NAME STRING DOWN COMMAND_SUB DOWN LIST DOWN PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN VAR_REF DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN CFOR DOWN FOR_INIT DOWN PLUS DOWN DIGIT DIGIT UP UP FOR_COND DOWN PLUS DOWN DIGIT DIGIT UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP FOR_MOD DOWN PLUS DOWN DIGIT DIGIT UP UP UP UP COMMAND DOWN SELECT DOWN NAME STRING DOWN COMMAND_SUB DOWN LIST DOWN PIPE DOWN COMMAND DOWN STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN DIGIT UP REDIR DOWN GREATER_THAN STRING DOWN SLASH NAME SLASH NAME UP UP UP UP UP UP COMMAND DOWN IF_STATEMENT DOWN IF DOWN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP UP COMMAND DOWN UNTIL DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN KEYWORD_TEST DOWN LETTER DOWN STRING DOWN NAME SLASH NAME DOT NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME SLASH NAME DOT NAME UP UP UP UP UP COMMAND DOWN WHILE DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN BUILTIN_TEST DOWN LETTER DOWN STRING DOWN NAME UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME BLANK NAME UP UP UP UP UP UP COMMAND DOWN IF_STATEMENT DOWN IF DOWN LIST DOWN COMMAND DOWN COMPOUND_COND DOWN BUILTIN_TEST DOWN NAME DOWN STRING DOWN DIGIT UP STRING DOWN DIGIT UP UP UP UP UP UP LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN DOUBLE_QUOTED_STRING DOWN NAME SQUOTE LETTER BLANK NAME UP UP UP UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP PROCESS_SUBSTITUTION DOWN LESS_THAN LIST DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN SLASH NAME SLASH NAME SLASH NAME SLASH NAME DOT NAME UP UP UP UP UP LOGICOR DOWN LOGICAND DOWN LOGICAND DOWN LOGICAND DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN DOT SLASH NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN SLASH NAME SLASH NAME UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN MINUS NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME STRING DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN USE_DEFAULT_WHEN_UNSET_OR_NULL DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN OFFSET DOWN NAME DIGIT UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN BANG DOWN NAME TIMES UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN BANG DOWN NAME AT UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN POUND DOWN NAME UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_FIRST DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_START DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_START DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_END DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN LAZY_REMOVE_AT_END DOWN NAME STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN DIGIT UP UP STRING DOWN VAR_REF DOWN AT UP UP STRING DOWN VAR_REF DOWN TIMES UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN QMARK UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_ALL DOWN NAME STRING DOWN DOT UP STRING DOWN UNDERSCORE UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_START DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN STRING DOWN VAR_REF DOWN REPLACE_AT_END DOWN NAME STRING DOWN NAME UP STRING DOWN NAME UP UP UP UP UP COMMAND DOWN VARIABLE_DEFINITIONS DOWN EQUALS DOWN NAME STRING DOWN VAR_REF DOWN REPLACE_FIRST DOWN NAME STRING DOWN NAME MINUS UP UP UP UP UP UP UP PIPE DOWN COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP STRING DOWN DIGIT UP REDIR DOWN OP FILE_DESCRIPTOR DOWN DIGIT UP UP REDIR DOWN GREATER_THAN STRING DOWN SLASH NAME SLASH NAME UP UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP REDIR DOWN OP STRING DOWN NAME UP UP UP COMMAND DOWN STRING DOWN NAME UP STRING DOWN NAME UP HERE_STRING_OP DOWN STRING DOWN NAME UP UP UP UP
diff --git a/bashast/gunit/arith_main.gunit b/bashast/gunit/arith_main.gunit
index 2a440fc..38c8e2e 100644
--- a/bashast/gunit/arith_main.gunit
+++ b/bashast/gunit/arith_main.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
//for this set of unittests, we'll start from the
//top of the order of ops
diff --git a/bashast/gunit/array.gunit b/bashast/gunit/array.gunit
index 3a15c20..ce0b344 100644
--- a/bashast/gunit/array.gunit
+++ b/bashast/gunit/array.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
var_def:
"asdf=(a b c d)"->(= asdf (ARRAY (STRING a) (STRING b) (STRING c) (STRING d)))
diff --git a/bashast/gunit/assoc_array.gunit b/bashast/gunit/assoc_array.gunit
index a3d1508..3bdca9a 100644
--- a/bashast/gunit/assoc_array.gunit
+++ b/bashast/gunit/assoc_array.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
var_def:
"arr[foo]=\"asdf\"" -> (= (arr (VAR_REF foo)) (STRING (DOUBLE_QUOTED_STRING asdf)))
diff --git a/bashast/gunit/brace.gunit b/bashast/gunit/brace.gunit
index bafb624..5d33d83 100644
--- a/bashast/gunit/brace.gunit
+++ b/bashast/gunit/brace.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
brace_expansion:
"{a,b}"-> (BRACE_EXP (STRING a) (STRING b))
diff --git a/bashast/gunit/command_sub.gunit b/bashast/gunit/command_sub.gunit
index 83f4026..e2d0021 100644
--- a/bashast/gunit/command_sub.gunit
+++ b/bashast/gunit/command_sub.gunit
@@ -16,11 +16,11 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
command_sub:
"$(echo \"foo\")" -> (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING foo)))))
"$(ls |grep file)" -> (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING file)))))
"$(CONTROL= command arg )" -> (COMMAND_SUB (LIST (COMMAND (STRING command) (STRING arg) (= CONTROL))))
"`cat output.log |grep error|cut`" -> (COMMAND_SUB (LIST (| (| (COMMAND (STRING cat) (STRING output . log)) (COMMAND (STRING grep) (STRING error))) (COMMAND (STRING cut)))))
-"$(function foo() { echo 'hello'; }; foo)" -> (COMMAND_SUB (LIST (COMMAND (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING hello))))))) (COMMAND (STRING foo))))
+"$(function foo() { echo 'hello'; }; foo)" -> (COMMAND_SUB (LIST (COMMAND (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING 'hello'))))))) (COMMAND (STRING foo))))
diff --git a/bashast/gunit/comment.gunit b/bashast/gunit/comment.gunit
index cf955a4..5245b93 100644
--- a/bashast/gunit/comment.gunit
+++ b/bashast/gunit/comment.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
start:
"./hello #comment" -> (LIST (COMMAND (STRING . / hello)))
diff --git a/bashast/gunit/compound.gunit b/bashast/gunit/compound.gunit
index f4ca4e1..5e2a098 100644
--- a/bashast/gunit/compound.gunit
+++ b/bashast/gunit/compound.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
cond_comparison:
"[[ -a this/is.afile ]]" -> (COMPOUND_COND (KEYWORD_TEST (a (STRING this / is . afile))))
@@ -85,7 +85,7 @@ for_expr:
echo \"file found\"
done" -> (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
"for each in `ls |grep log`; do echo \"file found\"; done" -> (for each (STRING (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING log)))))) (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING file found)))))
-"for i in 'foo' 'bar'; do echo $i; done" -> (for i (STRING (SINGLE_QUOTED_STRING foo)) (STRING (SINGLE_QUOTED_STRING bar)) (LIST (COMMAND (STRING echo) (STRING (VAR_REF i)))))
+"for i in 'foo' 'bar'; do echo $i; done" -> (for i (STRING (SINGLE_QUOTED_STRING 'foo')) (STRING (SINGLE_QUOTED_STRING 'bar')) (LIST (COMMAND (STRING echo) (STRING (VAR_REF i)))))
"for i in foo$var bar; do echo $i; done" -> (for i (STRING foo (VAR_REF var)) (STRING bar) (LIST (COMMAND (STRING echo) (STRING (VAR_REF i)))))
"for each in `ls |grep log`; do echo file done" FAIL
diff --git a/bashast/gunit/cond_main.gunit b/bashast/gunit/cond_main.gunit
index a17ae1e..943fd9d 100644
--- a/bashast/gunit/cond_main.gunit
+++ b/bashast/gunit/cond_main.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
cond_expr:
"[[ -a this/is.afile ]]" -> (KEYWORD_TEST (a (STRING this / is . afile)))
diff --git a/bashast/gunit/continued_lines.gunit b/bashast/gunit/continued_lines.gunit
index 96f6ee4..4be7059 100644
--- a/bashast/gunit/continued_lines.gunit
+++ b/bashast/gunit/continued_lines.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
start:
@@ -26,4 +26,5 @@ o Hello\
"sed -i \
-e 's/three/\
- four/'" -> (LIST (COMMAND (STRING sed) (STRING - i) (STRING - e) (STRING (SINGLE_QUOTED_STRING s / three / four /))))
+ four/'" -> (LIST (COMMAND (STRING sed) (STRING - i) (STRING - e) (STRING (SINGLE_QUOTED_STRING 's/three/\
+ four/'))))
diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gunit
index 20c54f1..a36d4da 100644
--- a/bashast/gunit/expansions.gunit
+++ b/bashast/gunit/expansions.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
clist:
"echo a{b,c,d}" -> (LIST (COMMAND (STRING echo) (STRING a (BRACE_EXP (STRING b) (STRING c) (STRING d)))))
diff --git a/bashast/gunit/fname.gunit b/bashast/gunit/fname.gunit
index 4627b46..fce198f 100644
--- a/bashast/gunit/fname.gunit
+++ b/bashast/gunit/fname.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
fname:
"+%Y%m%d" -> (STRING + % Y % m % d)
@@ -27,13 +27,13 @@ fname:
"\"asdf;!\"" -> (STRING (DOUBLE_QUOTED_STRING asdf ; !))
"\"$(whoami)\"" -> (STRING (DOUBLE_QUOTED_STRING (COMMAND_SUB (LIST (COMMAND (STRING whoami))))))
"\"`whoami`\"" -> (STRING (DOUBLE_QUOTED_STRING (COMMAND_SUB (LIST (COMMAND (STRING whoami))))))
-"'`whoami`'" -> (STRING (SINGLE_QUOTED_STRING ` whoami `))
-"'$(whoami)'" -> (STRING (SINGLE_QUOTED_STRING $ ( whoami )))
+"'`whoami`'" -> (STRING (SINGLE_QUOTED_STRING '`whoami`'))
+"'$(whoami)'" -> (STRING (SINGLE_QUOTED_STRING '$(whoami)'))
"\"${P}\"" -> (STRING (DOUBLE_QUOTED_STRING (VAR_REF P)))
-"'${P}'" -> (STRING (SINGLE_QUOTED_STRING $ { P }))
+"'${P}'" -> (STRING (SINGLE_QUOTED_STRING '${P}'))
"asdf#" -> (STRING asdf #)
-"'asdf'" -> (STRING (SINGLE_QUOTED_STRING asdf))
-"'asdf\"asdf'" -> (STRING (SINGLE_QUOTED_STRING asdf " asdf))
+"'asdf'" -> (STRING (SINGLE_QUOTED_STRING 'asdf'))
+"'asdf\"asdf'" -> (STRING (SINGLE_QUOTED_STRING 'asdf"asdf'))
"\"asdf'asdf\"" -> (STRING (DOUBLE_QUOTED_STRING asdf ' asdf))
"!/bin/bash" -> (STRING ! / bin / bash)
"ab?(g|h)"-> (STRING ab (EXTENDED_MATCH_AT_MOST_ONE (STRING g) (STRING h)))
@@ -41,7 +41,7 @@ fname:
"ab+(gh|i)" -> (STRING ab (EXTENDED_MATCH_AT_LEAST_ONE (STRING gh) (STRING i)))
"ab@(gh|i)" -> (STRING ab (EXTENDED_MATCH_EXACTLY_ONE (STRING gh) (STRING i)))
"ab!(gh|i)" -> (STRING ab (EXTENDED_MATCH_NONE (STRING gh) (STRING i)))
-"\"abc\"\'\"\'\"def\"" -> (STRING (DOUBLE_QUOTED_STRING abc) (SINGLE_QUOTED_STRING ") (DOUBLE_QUOTED_STRING def))
+"\"abc\"\'\"\'\"def\"" -> (STRING (DOUBLE_QUOTED_STRING abc) (SINGLE_QUOTED_STRING '"') (DOUBLE_QUOTED_STRING def))
"my\ name\ is" -> (STRING my \ name \ is)
"octal\007" -> (STRING octal \ 007)
"hex\xaF" -> (STRING hex \ xaF)
diff --git a/bashast/gunit/function.gunit b/bashast/gunit/function.gunit
index 55decb2..a046bd1 100644
--- a/bashast/gunit/function.gunit
+++ b/bashast/gunit/function.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
function:
"function quit {
diff --git a/bashast/gunit/list.gunit b/bashast/gunit/list.gunit
index 354fc1e..552788a 100644
--- a/bashast/gunit/list.gunit
+++ b/bashast/gunit/list.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
start:
"make" -> (LIST (COMMAND (STRING make)))
@@ -38,7 +38,7 @@ cp arch/x86_64/boot/bzImage /boot/kernel" -> (LIST (COMMAND (STRING make)) (COMM
b=three
echo \"a b\"" -> (LIST (COMMAND (VARIABLE_DEFINITIONS (= a (STRING asdf)))) (COMMAND (VARIABLE_DEFINITIONS (= b (STRING three)))) (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING a b))))
"echo one && (echo two || echo three)" -> (LIST (&& (COMMAND (STRING echo) (STRING one)) (COMMAND (SUBSHELL (LIST (|| (COMMAND (STRING echo) (STRING two)) (COMMAND (STRING echo) (STRING three))))))))
-"FOO='bar' ;" -> (LIST (COMMAND (VARIABLE_DEFINITIONS (= FOO (STRING (SINGLE_QUOTED_STRING bar))))))
+"FOO='bar' ;" -> (LIST (COMMAND (VARIABLE_DEFINITIONS (= FOO (STRING (SINGLE_QUOTED_STRING 'bar'))))))
"true;
true" -> (LIST (COMMAND (STRING true)) (COMMAND (STRING true)))
"(echo hi > /dev/null) >> 1" -> (LIST (COMMAND (SUBSHELL (LIST (COMMAND (STRING echo) (STRING hi) (REDIR > (STRING / dev / null))))) (REDIR >> (FILE_DESCRIPTOR 1))))
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit
index 67b26cf..9dfcd9e 100644
--- a/bashast/gunit/param_main.gunit
+++ b/bashast/gunit/param_main.gunit
@@ -16,14 +16,14 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
var_ref:
"$asdf" -> (VAR_REF asdf)
"${asdf}" -> (VAR_REF asdf)
"${asdf:-foo}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo)))
"${asdf:-public_html}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING public_html)))
-"${asdf='foo'}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET asdf (STRING (SINGLE_QUOTED_STRING foo))))
+"${asdf='foo'}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET asdf (STRING (SINGLE_QUOTED_STRING 'foo'))))
"${asdf:=}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET_OR_NULL asdf STRING))
"${bar:7}" -> (VAR_REF (OFFSET bar 7))
"${bar: -10}" -> (VAR_REF (OFFSET bar (MINUS_SIGN 10)))
diff --git a/bashast/gunit/pipeline.gunit b/bashast/gunit/pipeline.gunit
index 3a0af5b..ec6deda 100644
--- a/bashast/gunit/pipeline.gunit
+++ b/bashast/gunit/pipeline.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
pipeline:
"cat asdf" -> (COMMAND (STRING cat) (STRING asdf))
diff --git a/bashast/gunit/process_substitution.gunit b/bashast/gunit/process_substitution.gunit
index 0c2aa70..b0d2754 100644
--- a/bashast/gunit/process_substitution.gunit
+++ b/bashast/gunit/process_substitution.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
process_substitution:
"<( true )" -> (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING true))))
diff --git a/bashast/gunit/redir.gunit b/bashast/gunit/redir.gunit
index 5b0a0c7..bb1c24a 100644
--- a/bashast/gunit/redir.gunit
+++ b/bashast/gunit/redir.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
redirect:
">output_file" -> (REDIR > (STRING output_file))
@@ -30,9 +30,9 @@ redirect:
"2<&0" -> (REDIR 2 <& (FILE_DESCRIPTOR 0))
"<< asdf
asdf
-" -> (<< (STRING asdf) (STRING asdf))
+" -> (<< (STRING asdf))
"<<< herestring" -> (<<< (STRING herestring))
"<< blue
red
green
-" -> (<< (STRING blue) (STRING red) (STRING green))
+" -> (<< (STRING red green))
diff --git a/bashast/gunit/simp_command.gunit b/bashast/gunit/simp_command.gunit
index 76af49b..db26ab4 100644
--- a/bashast/gunit/simp_command.gunit
+++ b/bashast/gunit/simp_command.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
simple_command:
"./command" -> (STRING . / command)
@@ -29,6 +29,7 @@ simple_command:
"dodir ${foo}/${bar}" -> (STRING dodir) (STRING (VAR_REF foo) / (VAR_REF bar))
"local a=123 b=(1 2 3) c" -> (VARIABLE_DEFINITIONS local (= a (STRING 123)) (= b (ARRAY (STRING 1) (STRING 2) (STRING 3))) (EQUALS c))
"echo {}{}}{{{}}{{}" -> (STRING echo) (STRING { } { } } { { { } } { { })
+"echo \"ab#af ###\" #abc" -> (STRING echo) (STRING (DOUBLE_QUOTED_STRING ab # af ## #))
command:
"asdf=5 cat out.log > result" -> (COMMAND (STRING cat) (STRING out . log) (= asdf (STRING 5)) (REDIR > (STRING result)))
diff --git a/bashast/gunit/simp_prog.gunit b/bashast/gunit/simp_prog.gunit
index 9a1d88e..64aa001 100644
--- a/bashast/gunit/simp_prog.gunit
+++ b/bashast/gunit/simp_prog.gunit
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with libbash. If not, see <http://www.gnu.org/licenses/>.
*/
-gunit bashast;
+gunit java_libbash;
start:
"echo \"finding file\"
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 7121afa..1483e0c 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -266,11 +266,11 @@ string_part returns[std::string libbash_value, bool quoted, bool is_raw_string]
$libbash_value += libbash_string;
$quoted = true;
})*)
- |(SINGLE_QUOTED_STRING) =>
- ^(SINGLE_QUOTED_STRING (libbash_string=any_string {
- $libbash_value += libbash_string;
- $quoted = true;
- })*)
+ |(SINGLE_QUOTED_STRING) => ^(SINGLE_QUOTED_STRING node=SINGLE_QUOTED_STRING_TOKEN) {
+ pANTLR3_COMMON_TOKEN token = node->getToken(node);
+ $libbash_value = std::string(reinterpret_cast<const char *>(token->start + 1),
+ boost::numeric_cast<unsigned>(token->stop - token->start - 1));
+ }
|(ARITHMETIC_EXPRESSION) =>
^(ARITHMETIC_EXPRESSION value=arithmetics {
$libbash_value = boost::lexical_cast<std::string>(value);
diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash
index d485d57..76e9c4c 100644
--- a/scripts/command_execution.bash
+++ b/scripts/command_execution.bash
@@ -56,3 +56,4 @@ shopt -p
printf "%s %s\n" abc def
printf "%s %s\n" $FOO001, def
((FOO010=1))
+echo "abc #av### ##" # for comment
diff --git a/scripts/command_execution.bash.result b/scripts/command_execution.bash.result
index 280798b..5f9bede 100644
--- a/scripts/command_execution.bash.result
+++ b/scripts/command_execution.bash.result
@@ -55,6 +55,7 @@ shopt -u sourcepath
shopt -u xpg_echo
abc def
hello, def
+abc #av### ##
DEFAULTED=yes
FOO001=hello
FOO002=Hello World
diff --git a/scripts/here_document.ast b/scripts/here_document.ast
new file mode 100644
index 0000000..ca0781c
--- /dev/null
+++ b/scripts/here_document.ast
@@ -0,0 +1,3 @@
+(LIST (COMMAND (STRING cat) (<< (STRING blah
+ blah
+) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING hi)))
diff --git a/scripts/here_document.sh b/scripts/here_document.sh
new file mode 100644
index 0000000..2cc15d4
--- /dev/null
+++ b/scripts/here_document.sh
@@ -0,0 +1,5 @@
+cat<< _EOF_.abc >/dev/null
+blah
+blah
+_EOF_.abc
+echo hi
diff --git a/test/post_check.cpp b/test/post_check.cpp
index 2a411f8..715ccf5 100644
--- a/test/post_check.cpp
+++ b/test/post_check.cpp
@@ -35,12 +35,12 @@ static void check_file_size(const char *path, uintmax_t size_max)
TEST(post_check, lexer_size)
{
- check_file_size("libbashLexer.c", 512 * 1024);
+ check_file_size("libbashLexer.cpp", 1024 * 1024);
}
TEST(post_check, parser_size)
{
- check_file_size("libbashParser.c", 3*1024*1024);
+ check_file_size("libbashParser.cpp", 3*1024*1024);
}
TEST(post_check, walker_size)
diff --git a/test/verify_here_document.sh b/test/verify_here_document.sh
new file mode 100755
index 0000000..5fff5f7
--- /dev/null
+++ b/test/verify_here_document.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+./ast_printer -f $srcdir/scripts/here_document.sh | diff -u $srcdir/scripts/here_document.ast -