-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor review comments. Nice work!
@Override | ||
public Token getToken() { | ||
|
||
if (tokenText.isEmpty() && reader.isEOF()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic should be part of advance
. This method should only return the member variable that holds the current token.
return null; | ||
} | ||
|
||
private void advanceStringLiteral() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done by the StringLiteralStateMachine
addState(start); | ||
addState(end); | ||
|
||
Range digits = new Range('0', '9'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid accepting leading zeroes
public void init() { | ||
State stateStart = new State("Start"); | ||
stateStart.setStartState(true); | ||
stateStart.setAcceptState(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks suspicious. The accepting state shouldn't be the start state here.
Reader reader = new Reader(new File("src/test/resources/test.txt")); | ||
Lexer lexer = new Lexer(reader); | ||
|
||
lexer.advance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Advance should be done automatically by expect
, so you don't need to call both
@Test | ||
public void testGetChar() throws FileNotFoundException { | ||
Reader reader = new Reader(testFile); | ||
reader.getChar(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should assert somehow if the expectations afterwards are met
Tests should work though! |
b3aaf07
to
8e92f0a
Compare
No description provided.