]> git.saurik.com Git - bison.git/commitdiff
identifiers: dashes are letters.
authorAkim Demaille <demaille@gostai.com>
Mon, 4 May 2009 19:15:17 +0000 (21:15 +0200)
committerAkim Demaille <demaille@gostai.com>
Mon, 4 May 2009 19:38:42 +0000 (21:38 +0200)
Dashes can now start identifiers (symbols and directives).

* src/scan-gram.l ({letter}): Add dash.
({id}): Remove it.
* tests/input.at (Symbols): Adjust.
Remove stray comment.
* tests/regression.at (Invalid inputs): Adjust error message.
* doc/bison.texinfo (Symbols): Update.

ChangeLog
NEWS
doc/bison.texinfo
src/scan-gram.l
tests/input.at
tests/regression.at

index 6ac849dac3257373539d6fa26a9b9c6461e43328..bd1799a9e823c924f55ab15775cf9c68254f587f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-05-04  Akim Demaille  <demaille@gostai.com>
+
+       identifiers: dashes are letters.
+       Dashes can now start identifiers (symbols and directives).
+       
+       * src/scan-gram.l ({letter}): Add dash.
+       ({id}): Remove it.
+       * tests/input.at (Symbols): Adjust.
+       Remove stray comment.
+       * tests/regression.at (Invalid inputs): Adjust error message.
+       * doc/bison.texinfo (Symbols): Update.
+
 2009-05-01  Joel E. Denny  <jdenny@ces.clemson.edu>
 
        Declare %code to be a permanent feature.
diff --git a/NEWS b/NEWS
index fe80c6ff07100b139fe3cecf62f439d96a83ef13..bbf2538337ff7b479caa501d871a9880f3920627 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -70,6 +70,14 @@ Bison News
   The old names are now deprecated but will be maintained indefinitely
   for backward compatibility.
 
+** Symbols names
+
+  Consistently with directives (such as %error-verbose) and variables
+  (e.g. push-pull), symbol names may include dashes in any position,
+  similarly to periods and underscores.  This is GNU extension over
+  POSIX Yacc whose use is reported by -Wyacc, and rejected in Yacc
+  mode (--yacc).
+
 ** Temporary hack for adding a semicolon to the user action.
 
   Previously, Bison appended a semicolon to every user action for
index 30b699957ae0e43ccf4ab5962b61c11f0a3e9d22..b09cf842a8ff22cf3f4e04fd07fd49bb52577683 100644 (file)
@@ -3050,8 +3050,8 @@ A @dfn{nonterminal symbol} stands for a class of syntactically
 equivalent groupings.  The symbol name is used in writing grammar rules.
 By convention, it should be all lower case.
 
-Symbol names can contain letters, underscores, period, and (not at the
-beginning) digits and dashes.  Dashes in symbol names are a GNU
+Symbol names can contain letters, underscores, periods, dashes, and (not
+at the beginning) digits.  Dashes in symbol names are a GNU
 extension, incompatible with @acronym{POSIX} Yacc.  Terminal symbols
 that contain periods or dashes make little sense: since they are not
 valid symbols (in most programming languages) they are not exported as
index 2eb36664cd486f1295cddcbb281b7a57a8362f0e..5d4b4b306f20746ba1885b6487c3b6ca15b19d12 100644 (file)
@@ -98,8 +98,8 @@ static void unexpected_newline (boundary, char const *);
  /* Strings and characters in code. */
 %x SC_STRING SC_CHARACTER
 
-letter   [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
-id       {letter}({letter}|[0-9]|-)*
+letter   [-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
+id       {letter}({letter}|[0-9])*
 directive %{id}
 int      [0-9]+
 
index cb3bfd87307592f3ca5bef54c5bafc1541e77abe..5baa4f97e7875dcb430c55b833ecbbb7571afc38 100644 (file)
@@ -616,9 +616,6 @@ AT_CLEANUP
 
 AT_SETUP([Symbols])
 
-# Bison once thought a character token and its alias were different
-# symbols with the same user token number.
-
 AT_DATA_GRAMMAR([input.y],
 [[%token WITH-DASH
 %token WITHOUT_DASH "WITHOUT-DASH"
@@ -656,18 +653,17 @@ AT_BISON_CHECK([-o input.c input.y])
 AT_COMPILE([input.o], [-c input.c])
 
 
-# Period are genuine letters, they can start identifiers.  Dashes
-# and digits can't.
+# Periods and dashes are genuine letters, they can start identifiers.
+# Digits cannot.
 AT_DATA_GRAMMAR([input.y],
-[[%token .good
-%token -wrong
-%token 1nv4l1d
+[[%token .GOOD
+%token -GOOD
+%token 1NV4L1D
 %%
-start: .good
+start: .GOOD -GOOD
 ]])
 AT_BISON_CHECK([-o input.c input.y], [1], [],
-[[input.y:10.8: invalid character: `-'
-input.y:11.8: syntax error, unexpected integer, expecting char or identifier or <tag>
+[[input.y:11.8: syntax error, unexpected integer, expecting char or identifier or <tag>
 ]])
 
 AT_CLEANUP
index a4b20de5a343ea79e9cc00fe0f007574fb3af19a..6bfc77ea6dbaed4e1d8c4974aeed5c84e68a628f 100644 (file)
@@ -1,6 +1,6 @@
 # Bison Regressions.                               -*- Autotest -*-
 
-# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -393,8 +393,7 @@ input.y:3.14: invalid character: `}'
 input.y:4.1: invalid character: `%'
 input.y:4.2: invalid character: `&'
 input.y:5.1-17: invalid directive: `%a-does-not-exist'
-input.y:6.1: invalid character: `%'
-input.y:6.2: invalid character: `-'
+input.y:6.1-2: invalid directive: `%-'
 input.y:7.1-8.0: missing `%}' at end of file
 input.y:7.1-8.0: syntax error, unexpected %{...%}
 ]])