Giter VIP home page Giter VIP logo

Comments (6)

jacoblister avatar jacoblister commented on May 28, 2024 2

@fuzzthink - I've added a clone of my wax language implementation at https://github.com/jacoblister/rewax

It's pretty rough, but it should build - on Linux at least, or in VSCode with Docker. There is a .devcontainer in the project to setup an Ubuntu docker container in VSCode. Mostly it needs the node environment to bootstrap it for this.

git clone https://github.com/jacoblister/rewax
cd rewax
make test

will run all the test cases. For example:

./wax build --target=js test/prog_fib.wax
./wax build --target=cpp test/prog_fib.wax

will generate the currently implemented javascript and c++ targets

If you're really lucky, svg dom bindings at.

cd vdom/example
make
./svg (linux build)
or
./serve.sh (javascript version, at http://localhost:8080/example.svg

Cheers

from wax.

jacoblister avatar jacoblister commented on May 28, 2024 2

Just to mention a few extra language features too, check the test_extended directory.

I've deliberately not wanted to add much, as having a core language spec that's so simple is the real attraction, but first class functions are must have to my mind - being able assign a function to a variable, and pass to and return from another function.

Conveniently that didn't involve changing the language spec at all, and they fit in quite nicely

func.wax demonstrates this. This feature is used to register event handlers in the DOM api.

there's also an attempt at GoLang style interfaces using this in 'interfaces.wax' building on this.

from wax.

Quentie avatar Quentie commented on May 28, 2024 1

Hi @jacoblister this is looking good.

from wax.

jacoblister avatar jacoblister commented on May 28, 2024

Hi @Quentie,

This project has sparked quite a bit of interest for me, and I've got a separate implementation going, which can target JavaScript, C++ currently. It's really scratched an itch for me in terms of having a super lightweight language definition that's easy to parse and process, and can target multiple transpilation languages.

It does a fair bit, including some basic DOM integration to allow writing HTML/SVG content into a browser window. Error handling's not so great at the moment, does have a good test suite though.

If there's interest, I can put it in a public git repo. Just having a look at how I'm handing comments - currently I strip them to make the code generation phase easier, but I do have a wax language target which can process wax in/wax out for reformatting purposes - and that leaves comments intact, so it can be done.

from wax.

fuzzthink avatar fuzzthink commented on May 28, 2024

@jacoblister Would love to see it

from wax.

jacoblister avatar jacoblister commented on May 28, 2024

Yeh it's working pretty well.

The approach I've taken is to do a straight syntax translation as much as possible, and have the target language do the heavy lifting in terms of symbol resolution/type conversion etc. As such, the implementation can be very simple (the initial prototype I did was <1000 lines of code).

Ultimately I'd really like to get this running as just in time compiler, and generating native machine code on the fly - but this would involve implementing a symbol table, and a type conversion system. With only a dozen or so language elements in the core language spec, the actually machine code generation part should be quite simple though. There's a partial implementation in the file 'symbol.wax', but I wouldn't recommend looking at it - it's horrible. The JS and C++ targets don't use it, there is a C language target which does, but it's only partially implemented.

The C target is partially implemented, and doesn't support dynamic memory allocation. I'm able to generate C code from this and compile it with the TinyCC compiler on the fly https://bellard.org/tcc/. For the JavaScript target, eval() can do this. I'm using this generated code for audio DSP, which doesn't need a lot of language features.

from wax.

Related Issues (18)

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.