Handling of this (post-iteration statement) #76

Closed
opened 2023-01-07 11:38:30 +00:00 by deavmi · 3 comments
Owner

WHen we have:

for(int idx = 0; idx < i; idx=idx+1;)

So we call parseStatement() on this, then parseExpression() is called in-turn. It will stop when it sees a ) or ; and then return the expression to parseStatement() - however parseStatement() will expect to have ; and not a ). We could work around this by passing in the requested terminator to parseStatement() and having the default argument value be SymbolType.SEMICOLON.

I think that is a neat fix.

WHen we have: ``` for(int idx = 0; idx < i; idx=idx+1;) ``` So we call `parseStatement()` on this, then `parseExpression()` is called in-turn. It will stop when it sees a `)` or `;` and then return the expression to `parseStatement()` - however `parseStatement()` will expect to have `;` and **not** a `)`. We could work around this by passing in the requested terminator to `parseStatement()` and having the default argument value be `SymbolType.SEMICOLON`. I think that is a neat fix.
deavmi added a new dependency 2023-01-07 11:40:16 +00:00
Author
Owner

Actually, it isn't there me thinks? mmmh:

[WARNING] parseExpression(): Leave
[ERROR] Syntax error: Expected SEMICOLON but got RBRACE, see ) at (7, 40)

Aha! It's in parseAssignment().

As: parseStatement() -> parseName() -> parseAssignment().

We would probably need to parse this thing all the way down.

Actually, it isn't there me thinks? mmmh: ``` [WARNING] parseExpression(): Leave [ERROR] Syntax error: Expected SEMICOLON but got RBRACE, see ) at (7, 40) ``` **Aha!** It's in `parseAssignment()`. As: `parseStatement() -> parseName() -> parseAssignment()`. We would probably need to parse this thing all the way down.
Author
Owner

I have implemented the above and it seems to be working.

I have implemented the above and it seems to be working.
deavmi added the due date 2023-01-08 2023-01-07 13:36:09 +00:00
deavmi added reference loops 2023-01-08 10:40:21 +00:00
deavmi added the
parser
label 2023-01-08 10:40:28 +00:00
deavmi self-assigned this 2023-01-08 10:40:31 +00:00
deavmi added this to the Parser project 2023-01-08 10:40:35 +00:00
deavmi added this to the Basics milestone 2023-01-08 10:40:38 +00:00
Author
Owner

We have sorted this out with an update to:

  1. parseStatement()
  2. parseName()
  3. parseAssignment()

They now all take in arguments for a custoim terminator but will default to SymbolType.SEMICOLON.

As of commit ec7d8cf4240b24a2f6fdbd8071195c9efe08d573 on branch loops

We have sorted this out with an update to: 1. `parseStatement()` 2. `parseName()` 3. `parseAssignment()` They now all take in arguments for a custoim terminator but will default to `SymbolType.SEMICOLON`. As of commit `ec7d8cf4240b24a2f6fdbd8071195c9efe08d573` on branch `loops`
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

2023-01-08

Reference: tlang/tlang#76
No description provided.