segment: Ignore !ENDDEFINE in /*comments*/ and "strings".
[pspp] / tests / language / lexer / segment.at
index 86d967b5c58bab116b30e09c6606e3b340603e2e..86a09411947f883538d3fcedb2482908817832b4 100644 (file)
@@ -508,7 +508,8 @@ shbang          #!_/usr/bin/pspp
 newline         \n (first)
 
 identifier      title    space
-unquoted_string my_title
+identifier      my    space
+identifier      title
 end_command     .
 newline         \n (first)
 
@@ -674,18 +675,9 @@ end
 PSPP_CHECK_SEGMENT([-i])
 AT_CLEANUP
 \f
-AT_SETUP([TITLE, SUBTITLE, FILE LABEL commands])
+AT_SETUP([FILE LABEL command])
 AT_KEYWORDS([segment])
 AT_DATA([input], [dnl
-title/**/'Quoted string title'.
-tit /*
-"Quoted string on second line".
-sub "Quoted string subtitle"
- .
-
-TITL /* Not a */ quoted string title.
-SUBT Not a quoted string /* subtitle
-
 FIL label isn't quoted.
 FILE
   lab 'is quoted'.
@@ -694,42 +686,6 @@ FILE /*
 
 ])
 AT_DATA([expout-base], [dnl
-identifier      title
-comment         /**/
-quoted_string   'Quoted_string_title'
-end_command     .
-newline         \n (first)
-
-identifier      tit    space
-comment         /*
-newline         \n (later)
-
-quoted_string   "Quoted_string_on_second_line"
-end_command     .
-newline         \n (first)
-
-identifier      sub    space
-quoted_string   "Quoted_string_subtitle"
-newline         \n (later)
-    space
-end_command     .
-newline         \n (first)
-
-separate_commands
-newline         \n (first)
-
-identifier      TITL    space
-unquoted_string /*_Not_a_*/_quoted_string_title
-end_command     .
-newline         \n (first)
-
-identifier      SUBT    space
-unquoted_string Not_a_quoted_string_/*_subtitle
-newline         \n (later)
-
-separate_commands
-newline         \n (first)
-
 identifier      FIL    space
 identifier      label    space
 unquoted_string isn't_quoted
@@ -1058,7 +1014,7 @@ AT_SETUP([DEFINE command - simple])
 AT_KEYWORDS([segment])
 AT_DATA([input], [dnl
 define !macro1()
-var1 var2 var3
+var1 var2 var3 "!enddefine"
 !enddefine.
 ])
 AT_DATA([expout-base], [dnl
@@ -1066,11 +1022,79 @@ identifier      define    space
 macro_id        !macro1
 punct           (
 punct           )
+spaces
 newline         \n (DEFINE)
 
-macro_body      var1_var2_var3
+macro_body      var1_var2_var3_"!enddefine"
+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
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier      define    space
+macro_id        !macro1
+punct           (
+punct           )
+macro_body      _var1_var2_var3_/*_!enddefine
+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           )
+spaces
 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)
@@ -1091,6 +1115,38 @@ identifier      define    space
 macro_id        !macro1
 punct           (
 punct           )
+spaces
+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           )
+spaces
+newline         \n (DEFINE)
+
+macro_body
+newline         \n (DEFINE)
+
+macro_body
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1124,6 +1180,7 @@ identifier      c
 punct           (
 punct           )
 punct           )
+spaces
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1172,6 +1229,7 @@ punct           )
 newline         \n (later)
 
 punct           )
+spaces
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1207,6 +1265,7 @@ identifier      z
 newline         \n (later)
 
 punct           )
+spaces
 newline         \n (DEFINE)
 
 macro_body      content_1
@@ -1348,6 +1407,7 @@ identifier      define    space
 macro_id        !macro1
 punct           (
 punct           )
+spaces
 newline         \n (DEFINE)
 
 macro_body      content_line_1