Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lexer #2

Merged
merged 14 commits into from
Apr 21, 2019
Merged

Add lexer #2

merged 14 commits into from
Apr 21, 2019

Conversation

tjysdsg
Copy link
Owner

@tjysdsg tjysdsg commented Apr 13, 2019

  • Implement Reader
  • Add test for Reader
  • Implement Lexer
  • Add test for Lexer

Implement class Reader in src/reader/reader.cpp.

Add src/test/test_program.tan, add test for Reader (src/test/reader_test.h).
@tjysdsg tjysdsg changed the title Add lexer [WIP] Add lexer Apr 13, 2019
tjysdsg added 2 commits April 13, 2019 23:58
Add read_string function to Reader for better testing.

Add functions to Lexer for parsing integer literal.

Add test for Lexer.

Modify test for Reader, because for some reason Boost::filesystem cause
infinite recusive when current working directory is not in src/test.
@todo

This comment has been minimized.

Repository owner deleted a comment from todo bot Apr 15, 2019
Repository owner deleted a comment from todo bot Apr 15, 2019
@tjysdsg tjysdsg self-assigned this Apr 15, 2019
tjysdsg added 2 commits April 15, 2019 23:10
Implement advance_for_identifier and related things.
@tjysdsg
Copy link
Owner Author

tjysdsg commented Apr 18, 2019

recognize identifiers and keywords

tan/src/lexer/lexer.cpp

Lines 156 to 161 in a932dca
// TODO: recognize identifiers and keywords
}
++current;
}
line = _reader->next_line();
}

This comment was generated by todo based on a TODO comment in a932dca in #2. cc @tjysdsg.

Done

@todo
Copy link

todo bot commented Apr 20, 2019

error handling

tan/src/lexer/lexer.cpp

Lines 216 to 221 in 5dd3518

// TODO error handling
}
_token_infos.emplace_back(t);
} else if (line[current] == '"') { // string literals
auto *t =
advance_for_string_literal(line, current, line_len);


This comment was generated by todo based on a TODO comment in 5dd3518 in #2. cc @tjysdsg.

Repository owner deleted a comment Apr 20, 2019
Repository owner deleted a comment Apr 20, 2019
tjysdsg added 2 commits April 20, 2019 21:22
Test code now directly access struct token_info, otherwise it's hard to
test using string representation of floating numbers.
@todo
Copy link

todo bot commented Apr 20, 2019

lex keywords

tan/src/lexer/lexer.cpp

Lines 254 to 259 in 63b534e

// TODO: lex keywords
_token_infos.emplace_back(t);
} else if (line[current] == '\'') { // char
++current;
auto *t = new token_info;
t->type = CHAR;


This comment was generated by todo based on a TODO comment in 63b534e in #2. cc @tjysdsg.

@todo
Copy link

todo bot commented Apr 20, 2019

add more test cases

tan/src/test/lexer_test.h

Lines 148 to 151 in 63b534e

// TODO: add more test cases
}
#endif //__TAN_TEST_LEXER_TEST_H__


This comment was generated by todo based on a TODO comment in 63b534e in #2. cc @tjysdsg.

tjysdsg added 4 commits April 21, 2019 11:14
Add more test cases for string literals, character, and symbols in
src/test/lexer_test.h.
Fix some minor warnings.
Fix the bug that Lexer stuck in infinite loop when "0" is in the middle
of a string.

Fix the bug that Reader doesn't reset the value of _curr_line when
read_string is called more than once.

Fix the bug that Reader doesn't clear _lines (std::vector<line_info*>)
when read_string is called more than once.
Fix the bug that some type in enum TOKEN_TYPE have the same value.
@tjysdsg tjysdsg changed the title [WIP] Add lexer Add lexer Apr 21, 2019
@tjysdsg tjysdsg merged commit d6d9b4a into master Apr 21, 2019
@todo todo bot mentioned this pull request Apr 21, 2019
@tjysdsg tjysdsg deleted the lexer branch April 21, 2019 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant