+-newline \n (first)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-i])
+AT_CLEANUP
+\f
+AT_SETUP([DO REPEAT command in batch mode])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+do repeat x=a b c
+ y=d e f
+do repeat a=1 thru 5
+another command
+second command
++ third command
+end /* x */ /* y */ repeat print
+end
+ repeat
+do
+ repeat #a=1
+
+ inner command
+end repeat
+])
+AT_DATA([expout-base], [dnl
+identifier do space
+identifier repeat space
+identifier x
+punct =
+identifier a space
+identifier b space
+identifier c
+newline \n (later)
+
+spaces __________
+identifier y
+punct =
+identifier d space
+identifier e space
+identifier f
+newline \n (later)
+
+start_command
+do_repeat_command do_repeat_a=1_thru_5
+newline \n (DO REPEAT)
+
+do_repeat_command another_command
+newline \n (DO REPEAT)
+
+do_repeat_command second_command
+newline \n (DO REPEAT)
+
+do_repeat_command +_third_command
+newline \n (DO REPEAT)
+
+do_repeat_command end_/*_x_*/_/*_y_*/_repeat_print
+newline \n (DO REPEAT)
+
+identifier end
+newline \n (later)
+ space
+identifier repeat
+newline \n (later)
+
+start_command
+identifier do
+newline \n (later)
+
+spaces __
+identifier repeat space
+identifier #a
+punct =
+number 1
+newline \n (later)
+
+separate_commands
+newline \n (DO REPEAT)
+
+do_repeat_command __inner_command
+newline \n (DO REPEAT)
+
+identifier end space
+identifier repeat
+-newline \n (later)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-b])
+AT_CLEANUP
+\f
+AT_SETUP([DEFINE command - simple])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1()
+var1 var2 var3 "!enddefine"
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier define space
+macro_name !macro1
+punct (
+punct )
+spaces
+newline \n (DEFINE)
+
+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_name !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_name !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_name !macro1
+punct (
+punct )
+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 - empty])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1()
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier define space
+macro_name !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_name !macro1
+punct (
+punct )
+spaces
+newline \n (DEFINE)
+
+macro_body
+newline \n (DEFINE)
+
+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 - arguments])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1(a(), b(), c())
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier define space
+macro_name !macro1
+punct (
+identifier a
+punct (
+punct )
+punct , space
+identifier b
+punct (
+punct )
+punct , space
+identifier c
+punct (
+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 - multiline arguments])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1(
+ a(), b(
+ ),
+ c()
+)
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier define space
+macro_name !macro1
+punct (
+newline \n (later)
+
+spaces __
+identifier a
+punct (
+punct )
+punct , space
+identifier b
+punct (
+newline \n (later)
+
+spaces __
+punct )
+punct ,
+newline \n (later)
+
+spaces __
+identifier c
+punct (
+punct )
+newline \n (later)
+
+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 - arguments start on second line])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1
+(x,y,z
+)
+content 1
+content 2
+!enddefine.
+])
+AT_DATA([expout-base], [dnl
+identifier define space
+macro_name !macro1
+newline \n (later)
+
+punct (
+identifier x
+punct ,
+identifier y
+punct ,
+identifier z
+newline \n (later)
+
+punct )
+spaces
+newline \n (DEFINE)
+
+macro_body content_1
+newline \n (DEFINE)
+
+macro_body content_2
+newline \n (DEFINE)
+
+macro_id !enddefine
+end_command .
+-newline \n (first)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-i])
+AT_CLEANUP
+\f
+AT_SETUP([DEFINE command - early end of command 1])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1.
+data list /x 1.
+])
+AT_DATA([expout-base], [dnl
+identifier define space
+macro_name !macro1
+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 2])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1
+x.
+data list /x 1.
+])
+AT_DATA([expout-base], [dnl
+identifier define space
+macro_name !macro1
+newline \n (later)
+
+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 3])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+define !macro1(.
+x.
+data list /x 1.
+])
+AT_DATA([expout-base], [dnl
+identifier define space
+macro_name !macro1
+punct (
+end_command .
+newline \n (first)
+
+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_name !macro1
+end_command .