Skip to content

Commit

Permalink
Identifiers may include _underscore_characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
plioi committed Apr 12, 2013
1 parent e874b91 commit f8a4cbd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rook.Compiling/Syntax/RookLexer.cs
Expand Up @@ -41,7 +41,7 @@ public class RookLexer : Lexer
# Close quote:
""
");
public static readonly Pattern Identifier = new Pattern("identifier", @"[a-zA-Z]+[a-zA-Z0-9]*");
public static readonly Pattern Identifier = new Pattern("identifier", @"[_a-zA-Z]+[_a-zA-Z0-9]*");
public static readonly Operator Semicolon = new Operator(";");
public static readonly Operator LeftParen = new Operator("(");
public static readonly Operator RightParen = new Operator(")");
Expand Down
1 change: 1 addition & 0 deletions src/Rook.Test/Compiling/Syntax/RookLexerTests.cs
Expand Up @@ -64,6 +64,7 @@ public void ShouldRecognizeIdentifiers()
Tokenize("a").Single().ShouldEqual(RookLexer.Identifier, "a");
Tokenize("ab").Single().ShouldEqual(RookLexer.Identifier, "ab");
Tokenize("a0").Single().ShouldEqual(RookLexer.Identifier, "a0");
Tokenize("_true_").Single().ShouldEqual(RookLexer.Identifier, "_true_");
}

public void ShouldRecognizeOperatorsGreedily()
Expand Down
1 change: 1 addition & 0 deletions src/Rook.Test/Compiling/Syntax/TokenParserTests.cs
Expand Up @@ -48,6 +48,7 @@ public void ParsesIdentifiers()
identifier.Parses("ab").WithValue(Token(RookLexer.Identifier, "ab"));
identifier.Parses("a0").WithValue(Token(RookLexer.Identifier, "a0"));
identifier.Parses("a01").WithValue(Token(RookLexer.Identifier, "a01"));
identifier.Parses("_true_").WithValue(Token(RookLexer.Identifier, "_true_"));

var keywords = new[] {"true", "false", "int", "bool", "string", "void", "null", "if", "else", "fn", "class", "new"};

Expand Down

0 comments on commit f8a4cbd

Please sign in to comment.