Lexer interface #105

Closed
opened 2023-03-08 14:23:51 +00:00 by deavmi · 9 comments
Owner

What is this?

The point of this feature request is to declare a set of files that hold Token, LexerInterface and then a generalized LexerInterface. The interface should declare the general structure that a parser must adhere to in order to be used, namely:

  1. There must be a getCurrentToken() method which returns a Token
  2. Implement nextToken(), previousToken()
  3. Cursor position set/get with setCursor(ulong) and getCursor()
  4. There must be a hasTokens() to check if there are more tokens to come considering the current cursor position
  5. An exhaustive getTokens()
  6. A getLine() and getColumn() to know where in the source text we are
# What is this? The point of this feature request is to declare a set of files that hold `Token`, `LexerInterface` and then a generalized `LexerInterface`. The interface should declare the general structure that a parser must adhere to in order to be used, namely: 1. There must be a `getCurrentToken()` method which returns a `Token` 2. Implement `nextToken()`, `previousToken()` 3. Cursor position set/get with `setCursor(ulong)` and `getCursor()` 4. There must be a `hasTokens()` to check if there are more tokens to come considering the current cursor position 5. An exhaustive `getTokens()` 6. A `getLine()` and `getColumn()` to know where in the source text we are
deavmi added a new dependency 2023-03-08 14:23:59 +00:00
Ghost was assigned by deavmi 2023-03-08 14:24:26 +00:00
deavmi added the
parser
label 2023-03-08 14:24:38 +00:00
deavmi changed title from Parser interface to Lexer interface 2023-03-08 14:25:02 +00:00
deavmi added
qol
lexer
and removed
parser
labels 2023-03-08 14:25:07 +00:00
deavmi added a new dependency 2023-03-08 14:29:17 +00:00
Author
Owner

🔐️ Locking for now till I stabilize stuff and onboard @rany

🔐️ Locking for now till I stabilize stuff and onboard @rany
deavmi locked and limited conversation to collaborators 2023-03-08 14:30:39 +00:00
deavmi added this to the Clean ups milestone 2023-03-08 14:32:19 +00:00
deavmi added this to the Parser project 2023-03-08 14:32:50 +00:00
deavmi added reference feature/lexer_interface 2023-04-20 11:05:13 +01:00
Author
Owner

I have pushed a definition for LexerInterface now

I have pushed a definition for `LexerInterface` now
Author
Owner

Todo 📝

  • Add getTokens() to the interface API
    • Perhaps we should define a getTokens(), which exhaustively calls getTokens()till it cannot anymore. Useful for unit tests where we need to compare tokens.
  • getLine() and getColumn()
## Todo 📝 - [x] Add `getTokens()` to the interface API * Perhaps we should define a `getTokens()`, which exhaustively calls `getTokens()`till it cannot anymore. Useful for unit tests where we need to compare tokens. - [x] `getLine()` and `getColumn()`
Author
Owner

Questions 🤔

  • getTokens() is common code
    • It could be argued that we may want this to be an abstract class rather than an interface in the case of getTokens(), as we could simply call it exhaustively ourselves. It would be common code
    • Solution, we don't even need a class, we can use a ~default~ final interface method for this, mmmh, however maybe we do? We would need to reset the cursor each time - it is doable but we can see - honestly who would call getTokens() in places other than unit tests and also more than once? It will not change.
## Questions 🤔 - [ ] `getTokens()` is common code * It could be argued that we may want this to be an `abstract class` rather than an `interface` in the case of `getTokens()`, as we could simply call it exhaustively ourselves. It would be common code * **Solution**, we don't even need a class, we can use a ~`default`~ `final` interface method for this, mmmh, however maybe we do? We would need to reset the cursor each time - it is doable but we can see - honestly who would call `getTokens()` in places other than unit tests and also more than once? It will not change.
deavmi self-assigned this 2023-04-20 13:34:45 +01:00
Ghost was unassigned by deavmi 2023-04-20 13:34:46 +01:00
Author
Owner

Questions 🤔

  • getTokens() is common code
    • It could be argued that we may want this to be an abstract class rather than an interface in the case of getTokens(), as we could simply call it exhaustively ourselves. It would be common code
    • Solution, we don't even need a class, we can use a ~default~ final interface method for this, mmmh, however maybe we do? We would need to reset the cursor each time - it is doable but we can see - honestly who would call getTokens() in places other than unit tests and also more than once? It will not change.

Currently doing this crashes with out of bounds, need to check how basic.d works.

> ## Questions 🤔 > > - [ ] `getTokens()` is common code > * It could be argued that we may want this to be an `abstract class` rather than an `interface` in the case of `getTokens()`, as we could simply call it exhaustively ourselves. It would be common code > * **Solution**, we don't even need a class, we can use a ~`default`~ `final` interface method for this, mmmh, however maybe we do? We would need to reset the cursor each time - it is doable but we can see - honestly who would call `getTokens()` in places other than unit tests and also more than once? It will not change. Currently doing this crashes with out of bounds, need to check how `basic.d` works.
deavmi removed a dependency 2023-04-20 14:12:30 +01:00
Author
Owner

I want to start work on this soon :). Maybe once I finish some of the type checking stuff up.

I want to start work on this soon :). Maybe once I finish some of the type checking stuff up.
deavmi changed reference from feature/lexer_interface to feature/clean_lexer_interface 2023-07-08 18:03:15 +01:00
deavmi started working 2023-07-08 19:10:30 +01:00
deavmi added the due date 2023-07-10 2023-07-08 19:10:37 +01:00
deavmi unlocked this conversation 2023-07-08 19:24:31 +01:00
deavmi stopped working 2023-07-08 20:37:28 +01:00
1 hour 26 minutes
deavmi started working 2023-07-09 11:37:10 +01:00
Author
Owner

This lexer interface is done now.

This lexer interface is done now.
deavmi added a new dependency 2023-07-09 11:38:42 +01:00
Author
Owner

Awaiting CI/CD ...

Awaiting CI/CD ...
Author
Owner

Looks like the CI/CD is all green - closing

Looks like the CI/CD is all green ✅ - closing
deavmi stopped working 2023-07-09 11:41:21 +01:00
4 minutes 11 seconds
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 1 hour 31 minutes
deavmi
1 hour 31 minutes
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

2023-07-10

Reference: tlang/tlang#105
No description provided.