Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

All notable changes to Coderive are documented in this file.

## [v0.9.6] - Keyword Cleanup & Parity Fix - May 2, 2026

### 🔑 Keyword Rename: `exit` → `fin`
- Renamed void early-return keyword from `exit` to `fin` throughout the language.
- `TokenType.Keyword.EXIT` renamed to `TokenType.Keyword.FIN`.
- AST node `Exit` renamed to `Fin`; exception `EarlyExitException` renamed to `EarlyFinException`.
- IR serialization tag updated from `"Exit"` to `"Fin"` (no backward compatibility required; pre-release).
- All parser, printer, lowerer, and visitor references updated accordingly.

### 🚫 Removed Keyword Aliases
- Removed `continue` → `skip` and `return` → `fin` compatibility aliases from `IdentifierLexer`.
- Only explicit `skip` and `fin` keywords are now recognized as control-flow statements.

### 📝 Source File Updates
- Updated all `.cod` demo and standard-library files to use `fin` instead of `exit`/`return` and `skip` instead of `continue`:
- `std/json/Json.cod`
- `std/scimath/SciMath.cod`
- `demo/src/main/test/controlflow/ControlFlow.cod`
- `demo/src/main/test/json/JsonStandardLibraryComprehensive.cod`

### ✅ Parity & Java Compatibility
- Fixed `CodPTACParityRunner` normalize function to handle timing output of the form `"... at <N> ms"` (fixes `BMark.cod` parity mismatch).
- Verified Java 7 source/target compatibility; all sources compile cleanly with `-source 1.7 -target 1.7`.
- All parity tests pass after keyword migration.

### 📊 BMark primeCount Baseline (primeCount(5000))
- Baseline run (PTAC executor, Java 17): `~1280 ms`, checksum `2666668685121930669`.

## [v0.9.5] - JSON Stabilization - April 18, 2026

### 🧩 JSON Parser & Serializer Fixes
Expand Down
6 changes: 3 additions & 3 deletions src/main/cod/demo/src/main/test/controlflow/ControlFlow.cod
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ share ControlFlow {

out("sum=" + sum)

out("exit:before")
exit
out("exit:after-should-not-print")
out("fin:before")
fin
out("fin:after-should-not-print")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ share JsonStandardLibraryComprehensive {
share check(label: text, actual: text, expected: text) {
if actual == expected {
out("PASS " + label)
return
fin
}
out("FAIL " + label)
out(" actual: " + actual)
Expand All @@ -16,7 +16,7 @@ share JsonStandardLibraryComprehensive {
share checkBool(label: text, actual: bool, expected: bool) {
if actual == expected {
out("PASS " + label)
return
fin
}
out("FAIL " + label)
out(" actual: " + actual)
Expand Down
52 changes: 26 additions & 26 deletions src/main/cod/std/json/Json.cod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ share JsonValue {
}

share add(item: JsonValue) {
if this.kind != 4 { return }
if this.kind != 4 { fin }
idx: int = this.arrayData.size
arrayData[idx] = item
}
Expand All @@ -48,11 +48,11 @@ share JsonValue {
}

share set(key: text, value: JsonValue) {
if this.kind != 5 { return }
if this.kind != 5 { fin }
for i of 0 to this.objectKeys.size - 1 {
if this.objectKeys[i] == key {
objectValues[i] = value
return
fin
}
}
idx: int = this.objectKeys.size
Expand Down Expand Up @@ -262,41 +262,41 @@ share Json {
if Json.isUnicodeEscapeAt(raw, idx) {
outText = outText + raw[idx to idx + 5]
idx = idx + 6
continue
skip
}
outText = outText + "\\\\"
idx = idx + 1
continue
skip
}
if ch == "\"" {
outText = outText + "\\\""
idx = idx + 1
continue
skip
}
if ch == "\n" {
outText = outText + "\\n"
idx = idx + 1
continue
skip
}
if ch == "\r" {
outText = outText + "\\r"
idx = idx + 1
continue
skip
}
if ch == "\t" {
outText = outText + "\\t"
idx = idx + 1
continue
skip
}
if ch == "\b" {
outText = outText + "\\b"
idx = idx + 1
continue
skip
}
if ch == "\f" {
outText = outText + "\\f"
idx = idx + 1
continue
skip
}
outText = outText + ch
idx = idx + 1
Expand Down Expand Up @@ -491,14 +491,14 @@ share JsonParser {
esc := this.source[this.index]
index = this.index + 1

if esc == "\"" { outText = outText + "\"" continue }
if esc == "\\" { outText = outText + "\\" continue }
if esc == "/" { outText = outText + "/" continue }
if esc == "b" { outText = outText + "\b" continue }
if esc == "f" { outText = outText + "\f" continue }
if esc == "n" { outText = outText + "\n" continue }
if esc == "r" { outText = outText + "\r" continue }
if esc == "t" { outText = outText + "\t" continue }
if esc == "\"" { outText = outText + "\"" skip }
if esc == "\\" { outText = outText + "\\" skip }
if esc == "/" { outText = outText + "/" skip }
if esc == "b" { outText = outText + "\b" skip }
if esc == "f" { outText = outText + "\f" skip }
if esc == "n" { outText = outText + "\n" skip }
if esc == "r" { outText = outText + "\r" skip }
if esc == "t" { outText = outText + "\t" skip }

if esc == "u" {
firstUnit := this.parseHex4At(this.index)
Expand All @@ -522,15 +522,15 @@ share JsonParser {
}
index = this.index + 4
outText = outText + firstText + "\\u" + Json.hex4(secondUnit)
continue
skip
}

if Json.isLowSurrogate(firstUnit) {
~> (JsonValue.makeError("unexpected low surrogate at index " + (this.index - 4)))
}

outText = outText + firstText
continue
skip
}

~> (JsonValue.makeError("invalid escape sequence \\" + esc + " at index " + (this.index - 1)))
Expand Down Expand Up @@ -627,7 +627,7 @@ share JsonParser {
if all[this.index < this.source.length, this.source[this.index] == "]"] {
~> (JsonValue.makeError("trailing comma in array at index " + this.index))
}
continue
skip
}

if ch == "]" {
Expand Down Expand Up @@ -683,7 +683,7 @@ share JsonParser {
if all[this.index < this.source.length, this.source[this.index] == "\}"] {
~> (JsonValue.makeError("trailing comma in object at index " + this.index))
}
continue
skip
}

if ch == "\}" {
Expand All @@ -699,13 +699,13 @@ share JsonParser {

share skipWhitespace() {
for n of this.index to this.source.length {
if this.index >= this.source.length { return }
if this.index >= this.source.length { fin }
ch := this.source[this.index]
if any[ch == " ", ch == "\n", ch == "\r", ch == "\t"] {
index = this.index + 1
continue
skip
}
return
fin
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/cod/std/scimath/SciMath.cod
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ share SciMath {
ssBetween: int|float = 0
ssWithin: int|float = 0
for g of 0 to groups.size - 1 {
if groups[g].size == 0 { continue }
if groups[g].size == 0 { skip }
meanG: int|float = 0
for i of 0 to groups[g].size - 1 {
meanG = meanG + groups[g][i]
Expand Down Expand Up @@ -251,7 +251,7 @@ share SciMath {
if n <= 0 { ~> (0) }
chi2: int|float = 0
for i of 0 to n - 1 {
if expected[i] <= 0 { continue }
if expected[i] <= 0 { skip }
d := observed[i] - expected[i]
chi2 = chi2 + d * d / expected[i]
}
Expand Down Expand Up @@ -295,7 +295,7 @@ share SciMath {
aug[c][j] = aug[c][j] / pivot
}
for r of 0 to n - 1 {
if r == c { continue }
if r == c { skip }
factor := aug[r][c]
for j of 0 to (2 * n) - 1 {
aug[r][j] = aug[r][j] - factor * aug[c][j]
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/cod/ast/ASTFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,12 @@ public static Var createVar(String name, Expr value, Token nameToken) {
return var;
}

public static Exit createExit(Token exitToken) {
Exit exit = new Exit();
if (exitToken != null) {
exit.setSourceSpan(span(exitToken));
public static Fin createFin(Token finToken) {
Fin fin = new Fin();
if (finToken != null) {
fin.setSourceSpan(span(finToken));
}
return exit;
return fin;
}

public static ArgumentList createArgumentList(List<Expr> arguments, Token lparenToken) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cod/ast/ASTPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ public Void visit(Range node) {
}

@Override
public Void visit(Exit node) {
println("EXIT");
public Void visit(Fin node) {
println("FIN");
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cod/ast/ASTVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public T visit(Range n) {
}

@Override
public T visit(Exit n) {
public T visit(Fin n) {
return n.accept(this);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cod/ast/VisitorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public interface VisitorImpl<T> {

T visit(Range n);

T visit(Exit n);
T visit(Fin n);

T visit(Tuple n);

Expand Down
13 changes: 0 additions & 13 deletions src/main/java/cod/ast/node/Exit.java

This file was deleted.

12 changes: 12 additions & 0 deletions src/main/java/cod/ast/node/Fin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package cod.ast.node;

import cod.ast.VisitorImpl;

public class Fin extends Stmt {

@Override
public final <T> T accept(VisitorImpl<T> visitor) {
return visitor.visit(this);
}

}
6 changes: 3 additions & 3 deletions src/main/java/cod/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ private void executeMainMethod(Type ownerType, Method mainMethod, String entryTa
}
}
DebugSystem.methodExit("main", null);
} catch (EarlyExitException e) {
} catch (EarlyFinException e) {
DebugSystem.methodExit("main", null);
} catch (ProgramError e) {
throw e;
Expand Down Expand Up @@ -939,7 +939,7 @@ public Object evalMethod(Method node, ObjectInstance obj, Map<String, Object> lo
}
}
}
} catch (EarlyExitException e) {
} catch (EarlyFinException e) {
// Normal exit
} catch (ProgramError e) {
throw e;
Expand Down Expand Up @@ -1151,7 +1151,7 @@ public Object evalMethodCall(
}
}
}
} catch (EarlyExitException e) {
} catch (EarlyFinException e) {
} catch (ProgramError e) {
throw e;
} catch (Exception e) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/cod/interpreter/InterpreterVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ public Object visit(Range n) {
}

@Override
public Object visit(Exit node) {
throw new EarlyExitException();
public Object visit(Fin node) {
throw new EarlyFinException();
}

@Override
Expand Down Expand Up @@ -780,8 +780,8 @@ private Object evaluateLambdaAssignment(
} else {
throw tailCallSignal;
}
} catch (EarlyExitException e) {
// normal lambda early exit
} catch (EarlyFinException e) {
// normal lambda early fin
} finally {
popContext();
}
Expand Down Expand Up @@ -1583,8 +1583,8 @@ public Object visit(MethodCall node) {
} else {
throw tailCallSignal;
}
} catch (EarlyExitException e) {
// Normal exit - method completed
} catch (EarlyFinException e) {
// Normal fin - method completed
} catch (ProgramError e) {
throw e;
} catch (Exception e) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cod.interpreter.exception;

@SuppressWarnings("serial")
public class EarlyFinException extends RuntimeException {
public EarlyFinException() {
super("Early fin");
}
}
Loading