Giter Site home page Giter Site logo

billhails / cekf Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 3.68 MB

Low level (C) implementation of a CEK machine with an additional "F" failure continuation supporting amb

License: GNU General Public License v3.0

Makefile 0.54% C 70.07% Scheme 1.87% Python 21.50% Lex 0.77% Yacc 2.69% Haskell 0.27% Racket 2.16% Shell 0.12%
interpreter language vm cek

cekf's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cekf's Issues

Improve Arithmetic

  • General overhaul.
  • move to libgmp?
  • trig functions.
  • Pre-compute constant values at compile time.
  • allow numeric (not symbolic) arithmetic expressions in patterns.
  • allow unpacking of numerator and denominator variables in patterns.
    • special case: a / b because there is a canonical form (via gcd).
    • match would fail if the actual argument is not integer or rational.
    • b would be bound to 1 if the argument was an integer.
    • can't allow arbitrary ops and combinations because i.e. (a + 2) * b
      can't uniquely determine a and b, and a ** 2 would require a
      to be bound to the square root of the actual argument.
  • allow unpacking of the real and imaginary parts of a complex number in patterns.
    • another special case: a + b, b would be bound to 0i if the actual
      argument is not complex.

overhaul runtime stack manipulation

depends on #83

  • Probably first do some profiling to verify that performance is hampered by all of the stack copying that goes on when reinstating continuations etc. I can't see how it isn't though.
  • Investigate options for only, or mostly only, manipulating pointers to stacks instead. call/cc will complicate this of course, because continuations are re-usable.

Much better error reporting

some progress already made with the ParserInfo struct but cant_happen is being used everywhere for conditions that are just errors in the input.

Aliases

alias string = list(char) is the main driver.

Replace the CEKFs support code with generated code

The run-time engine of this project is some of the earliest code, and the tooling for code generation wasn't there at that time. Now the code-generation is more mature it would be good to replace all that hand-written boilerplate with generated code, reducing the maintenance overhead and gaining access to extra features that the CG provides.

UTF8 and `wchar_t`

  • Would play nicely with strings being lists of char.
  • Store the Unicode code points internally.
  • Combining characters need special handling.

overhaul ANF conversion

The ANF conversion code is messy and potentially has bugs, which are likely adding unnecessary let bindings which will significantly slow down the run-time. The current plan is to write the ANF conversion in F Natural itself, then convert that to C. Problem is that the ANF examples to hand are written in scheme using CPS, making conversion from F Natural to C non-trivial.

User defined operators

  • With precedence and associativity.
  • infix 55 left >>= fn(l, r) { ... }
  • prefix 45 $ fn(a) { ... }
  • suffix 60 ! factorial

The main thing to figure out is scoping, it should be relatively easy to add these to a parser but they may also need to be removed when they go out of scope.

Unpacking function return values

Tuples only, a tuple returned from a function should be directly unpackable without requiring a switch, i.e.

#(a, b) = somefunc();

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.