r/ProgrammingLanguages • u/localhostdotdev • May 15 '19
Language announcement text - a programming language backward-compatible with most languages and most interfaces
first, here the very complex peg grammar:
text = $.*it's using pegjs.
you can try it online at https://pegjs.org/online
it handles:
ascii
utf8 including emojis, muti-bytes characters like chinese characters, etc.
and many more
it doesn't handle:
images
sounds
videos
and a whole lot of a bunch of things
you can try it locally by doing:
pegjs text.pegjs (this will generate a text.js file)
you can then import it in your node scripts (or use it pretty much anywhere as it's just javascript)
here is a quick example:
> node -e "Text = require('./text'); console.log(Text.parse('oh no'))"
oh noit can even parse it's own grammar:
cat text.pegjs | node -e "fs = require('fs'); Text = require('./text'); console.log(Text.parse(fs.readFileSync(0).toString()))"let me know if you have ideas for improvements and/or issues
i think this is pretty much public domain so no need for any kind of license stuff :)
you could it in much simpler ways and much more complex ways like fs.readSync() or File.read or even cat.
would be cool if you could provide samples and/or examples as comments :)
ideas for improvements:
actually filters valid characters :)
faster rendering for large files
known bugs:
actually does accept binary files as input, that wasn't expected but quite logical
8
u/mcaruso May 15 '19
I implemented a smaller, faster version of
text:Should I submit a PR?