DEFINE: Properly support redefining a macro.
[pspp] / tests / language / lexer / segment.at
index 65a271f69865d59b83305c63224985ad1f196c4a..78ad1e99eb5843b81fc9e432119d56335b7a6dc3 100644 (file)
@@ -291,8 +291,8 @@ AT_SETUP([punctuation])
 AT_KEYWORDS([segment])
 AT_DATA([input], [dnl
 ~ & | = >= > <= < ~= <> ( ) , - + * / [[ ]] **
-~&|=>=><=<~=<>(),-+*/[[]]**
-% : ; ? _ ` { } ~
+~&|=>=><=<~=<>(),-+*/[[]]**!*
+% : ; ? _ ` { } ~ !*
 ])
 AT_DATA([expout-base], [dnl
 punct           ~    space
@@ -337,6 +337,7 @@ punct           /
 punct           [[
 punct           ]]
 punct           **
+macro_id        !*
 newline         \n (later)
 
 punct           %    space
@@ -347,7 +348,8 @@ punct           \_    space
 punct           `    space
 punct           {    space
 punct           }    space
-punct           ~
+punct           ~    space
+macro_id        !*
 -newline         \n (later)
 -
 end
@@ -355,7 +357,7 @@ end
 PSPP_CHECK_SEGMENT([-i])
 AT_CLEANUP
 \f
-AT_SETUP([numbers])
+AT_SETUP([positive numbers])
 AT_KEYWORDS([segment])
 AT_DATA([input], [dnl
 0 1 01 001. 1.
@@ -423,6 +425,83 @@ end
 ])
 PSPP_CHECK_SEGMENT([-i])
 AT_CLEANUP
+\f
+AT_SETUP([negative numbers])
+AT_KEYWORDS([segment])
+AT_DATA([input], [dnl
+ -0 -1 -01 -001. -1.
+ -123. /* comment 1 */ /* comment 2 */
+ -.1 -0.1 -00.1 -00.10
+ -5e1 -6E-1 -7e+1 -6E+01 -6e-03
+ -.3E1 -.4e-1 -.5E+1 -.6e+01 -.7E-03
+ -1.23e1 -45.6E-1 -78.9e+1 -99.9E+01 -11.2e-03
+ -/**/1
+ -. -1e -e1 -1e+ -1e- -1.
+])
+AT_DATA([expout-base], [dnl
+spaces          _
+number          -0    space
+number          -1    space
+number          -01    space
+number          -001.    space
+number          -1
+end_command     .
+newline         \n (first)
+    space
+number          -123
+end_command     .    space
+comment         /*_comment_1_*/    space
+comment         /*_comment_2_*/
+newline         \n (first)
+    space
+number          -.1    space
+number          -0.1    space
+number          -00.1    space
+number          -00.10
+newline         \n (later)
+    space
+number          -5e1    space
+number          -6E-1    space
+number          -7e+1    space
+number          -6E+01    space
+number          -6e-03
+newline         \n (later)
+    space
+number          -.3E1    space
+number          -.4e-1    space
+number          -.5E+1    space
+number          -.6e+01    space
+number          -.7E-03
+newline         \n (later)
+    space
+number          -1.23e1    space
+number          -45.6E-1    space
+number          -78.9e+1    space
+number          -99.9E+01    space
+number          -11.2e-03
+newline         \n (later)
+    space
+punct           -
+comment         /**/
+number          1
+newline         \n (later)
+    space
+punct           -
+punct           .    space
+expected_exponent -1e    space
+punct           -
+identifier      e1    space
+expected_exponent -1e+    space
+expected_exponent -1e-    space
+number          -1
+end_command     .
+-newline         \n (first)
+-
+end
+])
+PSPP_CHECK_SEGMENT([-i])
+AT_CLEANUP
+
 \f
 AT_SETUP([strings])
 AT_KEYWORDS([segment])
@@ -508,7 +587,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 +754,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 +765,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,18 +1093,18 @@ 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
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 punct           )
-macro_body
+spaces
 newline         \n (DEFINE)
 
-macro_body      var1_var2_var3
+macro_body      var1_var2_var3_"!enddefine"
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1084,15 +1119,15 @@ AT_CLEANUP
 AT_SETUP([DEFINE command - no newline after parentheses])
 AT_KEYWORDS([segment])
 AT_DATA([input], [dnl
-define !macro1() var1 var2 var3
+define !macro1() var1 var2 var3 /* !enddefine
 !enddefine.
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 punct           )
-macro_body      _var1_var2_var3
+macro_body      _var1_var2_var3_/*_!enddefine
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1112,10 +1147,10 @@ var1 var2 var3!enddefine.
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 punct           )
-macro_body
+spaces
 newline         \n (DEFINE)
 
 macro_body      var1_var2_var3
@@ -1135,7 +1170,7 @@ define !macro1()var1 var2 var3!enddefine.
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 punct           )
 macro_body      var1_var2_var3
@@ -1156,10 +1191,10 @@ define !macro1()
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 punct           )
-macro_body
+spaces
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1181,10 +1216,10 @@ define !macro1()
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 punct           )
-macro_body
+spaces
 newline         \n (DEFINE)
 
 macro_body
@@ -1210,7 +1245,7 @@ define !macro1(a(), b(), c())
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 identifier      a
 punct           (
@@ -1224,7 +1259,7 @@ identifier      c
 punct           (
 punct           )
 punct           )
-macro_body
+spaces
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1248,7 +1283,7 @@ define !macro1(
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 newline         \n (later)
 
@@ -1273,7 +1308,7 @@ punct           )
 newline         \n (later)
 
 punct           )
-macro_body
+spaces
 newline         \n (DEFINE)
 
 macro_id        !enddefine
@@ -1297,7 +1332,7 @@ content 2
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 newline         \n (later)
 
 punct           (
@@ -1309,7 +1344,7 @@ identifier      z
 newline         \n (later)
 
 punct           )
-macro_body
+spaces
 newline         \n (DEFINE)
 
 macro_body      content_1
@@ -1335,7 +1370,7 @@ data list /x 1.
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 end_command     .
 newline         \n (first)
 
@@ -1361,7 +1396,7 @@ data list /x 1.
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 newline         \n (later)
 
 identifier      x
@@ -1390,7 +1425,7 @@ data list /x 1.
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 end_command     .
 newline         \n (first)
@@ -1422,7 +1457,7 @@ data list /x 1.
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 end_command     .
 newline         \n (first)
 
@@ -1448,10 +1483,10 @@ content line 2
 ])
 AT_DATA([expout-base], [dnl
 identifier      define    space
-macro_id        !macro1
+macro_name      !macro1
 punct           (
 punct           )
-macro_body
+spaces
 newline         \n (DEFINE)
 
 macro_body      content_line_1