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`conditionals
parent
beb068a33c
commit
4f899c69e2
@ -0,0 +1,32 @@
|
||||
module nested_conditionals;
|
||||
|
||||
void banana()
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if(i == 1)
|
||||
{
|
||||
int pp = 22+2;
|
||||
|
||||
if(i == 2+1+i+pp)
|
||||
{
|
||||
if(i == 3+i)
|
||||
{
|
||||
i=23;
|
||||
}
|
||||
else if(1 == 1)
|
||||
{
|
||||
i=50;
|
||||
|
||||
if(50 == 5+2)
|
||||
{
|
||||
i=51;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i=6969696;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
module simple_conditions;
|
||||
|
||||
int other(int arg1, int arg2)
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
void function(int i)
|
||||
{
|
||||
int apple = 69;
|
||||
|
||||
if(i == 1)
|
||||
{
|
||||
apple = 2;
|
||||
i = i +3;
|
||||
|
||||
if(i == 40)
|
||||
{
|
||||
|
||||
}
|
||||
else if(i == 41)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else if(i == 2)
|
||||
{
|
||||
i = i +2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int banana = 24;
|
||||
banana=2+i;
|
||||
|
||||
if(banana == 2+2+other(2,2))
|
||||
{
|
||||
banana=2;
|
||||
banana=3;
|
||||
banana = other(2,3)+other(3,4);
|
||||
}
|
||||
|
||||
int pp = other(80,81);
|
||||
}
|
Loading…
Reference in New Issue