From: David Kastrup Date: Thu, 4 Oct 2012 15:11:25 +0000 (+0200) Subject: parser.yy: make is_regular_identifier match the lexer definition X-Git-Tag: release/2.17.6-1~35 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d2d364015c346e1aaed2a8f25dfcf11182abf3ab;p=lilypond.git parser.yy: make is_regular_identifier match the lexer definition 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. --- diff --git a/lily/parser.yy b/lily/parser.yy index d6dcf11cc4..3fda84232f 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