Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Team 3: Reader and Lexer #1

Closed
wants to merge 0 commits into from
Closed

Team 3: Reader and Lexer #1

wants to merge 0 commits into from

Conversation

MaarcS
Copy link
Contributor

@MaarcS MaarcS commented Apr 16, 2024

No description provided.

@marcauberer
Copy link
Owner

Thanks ;)
Ignore the workflow error for the labeler. This is a bug on my side

Copy link
Owner

@marcauberer marcauberer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Noted a few things to make the parser integration smooth.

@Override
public Token getToken() {

if (tokenText.isEmpty() && reader.isEOF()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this logic should be moved to advance. All this method should do is to return the value of a member variable, that holds the current token.

}

// read token chars
while (!reader.isEOF() && reader.getChar() != ' ' && reader.getChar() != '\n' && reader.getChar() != '\t') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not always a whitespace between tokens. Think of parentheses, which are also tokens. This should also work if there is no whitespace.
What advance needs to do is, to match the input against all available state machines and the state machine, which can match the largest number of chars, gets to consume the input and create the respective token.

}

private void advanceStringLiteral() {
do {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StringLiteralStateMachine should do this part.


@Override
public void close() throws IOException {
inputStream.close();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool approach! This should close the input stream if anything exceptional occurs, right?

@marcauberer marcauberer changed the title Implement reader & lexer + tests Team 3: Reader and Lexer Apr 18, 2024
@MaarcS MaarcS closed this Apr 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants