diff options
author | Adrian Thurston <thurston@complang.org> | 2012-05-20 11:35:49 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2012-05-20 11:35:49 -0400 |
commit | b5bedab8125194f9c359c29ad50b51799d932a56 (patch) | |
tree | 7b4c962ca6e11f2a0c085a9080427b7e8aa7a4d0 | |
parent | 69d905340017bcf3642d21d005ff88a2e8ff84c4 (diff) | |
download | colm-b5bedab8125194f9c359c29ad50b51799d932a56.tar.gz |
added two test cases causing segfaults
-rw-r--r-- | test/Makefile.am | 12 | ||||
-rw-r--r-- | test/TESTS | 2 | ||||
-rw-r--r-- | test/concat1.exp | 0 | ||||
-rw-r--r-- | test/concat1.in | 6 | ||||
-rw-r--r-- | test/concat1.lm | 96 | ||||
-rw-r--r-- | test/concat2.exp | 0 | ||||
-rw-r--r-- | test/concat2.in | 4 | ||||
-rw-r--r-- | test/concat2.lm | 96 | ||||
-rwxr-xr-x | test/runtests.mk | 24 |
9 files changed, 235 insertions, 5 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 271cc698..89b43397 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -73,7 +73,9 @@ TEST_CASES = \ lhs1.lm \ rhsref1.lm \ order1.lm \ - order2.lm + order2.lm \ + concat1.lm \ + concat2.lm INPUT = \ ambig1.in \ @@ -135,7 +137,9 @@ INPUT = \ lhs1.in \ rhsref1.in \ order1.in \ - order2.in + order2.in \ + concat1.in \ + concat2.in EXPECTED_OUTPUT = \ ambig1.exp \ @@ -210,6 +214,8 @@ EXPECTED_OUTPUT = \ lhs1.exp \ rhsref1.exp \ order1.exp \ - order2.exp + order2.exp \ + concat1.in \ + concat2.in EXTRA_DIST = genmf TESTS runtests.mk $(TEST_CASES) $(INPUT) $(EXPECTED_OUTPUT) @@ -76,4 +76,6 @@ TESTS=" rhsref1.lm order1.lm order2.lm + concat1.lm + concat2.lm " diff --git a/test/concat1.exp b/test/concat1.exp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/concat1.exp diff --git a/test/concat1.in b/test/concat1.in new file mode 100644 index 00000000..9d02b37e --- /dev/null +++ b/test/concat1.in @@ -0,0 +1,6 @@ + +%% + +type foo + +include smtp.vpt diff --git a/test/concat1.lm b/test/concat1.lm new file mode 100644 index 00000000..dcc5b2fa --- /dev/null +++ b/test/concat1.lm @@ -0,0 +1,96 @@ + +lex start +{ + + literal 'type', 'include' + token id /[A-Za-z_][A-Za-z_0-9]*/ + ignore /'#' [^\n]* '\n'/ + ignore /[ \t\r\n]+/ +} + +lex include_file_name +{ + token ifn_part /[a-zA-Z0-9_.\-]+/ + token ifn_slash /'/'/ +} + +def ifn_path_part + [ifn_part] +| [ifn_slash] + +def ifn_path + [ifn_path_part ifn_path] +| [ifn_path_part] + + +literal '%%' + +lex embedded +{ + token em_ws /( any - 33..126 )+/ +} + +def em_item + [em_ws] + +def prelude + [em_item* '%%'] + +def item + ['include' ifn_path] +| ['type' id] + +def start + [prelude item*] + +start parseStart( InputFile: stream ) +{ + return parse start( InputFile ) +} + +start parseTxt( T: str ) +{ + cons a: accum<start>[] + send a [T + ] + return a.finish() +} + +item* concatItems( IL1: item* IL2: item* ) +{ + for IL: item* in IL1 { + if match IL [] { + IL = IL2 + break + } + } + return IL1 +} + +item* expandIncludes( ItemList: ref item* ) +{ + for IL: item* in ItemList { + if match IL + ['include' FN: ifn_path Rest: item*] + { + S: start = parseTxt( + " + "%% + " + ) + + match S [em_item* '%%' IncludedItems: item*] + + IL = concatItems( IncludedItems Rest ) + } + } +} + +int main() +{ + S: start = parseStart(stdin) + match S [em_item* '%%' ItemList: item*] + expandIncludes( ItemList ) +} + +main() diff --git a/test/concat2.exp b/test/concat2.exp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/concat2.exp diff --git a/test/concat2.in b/test/concat2.in new file mode 100644 index 00000000..32195f5d --- /dev/null +++ b/test/concat2.in @@ -0,0 +1,4 @@ + +%% + +include smtp.vpt diff --git a/test/concat2.lm b/test/concat2.lm new file mode 100644 index 00000000..dcc5b2fa --- /dev/null +++ b/test/concat2.lm @@ -0,0 +1,96 @@ + +lex start +{ + + literal 'type', 'include' + token id /[A-Za-z_][A-Za-z_0-9]*/ + ignore /'#' [^\n]* '\n'/ + ignore /[ \t\r\n]+/ +} + +lex include_file_name +{ + token ifn_part /[a-zA-Z0-9_.\-]+/ + token ifn_slash /'/'/ +} + +def ifn_path_part + [ifn_part] +| [ifn_slash] + +def ifn_path + [ifn_path_part ifn_path] +| [ifn_path_part] + + +literal '%%' + +lex embedded +{ + token em_ws /( any - 33..126 )+/ +} + +def em_item + [em_ws] + +def prelude + [em_item* '%%'] + +def item + ['include' ifn_path] +| ['type' id] + +def start + [prelude item*] + +start parseStart( InputFile: stream ) +{ + return parse start( InputFile ) +} + +start parseTxt( T: str ) +{ + cons a: accum<start>[] + send a [T + ] + return a.finish() +} + +item* concatItems( IL1: item* IL2: item* ) +{ + for IL: item* in IL1 { + if match IL [] { + IL = IL2 + break + } + } + return IL1 +} + +item* expandIncludes( ItemList: ref item* ) +{ + for IL: item* in ItemList { + if match IL + ['include' FN: ifn_path Rest: item*] + { + S: start = parseTxt( + " + "%% + " + ) + + match S [em_item* '%%' IncludedItems: item*] + + IL = concatItems( IncludedItems Rest ) + } + } +} + +int main() +{ + S: start = parseStart(stdin) + match S [em_item* '%%' ItemList: item*] + expandIncludes( ItemList ) +} + +main() diff --git a/test/runtests.mk b/test/runtests.mk index c60ac8e6..4a8bc314 100755 --- a/test/runtests.mk +++ b/test/runtests.mk @@ -74,7 +74,9 @@ TESTS = \ lhs1.lm \ rhsref1.lm \ order1.lm \ - order2.lm + order2.lm \ + concat1.lm \ + concat2.lm DIFFS = \ ambig1.diff \ @@ -148,7 +150,9 @@ DIFFS = \ lhs1.diff \ rhsref1.diff \ order1.diff \ - order2.diff + order2.diff \ + concat1.diff \ + concat2.diff all: runtests.mk $(DIFFS) $(SUBDIRS) @@ -741,3 +745,19 @@ order2.out: order2.bin order2.bin: order2.lm ./../colm/colm ./../colm/colm order2.lm +concat1.diff: concat1.out concat1.exp + @diff -u concat1.exp concat1.out > concat1.diff || ( cat concat1.diff; rm concat1.diff ) + +concat1.out: concat1.bin + ./concat1.bin < concat1.in > concat1.out + +concat1.bin: concat1.lm ./../colm/colm + ./../colm/colm concat1.lm +concat2.diff: concat2.out concat2.exp + @diff -u concat2.exp concat2.out > concat2.diff || ( cat concat2.diff; rm concat2.diff ) + +concat2.out: concat2.bin + ./concat2.bin < concat2.in > concat2.out + +concat2.bin: concat2.lm ./../colm/colm + ./../colm/colm concat2.lm |