Code Monkey home page Code Monkey logo

birblang's Introduction

Birb

Dart CI Deploy Discord

Minimal Birb programming language!

Contribution

$ pub get
$ dart2native lib/birb.dart
  • When ready, open and pull request and request a review from me - Calamity210.

Docs

https://birbolang.web.app/

birblang's People

Contributors

akramizz avatar andy-python-programmer avatar calamity210 avatar mrbirb avatar xxmrphdxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

birblang's Issues

[BUG] Infinite loop when performing operations on parameters

Performing operations on function parameters causes the program to get stuck within an infinite loop

Steps to reproduce the behavior:

  1. Launch birb shell with the birb command
  2. Type
void addAndPrint(int a, int b) {
   screm(a+b);
}

addAndPrint(5, 7);
  1. Run program with runBirb() command
  2. See error

The program should be printing 12

Starts the loop within visitFuncCall (runtime.dart)

Semi-colons aren't enforced

Describe the bug
Running a program without semi colons would generally run the first line correctly, but ignore all other lines rather than throwing an error

To Reproduce

screm(0)
screm(1);

Notice how only 0 is scremed

Expected behavior
Expect an error to be thrown stating that a semi-colon is expected

Improve testing framework

Describe the solution you'd like
We need a better testing framework. A way so we can test expected outputs and errors from birb code. Something like

screm("Hello World") // expect: Hello World

and then the test would parse the comment to get what's expected. This is not to be confused with a testing framework for birb itself, this is solely to test this repo

Correct how data types are handled by the parser

Describe the bug
The parser currently expects any occurrence of a data type to lead to a function/variable definition. This causes us to not be able to add type specific classes.

Example
We should be able to add a function for strings such as String.fromCharCode(), but calling this would throw an UnexpectedTokenException as it is expecting an identifier (the name of a variable)

To Reproduce
N/A

Add `use` and not pollute namespace

Add use:

Syntax

use library.someClass.someFunction;
use library.someFunction;
use library.someVariable;

// Multiple use’s
use library.{someClass, someVar, someFunc};

Update grab to not pollute:

grab("somelib");

// To access the function
somelib.someFunc();

This is tbh p easy so this can be marked as a good first issue! :)

Super Enums

Add enums with super powers!

  1. Enums with string values.
enum {
    a = "Hello",
    b = "Allo",
    c = "Bonjour",
} example;
  1. Enums with int values.
enum {
    a = 0,
    b = 500,
    c = 600,
} example;
  1. Enums with constructors.
enum {
    String(String),
    Bool(bool),
} example;

[BUG] Wrong line number given for errors

Errors always point to line 1

To Reproduce
Steps to reproduce the behavior:

  1. Launch birb shell with the birb command
  2. Type
String bar = "hello";
int I = 0;
screm(foo);
  1. Run program with runBirb() command
  2. See error

Expected behavior
An error pointing to line 3 stating that the variable foo does not exit

Add constructor()

Describe the solution you'd like
Add constructor() methods in classes. Mainly add arguments support in classes.

Additional context
N/A

[BUG] Can't chain operations

Describe the bug
Chaining operations results in an error. As an example, for "foo".length.isEven. The attribute access is handled as "foo.(length.isEven)" rather than (foo.length).isEven

To Reproduce
Steps to reproduce the behavior:

  1. Launch birb shell with the birb command
  2. Type
String str = "Foo";
bool isEven = str.length.isEven;
  1. See error

Expected behavior
Expect bool isEven to be false

Logs
Unhandled exception:
UndefinedVariableException: Error: [Line 2] Undefined variable `length`.
#0      visitVariable (package:Birb/runtime/runtime.dart:407:3)
<asynchronous suspension>
#1      visit (package:Birb/runtime/runtime.dart:211:20)
#2      visitAttAccess (package:Birb/runtime/runtime.dart:900:22)
#3      visit (package:Birb/runtime/runtime.dart:267:20)
#4      visitAttAccess (package:Birb/runtime/runtime.dart:1011:24)
<asynchronous suspension>
#5      visit (package:Birb/runtime/runtime.dart:267:20)
#6      visitVarDef (package:Birb/runtime/runtime.dart:438:34)
#7      visit (package:Birb/runtime/runtime.dart:213:20)
#8      visitCompound (package:Birb/runtime/runtime.dart:866:25)
<asynchronous suspension>
#9      visit (package:Birb/runtime/runtime.dart:241:20)
#10     main (package:Birb/birb.dart:93:9)
#11     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#12     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Process finished with exit code 255

[BUG] statements with single statement body expect their outer compound statement to end

Describe the bug
if, for, while to name a few take a body statement. In general, this is either a single statement or a compound statement.
Statements that take a single statement body expect their outer compound statement to end If they are nested inside a compound statement, ie, they expect a RBRACE ('}') token after the single statement

if (true) {
  if (true)
    screm('true is true');
//v--- The parser throws unexpected token error
  screm('just testing');
}

If they aren't nested they run, but the program ends after the single statement.

if (true)
  screm('true is true');
// program ends here
screm('just testing');

To Reproduce
Steps to reproduce the behavior:

  1. Run the above provided birb programs

Actual Results
The first program throws the following error:
UnexpectedTokenException: [Line 4] Unexpected token `screm`, was expecting `TokenType.TOKEN_RBRACE`
The second program outputs the following:
true is true

Expected Behaviour
Expected the first program to run without errors and the second program to not end after the single statement body. Also both programs should output:

true is true
just testing

[BUG] break and continue don't work as expected

Describe the bug
break and continue don't work if they are not direct children of the for loop body AST

To Reproduce
Steps to reproduce the behavior:
1- Run the following birb program

for (int j = 0; j < 5; j++) {
    if (j == 2) {
        break;
    }
    screm(j);
}

for (int k = 0; k < 5; k++) {
    if (k == 3) {
        continue;
    }
    screm(k);
}

Actual Results
first loop outputs 0 1 2 3 4
second loop outputs 0 1 2 3 4

Expected behavior
The first loop should output 0 1
The second loop should output 0 1 2 4

Additional context
The way this should be handled is by throwing an exception in visitBreak and visitContinue. The exception should be caught and handled by the loops (for and while). These exceptions aren't an indication of an error, but rather used as a flow control to unwind the call stack to the loops handling functions.

[BUG] Reassigning a variable causes a null exception to be thrown

Describe the bug
Reassigning a variable causes a null exception to be thrown.

Unhandled exception:
NoSuchMethodError: The getter 'type' was called on null.
Receiver: null
Tried calling: type
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      visitVarAssignment (package:Birb/utils/runtime.dart:504:17)
<asynchronous suspension>
#2      visit (package:Birb/utils/runtime.dart:219:20)
#3      visitCompound (package:Birb/utils/runtime.dart:869:25)
<asynchronous suspension>
#4      visit (package:Birb/utils/runtime.dart:245:20)
#5      main (package:Birb/birb.dart:43:15)
#6      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

To Reproduce
Steps to reproduce the behavior:

  1. Launch birb shell with the birb command
  2. Type
var x = 1;
x = 2;
  1. Run program with runBirb command
  2. See error

Expected behavior
Expected no error to be thrown

Dynamic Library ( C++, Rust, General FFI Support )

This is a very important thing that a language should have. Even though if its inbuilt std lib is not good then its P easy to use ffi and make a amazing library and add it to github and include it in your project using nest.

[BUG] Garbage Collector Is Broken

Describe the bug
In birb:ui when I move the mouse a bit fast or is off the screen and comes back again then I get this exception:

Unhandled exception:
Concurrent modification during iteration: Instance of 'ListQueue<ASTNode>'.
#0      ListQueue._checkModification (dart:collection/queue.dart:800:7)
#1      _ListQueueIterator.moveNext (dart:collection/queue.dart:910:12)
#2      collectAndSweepGarbage (package:Birb/runtime/runtime.dart:109:38)
#3      visitCompound (package:Birb/runtime/runtime.dart:948:3)

Full Logs:

PS C:\Users\user\Desktop\Andy\Projects\Birb\BirbLang> dart .\lib\birb.dart .\examples\ui.birb
lib/birb.dart: Warning: Interpreting this as package URI, 'package:Birb/birb.dart'.
1 : 26725049000
0 : 26725048952
0 : 26725048952
0 : 26725048952
0 : 26725048952
1 : 26725049000
0 : 26725048856
0 : 26725048856
0 : 26725048856
0 : 26725048856
0 : 26725048856
0 : 26725048856
0 : 26725048776
0 : 26725048776
Unhandled exception:
Concurrent modification during iteration: Instance of 'ListQueue<ASTNode>'.
#0      ListQueue._checkModification (dart:collection/queue.dart:800:7)
#1      _ListQueueIterator.moveNext (dart:collection/queue.dart:910:12)
#2      collectAndSweepGarbage (package:Birb/runtime/runtime.dart:109:38)
#3      visitCompound (package:Birb/runtime/runtime.dart:948:3)
<asynchronous suspension>
#4      visit (package:Birb/runtime/runtime.dart:282:20)
<asynchronous suspension>
#5      runtimeFunctionCall (package:Birb/runtime/runtime.dart:192:16)
<asynchronous suspension>
#6      runtimeFuncLookup (package:Birb/runtime/runtime.dart:834:18)
<asynchronous suspension>
#7      visitFuncCall (package:Birb/runtime/runtime.dart:905:36)
#8      mouseCallback (package:Birb/external/ui.dart:33:3)
#9      _FfiCallbackmouseCallback (dart:ffi)
#10     FfiTrampoline (dart:ffi)
#11     windowClass.<anonymous closure> (package:Birb/external/ui.dart:99:19)
#12     visitAttAccess (package:Birb/runtime/runtime.dart:1091:67)
<asynchronous suspension>
#13     visit (package:Birb/runtime/runtime.dart:323:20)
<asynchronous suspension>
#14     visitCompound (package:Birb/runtime/runtime.dart:932:35)
<asynchronous suspension>
#15     visit (package:Birb/runtime/runtime.dart:282:20)
<asynchronous suspension>
#16     visitWhile (package:Birb/runtime/runtime.dart:2120:27)
<asynchronous suspension>
#17     visit (package:Birb/runtime/runtime.dart:317:20)
#18     visitCompound (package:Birb/runtime/runtime.dart:932:35)
<asynchronous suspension>
#19     visit (package:Birb/runtime/runtime.dart:282:20)
#20     main (package:Birb/birb.dart:97:11)
#21     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#22     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)```

Improve Birb Documentation

Our documentation currently contains only a tour, String, Map, and Int. We need to:

  • Expand on the current documentation: (Types of Strings, escape characters (Strings), Map key types (Only Strings are supported), etc...).
  • And also document the remainder of our core types, such as bool, or double, as well as standard methods(grab, etc...) or libraries (math, io, etc...).

Once we've caught up the docs, I plan on enforcing documenting (where possible) changes made in a PR.

[BUG]

Describe the bug
Cant access Lists or Maps from within a class directly

To Reproduce
Steps to reproduce the behavior:

  1. Launch birb shell with the birb command
  2. Type
class Foo {
   List list = ["value"];
}

screm(Foo.list[0]);
  1. Run program with runBirb command
  2. See error

Expected behavior
Expected to print value.

Additional context
The scope gets messed up and the program tries to find a list within the global scope.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.