Permalink
Browse files

Added comment lexing/parsing. Reference: http://www.perlmonks.org/?no…

  • Loading branch information...
1 parent b196fe3 commit f7a73be0dbff33e6896a5ce936c1cb677792c46b @fruchtose fruchtose committed Apr 6, 2012
Showing with 3 additions and 2 deletions.
  1. +1 −0 in.tenc
  2. +1 −1 src/r194/Lexer.java
  3. +1 −1 src/r194/Parser.java
View
@@ -3,6 +3,7 @@ int main(){
return a(1) + i;
}
+// This is a comment
int a(int a) {
return a * 4;
}
View
@@ -7,7 +7,7 @@
enum Token {
NONE(null),
EOF(null),
- //COMMENT("\\/\\/.*?\n"),
+ COMMENT("//[^\n]*"),
RETURN("return"),
WHITESPACE("\\p{Space}"),
TYPE_NAME("(int|void)"),
View
@@ -17,7 +17,7 @@ public void filterTokens(){
List<Lexeme> newTokens = new ArrayList<>();
for (int i = 0; i < tokens.size(); i++) {
Lexeme t = tokens.get(i);
- if (/*t.type != Token.COMMENT && */t.type != Token.WHITESPACE){
+ if (t.type != Token.COMMENT && t.type != Token.WHITESPACE){
newTokens.add(t);
}
}

0 comments on commit f7a73be

Please sign in to comment.