Skip to content

ASFv2.0.0

Choose a tag to compare

@ws-garcia ws-garcia released this 17 Jan 04:42
· 200 commits to main since this release
50ea4c7

Summary

ASF v2.0.0 is a significant improvement over the previous version. This version adds support for classes, object literal methods, debug tracing, and extends the coverage of the test suite. Also the documentation is now more complete.


Highlights

  • Added

    • let keyword support
    • Bitwise or (|) operator
    • undefined data type
    • Support for classes:
       class Shape {
         field x = 0, y = 0, color = 'black';
         constructor(x, y) {
       	this.x = x;
       	this.y = y;
         };
         getPosition() {
       	return this.x + ',' + this.y;
         };
       };
       class Circle extends Shape {
         field radius = 1;
         constructor(x, y, r) {
       	super(x, y);
       	this.radius = r;
       	this.color = 'red';
         };
         getArea() {
       	return 3.14159 * this.radius * this.radius;
         };
       };
       let circle = new Circle(10, 20, 5);
       print('Position: ' + circle.getPosition()); // => 'Position: 10,20'
       print('Color: ' + circle.color); // => 'Color: red'
       print('Area: ' + circle.getArea()); // => 'Area: 78.53975'
    • Objects methods:
    o = {apple: 10, banana: 20, cherry: 30}; result = o.filter(fun(val, key) { return key.startsWith('a') }); 
    return result; // => { apple: 10 }
    • The ASF.ReadTextFile method allows users to get source code from text files.
    • Language reference documentation.
  • Internal core change:

    • VM:
      • Improved step in for node: now supports compound assignments

      • Users can now inspect the call stack through debug tracing.

         Dim ASF_ As New ASF
         Dim code As String
         
         ' Enable call tracing
         ASF_.EnableCallTrace = True
         
         code = "fun add(a, b) { return a + b; };" & vbCrLf & _
         	   "fun multiply(a, b) { return a * b; };" & vbCrLf & _
         	   "x = add(3, 4);" & vbCrLf & _
         	   "y = multiply(x, 3);" & vbCrLf & _
         	   "print(y)"
         		
         Dim idx As Long
         idx = ASF_.Compile(code)
         ASF_.Run idx
         
         ' Print the call stack trace
         Debug.Print "=== Call Stack Trace ==="
         Debug.Print ASF_.GetCallStackTrace()
         
         ' Clear for next run
         ASF_.ClearCallStack

        The above code will print

         === Call Stack Trace ===
         CALL: add(3, 4) -> 7
         CALL: multiply(7, 3) -> 21
        
  • Fixed:

    • Compiler: fixed an error that prevented Collection variables from initializing correctly, causing a fault at compilation phase.
    • Compiler: fixed nested try-catch parsing issue.
    • Compiler: fixed try statement requiring a mandatory catch block.
    • Map container: fixed nested maps cloning bug.
    • Parser: fixed compound assignment bug.
    • VM: fixed use of non-existent property when accessing ASF_ScopeStack keys.
    • VM: fixed bug in typeOf returning numeric types when invoked with null values.
    • VM: fixed switch statement executing all cases even when a match was found.
    • Regex: fixed line of statements compiled as comment in VBA.
    • Regex: fixed greedy sub quantifier.

Full Changelog: v1.0.7...v2.0.0