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 ;;
newline \n (first)
identifier title space
-unquoted_string my_title
+identifier my space
+identifier title
end_command .
newline \n (first)
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'.
])
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
AT_KEYWORDS([segment])
AT_DATA([input], [dnl
define !macro1()
-var1 var2 var3
+var1 var2 var3 "!enddefine"
!enddefine.
])
AT_DATA([expout-base], [dnl
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)
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
punct (
punct )
punct )
+spaces
newline \n (DEFINE)
macro_id !enddefine
newline \n (later)
punct )
+spaces
newline \n (DEFINE)
macro_id !enddefine
newline \n (later)
punct )
+spaces
newline \n (DEFINE)
macro_body content_1
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 /
AT_SETUP([DEFINE command - missing !ENDDEFINE])
AT_KEYWORDS([segment])
AT_DATA([input], [dnl
-define !macro1().
+define !macro1()
content line 1
content line 2
])
macro_id !macro1
punct (
punct )
-end_command .
+spaces
newline \n (DEFINE)
macro_body content_line_1