Added "switch" and "case" to the list of keywords so they can't be used as variable names.

This commit is contained in:
TomyLobo 2011-12-04 06:40:09 +01:00
parent 4753574bae
commit 61b2ea4007

View File

@ -109,7 +109,7 @@ public class Lexer {
characterTokens.add(':');
}
private static final Set<String> keywords = new HashSet<String>(Arrays.asList("if", "else", "while", "do", "for", "break", "continue", "return"));
private static final Set<String> keywords = new HashSet<String>(Arrays.asList("if", "else", "while", "do", "for", "break", "continue", "return", "switch", "case"));
private static final Pattern numberPattern = Pattern.compile("^([0-9]*(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)");
private static final Pattern identifierPattern = Pattern.compile("^([A-Za-z][0-9A-Za-z_]*)");