Code Monkey home page Code Monkey logo

primi's People

Contributors

fredsted avatar smuuf 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

primi's Issues

Cannot load modules in nomorearray branch

i have tried to run the test for nomorearray branch but i got errors because the modules not loaded

https://github.com/smuuf/primi/tree/nomorearray

Run chmod +x ./primi ./bin/* && ./bin/test --php phpdbg --coverage xml
███ Smoke tests
Running: /example/comparisons.primi ...
Running: /example/dict.primi ...
Running: /example/errors_invoking_nonfunctions.primi ...
Running: /example/errors_wrong_inserting.primi ...
Running: /example/ext.bool.primi ...
Running: /example/ext.dict.primi ...
Running: /example/ext.list.primi ...
Running: /example/ext.number.primi ...
Smuuf\Primi\Ex\ErrorException: Undefined variable 'cos' @ <main: file /home/runner/work/primi/primi/example/ext.number.primi> on line 38, position 5
Traceback:
[0] <main: file /home/runner/work/primi/primi/example/ext.number.primi>

how we can load the modules

i have tried without any success

Support for import aliasing

Currently import std.types will always import module types into variable types, or import std.term.colors: Fg will always import name Fg from module std.term.colors into variable Fg.

What we want to allow are these:

>>> import std.types as lol_std_types

... or:

>>> import import std.term.colors: Fg as colors_fg

... or even:

>>> import import std.term.colors: Fg as colors_fg, Bg as colors_bg

else-if

Hi - it would be good if the if() built-in function had the ability to include else-if clauses.
I hope you might consider.

Kind regards
Rick

Undefined offset error when passing string to dict constructor

>>> dict("ahoj")

PHP ERROR ErrorException: Undefined offset: 1 @ ./src/Structures/MapContainer.php:68
...

The same error can be spawned with:

>>> dict([[1]])

PHP ERROR ErrorException: Undefined offset: 1 @ ./src/Structures/MapContainer.php:68

And with:

>>> dict([[]])

PHP ERROR ErrorException: Undefined offset: 0 @ ./src/Structures/MapContainer.php:68

Documentation issue

I tried using Primi, however, could not get it to run the example. If I try to use the latest release (v0.4), it seems to not support php 8.2. If I try to use the dev version, the example in readme, does not work, as there appears to be a change in the construction of Context and Interpreter...

How to create ArrayValue from multidemensional array

Hello! Interesting development!

My question, is it possible to translate regular PHP multidimensional array into a multidimensional array ArrayValue of ArrayValue of Values.

For example:

$arrayValuesOfArrayValues = new ArrayValue(
[
  ['title' => 'hello'],
  ['title' => 'world']
]
)

UPD

Or maybe I have json array from user, and I want pass this array to Primi. How can I do it?

Insides of a class method should have access to scope where the class was defined

Scope of a method should have access to "global" variables from the current module where the class was defined. At the same time method scope should NOT have direct access to attributes of the class (these should be accessible only via self - and that's how it already is).

Example

>>> oh_noes = 123
123 (number bac34a9a)

>>> class Something {
...   function some_fn(self) {
...     print(oh_noes)
...   }
... }

>>> s = Something()
<instance 'Something' e0908f3a> (Something e0908f3a)

>>> s.some_fn()
Error: Undefined variable 'oh_noes' @ <module: __main__> on line 3
Traceback:
[0] <repl: cli> in <module: __main__>
[1] some_fn() in <module: __main__> called from <module: __main__> on line 1

Otherwise this also wouldn't work:

>>> import std.math

>>> class Something {
...   function some_fn(self) {
...     math.round(123.456)
...   }
... }

... because math is imported into module's global variables.

Number 0.0000001 is recognized as string 1.0E-8 in the function result

Example:

Variable 'a' is a string.

<?php

require __DIR__ . "/vendor/autoload.php";

$context = new \Smuuf\Primi\Context;
$interpreter = new \Smuuf\Primi\Interpreter($context);


$context->setVariable('teste', \Smuuf\Primi\Structures\Value::buildAutomatic(function() {
        return 0.00000001;
}));

try {

    $interpreter->run('a = teste()'); // expect variable 'a' be a Number but it is a string

    foreach ($context->getVariables() as $name => $value) {
        printf("%s (%s) ... %s\n", $name, $value::TYPE, json_encode($value->getInternalValue()));
    }

} catch (\Smuuf\Primi\ErrorException $e) {
    die($e->getMessage());
}

No maximum recursion depth

Hi, I just stumbled across this project, and this looks very interesting.
I was playing around with it a bit and noticed that there is no maximum recursion depth.

When calling a recursive function with no stop condition, it just loops forever:

function recursive(a) { recursive(a); }

It could be a good idea to set a hard limit like PHP, especially since this language targets clients.

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.