is_regular_identifier checks now for valid identifiers employing the
definition of words that is also used in the lexer: letters, and
characters outside of the ASCII range, interspersed with single - and
_ characters.
---
 lily/parser.yy |   27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/lily/parser.yy b/lily/parser.yy
index d6dcf11..3fda842 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -3199,19 +3199,22 @@ bool
 is_regular_identifier (SCM id)
 {
   string str = ly_scm2string (id);
-  char const *s = str.c_str ();
 
-  bool v = true;
-#if 0
-  isalpha (*s);
-  s++;
-#endif
-  while (*s && v)
-   {
-        v = v && isalnum (*s);
-        s++;
-   }
-  return v;
+  bool middle = false;
+
+  for (string::iterator it=str.begin(); it != str.end (); it++)
+  {
+         int c = *it & 0xff;
+         if ((c >= 'a' && c <= 'z')
+             || (c >= 'A' && c <= 'Z')
+             || c > 0x7f)
+                 middle = true;
+         else if (middle && (c == '-' || c == '_'))
+                 middle = false;
+         else
+                 return false;
+  }
+  return middle;
 }
 
 SCM
-- 
1.7.9.5


_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to