segment: The body of DEFINE does not have to be on separate lines.
[pspp] / tests / language / lexer / segment.at
index 8f82dd2e6e13f05b08dd11cfc9af43e0ca730dfe..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
@@ -1347,6 +1451,7 @@ identifier      define    space
 macro_id        !macro1
 punct           (
 punct           )
+macro_body
 newline         \n (DEFINE)
 
 macro_body      content_line_1