Floating point support #2

Closed
opened 2022-07-30 19:51:31 +01:00 by deavmi · 4 comments
Owner

Add floating point support

  • Lexer support
    • Turn 1.3 into a single unit instead of ['1', '.', '3']
  • Code generation and type checking
    • Generate a FloatFetchValue instruction and add to instruction stack
    • Push the correct type to the type stack
Add floating point support - [x] Lexer support * Turn `1.3` into a single unit instead of `['1', '.', '3']` - [x] Code generation and type checking - [x] Generate a `FloatFetchValue` instruction and add to instruction stack - [x] Push the correct type to the type stack
deavmi added this to the Parser project 2022-07-30 19:51:31 +01:00
Author
Owner

WIP: 7e49cf1d0a

WIP: 7e49cf1d0a1d1c2cabdb47f6afae28fd30393c61
Author
Owner

Fixed lexing bug with . in lexer.d in 806814f01c

Fixed lexing bug with `.` in `lexer.d` in 806814f01c42a046462b25fcdb52c48a87464e55
Author
Owner

We also have LiteralValueFloat now, so this should be done.

Type checking though?

We also have `LiteralValueFloat` now, so this should be done. Type checking though?
Author
Owner

Type checking is done already with:

/**
                * Typechecking
                *
                * If the number literal contains a `.` then it is a float
                * else if is an int (NOTE: This may need to be more specific
                * with literal encoders down the line)
                */
                NumberLiteral numLit = cast(NumberLiteral)statement;
                import std.string : indexOf;
                bool isFloat = indexOf(numLit.getNumber(), ".") > -1; 
                gprintln("NUMBER LIT: isFloat: "~to!(string)(isFloat));
                addType(getType(modulle, isFloat ? "float" : "int"));
Type checking is done already with: ```d /** * Typechecking * * If the number literal contains a `.` then it is a float * else if is an int (NOTE: This may need to be more specific * with literal encoders down the line) */ NumberLiteral numLit = cast(NumberLiteral)statement; import std.string : indexOf; bool isFloat = indexOf(numLit.getNumber(), ".") > -1; gprintln("NUMBER LIT: isFloat: "~to!(string)(isFloat)); addType(getType(modulle, isFloat ? "float" : "int")); ```
deavmi added this to the Basics milestone 2022-12-17 17:12:38 +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: tlang/tlang#2
No description provided.