Commit Graph

26 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire d716c306a2 Lexer
- Fully integrated new `LexerException` system into `performLex()`

COmmand-line

- Updated `commands.d` to catch any `TError` and report the error back

Parser

- Updated unittests to use `LexerException`

Compiler

- Disabled unit tests for now as they cause errors
2023-01-22 14:59:55 +02:00
Tristan B. Velloza Kildaire 5fd1bef2a4 Lexer
- Added new exception type `LexerException`
- Added `LexerError` enum to support various error types of the `LexerException` exception type
2023-01-22 14:45:25 +02:00
Tristan B. Velloza Kildaire 4f899c69e2 Lexer
- Fixed missing flushing for issue #65 (see "Flushing fix ")
- Added unit test for flushing fix

VariableDeclaration (Instruction)

- Added support for the embedding of a VariableAssignmentInstr inside (added a getter too) (a part of issue #66)
- Conditional support for if statements: Added two new instructions (IfStatementInstruction and BranchInstruction). See issue #64

DGen

- Added depth increment/decrement on enter/leave scope of `transform()`
- Correct tabbing for nested if-statements using new method `genTabs(ulong)` (which uses the above mechanism). Makes code emitted for if statements (issue #64) look nicer.
- Updated VariableDeclarations (with assignments) handling in `transform()` in the manner similar to BinOpInstr (see issue #66)
- Added a TODO for formatting BinOpInstr's `transform()` a little more aesthetically nicer
- Added code emitting support for if statements (the `IfStatementInstruction` instruction) (see issue #64)
- Updated `emitEntryPoint()` to only emit testing C code for the correct input test file

Parser

- `parseIf()` now returns an instance of IfStatement which couples multiple `Branch` objects consisting of `Statement[]` and `Expression`
- Ensured that each `Statement` of the generated `Statement[]` from `parseBody()` for a given `Branch` is parented to said Branch using `parentToContainer()`
- Ensured each generated `Branch` in `Branch[]` is parented to the generated `IfStatement` using `parentToContainer()`
- `parseBody()` now adds to its `Statement[]` build-up array the generated `IfStatement` from the call to `parseIf()`

Check

- Added support for back-mapping `SymbolType.EQUALS` to `getCharacter(SymbolType)`

Data

- Added `Branch` parser node which is a Container for body statements (`Statement[]`)
- Added `IfStatement` parser node which is a Container of `Statement[]` which are actually `Branch[]`

TypeChecker

- Moved import for `reverse` to top of module
- Implemented `tailPopInstr()` method which will pop from the back of the `codeQueue` "scratchpad"
- Fixes handling of `StaticVariableDeclaration` and `VariableAssignmentNode` (fixes issue #66)
- Added handling for IfStatement entities (if statement support #64)

Resolution

- Added a debug statement to `resolveUp(Container, string)` to print out the container to lookup from and the name being looked up

Dependency

- Added a default `toString()` to the DNode class which prints `[DNode: <entity toString()]`
- Added a TODO and debug print related to issues #9
- Disabled InitScope.STATIC check for now as it caused issues with if statement parsing (probably due to VIRTUAL being default and therefore skipping if statment processing) - issue #69
- Cleaned up handling of Entity type `Variable` (variable declarations) - removed repeated code
- Undid the VarAss->(depends on)->VarDec, reverted back to VarDec->(depends on)->VarAss, fixed by #66 (and closes it and #11)
- Added support for `IfStatement` (if statements) in `generalPass(Container, Context)`

Test cases

- Added new test case testing nested if statements (`nested_conditions.t`)
- Added another test case for if statements, `simple_conditions.t`
2022-12-19 15:37:55 +02:00
Tristan B. Velloza Kildaire ed9aa3637c Lexer
- Update column position
2022-12-17 20:44:14 +02:00
Tristan B. Velloza Kildaire dc607cdcd0 Lexer
- Added support for equality operator `==` (fixes issue #65
2022-12-17 20:40:45 +02:00
Tristan B. Velloza Kildaire c1efb0c819 Added unit test to test floating point empty string test in lexer 2022-10-01 15:26:13 +02:00
Tristan B. Velloza Kildaire 806814f01c Fixed bug whereby `isNumericalStr()` returned true for empty strings.
This fixes problems whereby if the current build up was empty and a field accessor was being attempted then lexing would fail.
2022-09-27 09:29:01 +02:00
Tristan B. Velloza Kildaire 7e49cf1d0a Added float support
- Added float constant support to the lexer
- Added float support to the typechecker to build the correct Instruction type

Unit tests

- Added unit test for a bad example of a malformed encoded floating point to test out the lexer
2022-08-11 10:26:30 +02:00
Tristan B. Velloza Kildaire 2dbe14b490 WIP: Floating pooint literal/constant support 2022-07-26 11:16:51 +02:00
Tristan B. Velloza Kildaire c58bf07bb1 WIP: Trying to get literal encoding working (but it is currently broken) 2021-11-10 17:01:12 +02:00
Tristan B. Velloza Kildaire dd8e5e8b0b Added `;` as splitter 2021-04-01 14:56:42 +02:00
Tristan B. Velloza Kildaire 0445534cda Refactored symbols 2021-03-30 17:35:16 +02:00
Tristan B. Velloza Kildaire 61aaa84daf Fixed parsing of dot-path identifiers
Updated test case
2021-03-29 13:48:32 +02:00
Tristan B. Velloza Kildaire e469cc3ec3 Added functions to lexer to aid in dot-identifier parsing
Made isPathIdentifier public

Updated test case
2021-03-29 13:44:09 +02:00
Tristan B. Velloza Kildaire e003a9879f Removd testing stuff 2021-03-29 13:34:30 +02:00
Tristan B. Velloza Kildaire 9c72756336 Added support for lexing `a.a`
Moved `isAlpha` to utils.d

Return false on lexing failures, true otherwise

Abort compilation and lexing failures
2021-03-28 19:48:07 +02:00
Tristan B. Velloza Kildaire 1abbf31f56 WIP: Support for `x.x.x` ideas 2021-03-28 12:11:13 +02:00
Tristan B. Velloza Kildaire 28c7bc4d3e Added new splitter 2021-03-04 23:25:24 +02:00
Tristan B. Velloza Kildaire 484353f6a9 Adjusted column number to be a little closer to home (might change later when I try to make column numbers more accurate) 2021-03-03 13:30:41 +02:00
Tristan B. Velloza Kildaire 49d0fc0086 Fixed column number tracking 2021-03-03 13:14:41 +02:00
Tristan B. Velloza Kildaire c439b4792c Integrated new Token type with lexer, now tokens take with them their line number and column number 2021-03-03 12:11:57 +02:00
Tristan B. Velloza Kildaire ef554befa4 Refactored lexer state variables to instance fields rather than local variables 2021-03-03 11:45:23 +02:00
Tristan B. Velloza Kildaire 8d24f6ada2 Added new-line support
Also added tracking for line number
2021-03-03 11:41:16 +02:00
Tristan B. Velloza Kildaire 2ceaa0c8b0 Added Token class for future use in lexer 2021-03-03 11:05:57 +02:00
Tristan B. Velloza Kildaire 1c2684814f Added TODO to do more tests 2021-03-03 11:02:03 +02:00
Tristan B. Velloza Kildaire 0f8862aedf Corrected module placement 2021-03-03 10:54:30 +02:00