segment: The body of DEFINE does not have to be on separate lines.
[pspp] / tests / language / lexer / segment.at
index 54520717c7ca96f6d74c91210ecb70156260e045..65a271f69865d59b83305c63224985ad1f196c4a 100644 (file)
@@ -16,7 +16,8 @@ dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl
 AT_BANNER([syntax segmentation])
 m4_define([PSPP_CHECK_SEGMENT],
-  [for strip in "" "-s"; do
+  [AT_CAPTURE_FILE([input])
+   for strip in "" "-s"; do
      case $strip in # (
         '') sed 's/^-//' < expout-base > expout ;; # (
        -s) sed '/^-/d' < expout-base > expout ;;
@@ -1065,11 +1066,79 @@ identifier      define    space
 macro_id        !macro1
 punct           (
 punct           )
+macro_body
 newline         \n (DEFINE)
 
 macro_body      var1_var2_var3
 newline         \n (DEFINE)
 
+macro_id        !enddefine
+end_command     .
+-newline         \n (first)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-i])
+AT_CLEANUP
+\f
+AT_SETUP([DEFINE command - no newline after parentheses])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1() var1 var2 var3
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier      define    space
+macro_id        !macro1
+punct           (
+punct           )
+macro_body      _var1_var2_var3
+newline         \n (DEFINE)
+
+macro_id        !enddefine
+end_command     .
+-newline         \n (first)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-i])
+AT_CLEANUP
+\f
+AT_SETUP([DEFINE command - no newline before !ENDDEFINE])
+AT_KEYWORDS([segment ENDDEFINE])
+AT_DATA([input], [dnl
+define !macro1()
+var1 var2 var3!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier      define    space
+macro_id        !macro1
+punct           (
+punct           )
+macro_body
+newline         \n (DEFINE)
+
+macro_body      var1_var2_var3
+macro_id        !enddefine
+end_command     .
+-newline         \n (first)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-i])
+AT_CLEANUP
+\f
+AT_SETUP([DEFINE command - all on one line])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1()var1 var2 var3!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier      define    space
+macro_id        !macro1
+punct           (
+punct           )
+macro_body      var1_var2_var3
 macro_id        !enddefine
 end_command     .
 -newline         \n (first)
@@ -1090,6 +1159,38 @@ identifier      define    space
 macro_id        !macro1
 punct           (
 punct           )
+macro_body
+newline         \n (DEFINE)
+
+macro_id        !enddefine
+end_command     .
+-newline         \n (first)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-i])
+AT_CLEANUP
+\f
+AT_SETUP([DEFINE command - blank lines])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1()
+
+
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier      define    space
+macro_id        !macro1
+punct           (
+punct           )
+macro_body
+newline         \n (DEFINE)
+
+macro_body
+newline         \n (DEFINE)
+
+macro_body
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1123,6 +1224,7 @@ identifier      c
 punct           (
 punct           )
 punct           )
+macro_body
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1171,6 +1273,7 @@ punct           )
 newline         \n (later)
 
 punct           )
+macro_body
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1206,6 +1309,7 @@ identifier      z
 newline         \n (later)
 
 punct           )
+macro_body
 newline         \n (DEFINE)
 
 macro_body      content_1
@@ -1295,6 +1399,33 @@ identifier      x
 end_command     .
 newline         \n (first)
 
+identifier      data    space
+identifier      list    space
+punct           /
+identifier      x    space
+number          1
+end_command     .
+-newline         \n (first)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-i])
+AT_CLEANUP
+\f
+AT_SETUP([DEFINE command - early end of command 4])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+dnl Notice the command terminator at the end of the DEFINE command,
+dnl which should not be there and ends it early.
+define !macro1.
+data list /x 1.
+])
+AT_DATA([expout-base], [dnl
+identifier      define    space
+macro_id        !macro1
+end_command     .
+newline         \n (first)
+
 identifier      data    space
 identifier      list    space
 punct           /
@@ -1311,7 +1442,7 @@ AT_CLEANUP
 AT_SETUP([DEFINE command - missing !ENDDEFINE])
 AT_KEYWORDS([segment])
 AT_DATA([input], [dnl
-define !macro1().
+define !macro1()
 content line 1
 content line 2
 ])
@@ -1320,7 +1451,7 @@ identifier      define    space
 macro_id        !macro1
 punct           (
 punct           )
-end_command     .
+macro_body
 newline         \n (DEFINE)
 
 macro_body      content_line_1