]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Scanner has now a public static method to check if a token is a keyword or an identif...
authorAlberto Ruiz <aruiz@codethink.co.uk>
Thu, 23 Jul 2009 16:35:27 +0000 (17:35 +0100)
committerAlberto Ruiz <aruiz@codethink.co.uk>
Thu, 23 Jul 2009 16:35:27 +0000 (17:35 +0100)
vala/valacodewriter.vala
vala/valascanner.vala

index 073c1073a2c5447905865a27473929de4e302f2c..b83b44b09ba916575f577013be5f8e2b9fdbc722 100644 (file)
@@ -1544,13 +1544,11 @@ public class Vala.CodeWriter : CodeVisitor {
        }
        
        private void write_identifier (string s) {
-               if (s == "base" || s == "break" || s == "class" ||
-                   s == "construct" || s == "delegate" || s == "delete" ||
-                   s == "do" || s == "dynamic" || s == "foreach" || s == "in" ||
-                   s == "interface" || s == "lock" || s == "namespace" ||
-                   s == "new" || s == "out" || s == "ref" ||
-                   s == "signal" || s.get_char ().isdigit ()) {
-                       stream.putc ('@');
+               char* id = (char*)s;
+               int id_length = (int)s.length;
+               if ( Vala.Scanner.get_identifier_or_keyword (id, id_length) != Vala.TokenType.IDENTIFIER ||
+                     s.get_char ().isdigit ()) {
+                       stream.putc ('@'); 
                }
                write_string (s);
        }
index 6f09a13ce76e1886907907dbc8ca4df032f89a6f..a08bdaa9187391fea29378fc65e0cc5b5516f9e8 100644 (file)
@@ -61,7 +61,7 @@ public class Vala.Scanner {
                return (c.isalnum () || c == '_');
        }
 
-       TokenType get_identifier_or_keyword (char* begin, int len) {
+       public static TokenType get_identifier_or_keyword (char* begin, int len) {
                switch (len) {
                case 2:
                        switch (begin[0]) {
@@ -792,7 +792,7 @@ public class Vala.Scanner {
                return type;
        }
 
-       bool matches (char* begin, string keyword) {
+       static bool matches (char* begin, string keyword) {
                char* keyword_array = keyword;
                long len = keyword.len ();
                for (int i = 0; i < len; i++) {