Lexer: Rework Integer (and Float) literals to make them easier to parse #11

Closed
opened 2023-10-17 04:22:14 +00:00 by j · 1 comment
Owner

Right now, the Lexer includes the base marker inside the string. However, it would likely be neater to match on the base marker and use that to determine whether the string is a valid literal at parse time.

#Requirements:

Grammar:

  • Update grammar with new production rules for each supported base

Tokens:

  • BaseHex := 0x: base-16 marker
  • BaseTen := 0d: base-10 marker (I find this one fun :P)
  • BaseOct := 0o: base-8 marker
  • BaseBin := 0b: base-2 marker

Lexer:

  • Remove base validation logic from Rule::integer
  • Add rules for each base

AST:

  • Preserve original number base within Int node

Parser:

  • Match (Base*, Integer), and convert from the appropriate base at parse-time
  • Implement digit aggregation
Right now, the Lexer includes the base marker inside the string. However, it would likely be neater to match on the base marker and use that to determine whether the string is a valid literal at parse time. #Requirements: ## Grammar: - [ ] Update grammar with new production rules for each supported base ## Tokens: - [ ] `BaseHex` := `0x`: base-16 marker - [ ] `BaseTen` := `0d`: base-10 marker (I find this one fun :P) - [ ] `BaseOct` := `0o`: base-8 marker - [ ] `BaseBin` := `0b`: base-2 marker ## Lexer: - [ ] Remove base validation logic from `Rule::integer` - [ ] Add rules for each base ## AST: - [ ] Preserve original number base within Int node ## Parser: - [ ] Match (Base*, Integer), and convert from the appropriate base at parse-time - [ ] Implement digit aggregation
j added the
bug
enhancement
labels 2023-10-17 04:22:14 +00:00
j self-assigned this 2023-10-17 04:22:14 +00:00
j added this to the Basic Syntax project 2023-10-17 04:22:14 +00:00
Author
Owner

Issue has been obsoleted with the lexer rewrite

Issue has been obsoleted with the lexer rewrite
j closed this issue 2023-10-22 23:32:54 +00:00
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'.

No due date set.

Dependencies

No dependencies set.

Reference: j/Conlang#11
No description provided.