Coder Social home page Coder Social logo

arkscript-lang / ark Goto Github PK

View Code? Open in Web Editor NEW
577.0 577.0 44.0 5.46 MB

ArkScript is a small, fast, functional and scripting language for C++ projects

Home Page: https://arkscript-lang.dev/

License: Mozilla Public License 2.0

CMake 2.72% C++ 94.24% Shell 1.46% Dockerfile 0.57% Python 1.01%
ark arkscript compiler cpp language lisp programming-language scripting scripting-language virtual-machine vm

ark's People

Contributors

biothewolff avatar codacy-badger avatar daemononunix avatar dontbelieveme avatar eliot-akira avatar fowled avatar gryfenfer97 avatar jsanestrzik avatar loki-astari avatar mattn avatar maxnatamo avatar owenl131 avatar pierrepharel avatar piyussshh avatar qix- avatar rakista112 avatar raloverast avatar rinz13r avatar rstefanic avatar sdachess avatar shehab7osny avatar superfola avatar unactived avatar wafelack avatar yardenshoham 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ark's Issues

Build on macOS

Is your feature request related to a problem? Please describe.

I followed the build steps on macOS, until cmake --build build. It ends with:

~/lisp/Ark/include/Ark/Utils.hpp:10:10: fatal error: 'filesystem' file not found
#include <filesystem>
         ^~~~~~~~~~~~

The comment on the next step ("works on Linux and on Windows") implies that the project is not meant to be built on macOS.

Is that the case, or perhaps I'm missing a dependency?

Describe the solution you'd like

I'd love to be able to play with ArkScript on macOS.

Additional context

As context, I'm pretty much a beginner with C++, so I have no clue whether filesystem is a platform-specific thing.

Add ability to define feature flags in a project.arkopt

Instead of having to send all the argument using the command line (which can lead to a pretty long command), we should be able to have a project.arkopt for example, with a list of options which should be triggered.

For example:

cool-project/
|___ cool-project.arkopt
|___ thing.ark
|___ ...

cool-project.arkopt

# file to run
thing.ark
# options
-fno-function-arity-check
-f...

And when we run Ark cool-project it will search for a cool-project ArkScript file, but not find it, thus it should look for a cool-project.arkopt and use its content as the options of the command line.

Plugin : custom types

In this moment, I'm working on msgpack module for Ark, and I need an clear and explicit way for define custom types for modules (plugin).

Closure scopes should be raw pointers

Instead of using shared pointer, we should have raw pointers to elements in a std::list owned by the VM. (see comment)

Description related data owned by the VM should also be moved to a lighter structure (Ark::State)

performance improvement

  • remove all the empty destructors
  • do not create nil/false/true as they are available in Ark::internal::FFI

Working on the ArkScript package manager

At this point where modules are starting to be more numerous, we should (imo) consider having an ArkScript package manager.

Won't be for the 3.1.0, more like a 3.2.0 or even a 3.x.0

Question: should we put the modules in another repository?

Should we put the modules in another repository?

I'm asking this because the repository will definitely grow a lot with all the modules we are going to add, and when someone wants to start experimenting on a project, often they don't like having to download a bunch of things that they aren't going to use.

Having like a module store would be quite cool, what do you think?

Compiler reporting an error when parsing snake.ark

Describe the bug
When launching Ark tests/games/snake/snake.ark -c, it crashes because it can't create a token from (() at line 13, char 38 (this token isn't in the file).

To Reproduce
Steps to reproduce the behavior:

  1. Clone the repository
  2. git checkout rework
  3. cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build
  4. build/Ark tests/games/snake/snake.ark -c

Expected behavior
No errors expected.

Desktop (please complete the following information):

  • OS: Linux Mint 18 64bits

Additional context
Must be related to the new lexer, the parser is just reporting a bug because it uses the lexer

Add safe multithreading

If we move description related data to an Ark::State as suggested in #35, we should be able to share a single state between multiple virtual machines, thus allowing multi threading

Can't call a function stored in an array

Describe the bug
This test is failing, and so is switch.ark, since it's using the same method for defered calls.

{
    (let egg (fun (bar) (print bar)))
    (let data ["Iron Man" "is" "Tony Stark"])
    (let callbacks [])

    (let add-callback (fun (d)
        (fun () (egg d))
    ))

    (let acc 0)
    (while (!= acc (len data)) {
        (let d (@ data acc))
        (set callbacks (append callbacks (add-callback d)))
        (set acc (+ 1 acc))
    })

    (set acc 0)
    (while (!= acc (len callbacks)) {
        ((@ callbacks acc))
        (set acc (+ 1 acc))
    })
}

To Reproduce
Steps to reproduce the behavior:

  1. download the latest version, build it
  2. compile tests/callbacks.ark
  3. execute it
  4. See error

Expected behavior
We should see

Iron Man
is
Tony Stark

in the shell, not an error.

Desktop (please complete the following information):

  • OS: Linux Mint 18 x64

Additional context
Must be related to the parser

Invalid syntax segfaults the compiler

The program {(while (= 1 1) "foo" "bar")} segfaults the compiler.

(gdb) run foo.ark 
Starting program: /tmp/Ark/build/Ark foo.ark

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bce3c0 in __memcmp_avx2_movbe () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7bce3c0 in __memcmp_avx2_movbe () from /usr/lib/libc.so.6
#1  0x00007ffff7eda920 in std::char_traits<char>::compare (__n=<optimized out>, __s2=0x555555624a70 ")", 
    __s1=<optimized out>) at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:325
#2  std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare (this=0x7fffffffc6a8, 
    __s=0x555555624a70 ")")
    at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:1425
#3  0x0000555555579e4b in bool std::operator==<char, std::char_traits<char>, std::allocator<char> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*) ()
#4  0x0000555555579fe5 in bool std::operator!=<char, std::char_traits<char>, std::allocator<char> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*) ()
#5  0x000055555560171b in Ark::Parser::parse(std::__cxx11::list<Ark::internal::Token, std::allocator<Ark::internal::Token> >&, bool, bool) ()
#6  0x0000555555600156 in Ark::Parser::feed(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#7  0x00005555555ea93c in Ark::Compiler::feed(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#8  0x000055555555e67b in Ark::compile(bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#9  0x000055555557c1da in Ark::VM_t<false>::doFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#10 0x000055555555f711 in main ()

Additionally, I think that the benchmark files are missing from this repository and I had to modify build.sh because it assumed my system runs GCC 8, but Arch provides GCC 9, and ((f f) x) isn't recognised as valid syntax by the reader, but the segfault is my biggest concern now.

REPL segfaulting in a few situations

Describe the bug
The REPL segfaults when:

  1. The input is only spaces
  2. The input is only a comment (starts by optional spaces and then #)

Expected behavior
Same behavior as if the user had directly pressed <ENTER>: "nothing" (new line and new prompt)

Relevant GIF
GIF

Notes (1 & 2):
Here is the code handling the REPL when the user simply presses <ENTER>:

if (line.length() == 0)
{
    std::cout << (new_command ? new_prompt : continuing_prompt);
    continue;
}

It only checks that the line is empty.
Maybe it should instead strip whitespaces ahead (spaces and tabs notably), and then conclude:
If the resulting line starts has a length of 0 or starts with # then: ...

I'm only doing an issue as I have no idea how to do this in C++

EDIT:
The GIF also shows how {} or the equivalent (begin ) block also causes the REPL to segfaults. But this is the current behavior of Arkscript itself and isn't "the fault" of the REPL implementation.

Redo the CLI to be able to compile files only when their bytecode version is outdated

Is your feature request related to a problem? Please describe.
We should be able to use Ark file to automatically compile the file only if needed, and then execute it on the virtual machine.

Describe the solution you'd like
Check if there is a bytecode file in the Ark cache for the given input file, and if it is older than the given file, recompile. Otherwise (if not older), launch the bytecode file located in the Ark cache (maybe provide something like Python, a __arkcache__ folder). If the file isn't in the Ark cache (or if the Ark cache doesn't exist yet), compile it, put it in the Ark cache, and execute it.

Builtins and std lib modules

This issue will be used to keep track of the needed builtins and std lib functionnalities for the 3.1.0

List

  • (zip list1 list2)
  • (map func list1)
  • sorting algorithms
  • reverse array
  • find object in array
  • delete element at index and return new list
  • (slice array from_index to_index step)
  • implement forEach (already done in examples/for-each.ark, but it can be greatly improved)

Dictionnary

  • dictionnary implementation using closures see the json module

String

  • regexes
  • reverse string
  • find substring in string
  • (slice string from_index to_index step)
  • (removeAtStr string index)

Network

  • create socket
    • TCP/IP
    • UDP
  • close socket
  • send data
  • receive data
  • make ARP request
  • make ICMP packets

Mathematics

  • trigonometrics
    • cos, arccos
    • sin, arcsin
    • tan, arctan
  • exp, log
  • pow (can be implemented in ArkScript with exp and log)
  • sqrt (can be implemented in ArkScript with pow)
  • ceil, floor, round
  • sum (elements from list)
  • is infinite, is nan
  • pi, e, tau, inf, nan

SFML

  • Graphics
  • Audio
  • Window
  • System
  • Network

Not part of the standard library anymore, was moved to https://github.com/SuperFola/arksfml

Clear Console

Is your feature request related to a problem? Please describe.
As i already said, i'm doing a mini Os in Ark (#28) so it also could be useful to have an CLS method !

Describe the solution you'd like
CLS Method

Describe alternatives you've considered
(clearScreen)
(clearScreen 5) A specific number of lines
Additional context
Mmmh, For a Lot of console thing like as a Command line OS ?

End-representation of lists

Is your feature request related to a problem? Please describe.
The representation (through print) of lists are their content in parentheses.
For example (print [1 2]) outputs ( 1 2 )

This representation looks like a block (of code) and doesn't really hint that the object considered is a list.

Describe the solution you'd like
I think it would be better if the representation matched the syntactic sugar used in
the programs: [a b c]

Describe alternatives you've considered
[ a b c ], or (list a b c) (according to what the syntactic sugar refers to).

Default Program bug

Ark-windows-x64.exe Bug
After moving it to C:\Program Files (x86)\Ark\bin , i can't use it to launch the .ark file
that's kinda weird, because it worked before (when the file was on my Desktop)

Add closure.field reading

Is your feature request related to a problem? Please describe.
We must be able to read public (immutable) data from a closure.

Describe the solution you'd like
eg: (print closure.field)

Parser generating a "wrong" AST (putting begin everywhere)

Describe the bug
The parser is parsing { (let a nil) (let b false) (let c true) } as ( Begin ( Let a nil ) Begin ( Let b false ) Begin ( Let c true ) ). It's not a problem with the syntactic sugar, since we have this:

[  Info ] (Parser) After applying sugar:
   1 | (
     | begin
   2 | (
     | let
     | a
     | nil
     | )
   3 | (
     | let
     | b
     | false
     | )
   4 | (
     | let
     | c
     | true
     | )
   5 | )

To Reproduce
Steps to reproduce the behavior:

  1. compile Ark
  2. Launch it on nearly any test file with at least 2 blocks in a begin node

Expected behavior
The parser shouldn't put that many begins (one before each block, WHY?).

Desktop (please complete the following information):

  • OS: Linux Mint 18 x64

write language documentation

Since the language is evolving, its documentation should evolve as well. The language itself needs to be documented, but the standard library and the Virtual Machine/Bytecode as well

toUpperCase and toLowerCase returning "Unknown error"

Describe the bug
toUpperCase and toLowerCase returning "Unknown Error"

To Reproduce
Steps to reproduce the behavior:
1.Import Case.ark
2. try (toLowerCase "Some StringYY sTuffY") or another string NB : you can also do this with toUpperCase
3. Enjoy the bug
Note : sometimes it returns another error like bad allocation
Expected behavior
Returning the string to lowercase (or to upper)

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • OS: Windows 10 64bits
  • Version 3.0.7

Additional context
Seems to happen with the latest version of Case.ark (i tried with an old version and it works)

EOF in REPL

Describe the bug
When sending End of File to the REPL, it prints indefinitely the prompt >>

To Reproduce
Steps to reproduce the behavior:

  1. Ark -r
  2. Ctrl + D (^D)
  3. >> is printed indefinitely

Expected behavior
The REPL exits

Desktop (please complete the following information):
OS: Arch Linux
Ark compiled with g++ (GCC) 9.2.0 from branch dev

Import bugging

Describe the bug
i Tryed to run unittest.ark, and it says "ParseError: Couldn't find file Switch.ark"
Note: i run it without the --lib argument
To Reproduce
Steps to reproduce the behavior:

  1. Go to tests directory
  2. Launch unittest.ark
  3. See error

Expected behavior
I Expect to import the module, wich is already installed with Ark Releases

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows
  • Version : 3.0.5
    Additional context
    I think it's the import bugging because it happens on the first import

Adding macros

I think we should consider adding macros to the language, since it would have been (imo) very useful for some programs, and also to extend the language (eg if we want to define a forEach "keyword", which wouldn't use a function behind but directly copy the code doing the forEach thing)

Add REPL

Should be able to type in code, wait for count("(") == count(")") before compiling.
Store code in buffer, compile and execute after each line.

List all files and folders of the current directory or specified path

Is your feature request related to a problem? Please describe.
Well, i'm trying to do a sort of Command line OS (fo no reason), and i think it could be nice if i can list all files of the current Directory/Path

Describe the solution you'd like
Add a method to list all the files in a array

Describe alternatives you've considered
(listAllFiles ".") Files of the current directory (also default argument)
(listAllFiles "C:\Users\Natend\Desktop\Programmation") Mmh maybe not \
Additional context
For creation of system that can see files (a.k.a : OS, IDE, Lots of things)

Enhance builtins

We need to have at least:

  • write file
  • read file
  • file exists?
  • string concatenations
  • type
  • hasfield

Make a specific lexer instead of relying on regexes

Rules list is quite simple:

string: ^"[^"]*
number: ^((\+|-)?[[:digit:]]+)(\.(([[:digit:]]+)?))?
operator: ^(\+|\-|\*|/|<=|>=|!=|<|>|@=|@|=|\^)
identifier: ^[a-zA-Z_\u0080-\uDB7F][a-zA-Z0-9_\u0080-\uDB7F\-?']*
capture: ^&[a-zA-Z_\u0080-\uDB7F][a-zA-Z0-9_\u0080-\uDB7F\-?']*
getfield: ^\.[a-zA-Z_\u0080-\uDB7F][a-zA-Z0-9_\u0080-\uDB7F\-?']*
skip: ^[\s]+
comment: ^#.*
shorthand: ^[']
mismatch: ^.

Add a msgpack C++ module

To be able to create packed messages to send on the internet when the network module will be available.

Color and background color for console

Is your feature request related to a problem? Please describe.
Well nope, but it could be nice for reading

Describe the solution you'd like
add a method that change the color , or the background color

Describe alternatives you've considered
(consoleColor "1") (4Bits console colors)
(consoleBackgroundColor "2") (4 bits console colors)
Additional context
Mmmh, for better interactions beetwen user and program

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.