Comments (6)
@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.
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.
Hi @jacoblister this is looking good.
from wax.
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.
@jacoblister Would love to see it
from wax.
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)
- Segfault while multi transpilation
- read or input from file or console HOT 2
- Railroad grammar diagram HOT 1
- What string operations are supported? HOT 1
- Casting structs (or how to handle generic functions) HOT 1
- More languages transpiling support HOT 6
- Self-hosting Compiler HOT 3
- How to #include with C backend? HOT 1
- representing unions/enums
- WAT globals interpreted as locals HOT 3
- Convert wax back
- Wax compiler in wax - working implementation
- [file error] cannot read file HOT 1
- Completion of error handling
- 向你致敬!
- Typo on `insert` operations HOT 1
- Does wax use short-circuit evaluation for boolean expressions? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wax.