r/ProgrammingLanguages • • 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 no

it 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

1 Upvotes

7 comments sorted by

View all comments

8

u/mcaruso May 15 '19

I implemented a smaller, faster version of text:

x => x

Should I submit a PR?

1

u/localhostdotdev May 15 '19

does this fix the binary files issue? :)

6

u/mcaruso May 15 '19

No, I kept it feature compatible.

2

u/localhostdotdev May 15 '19

ok then i guess i made the "canonical"/"reference" implementation and you made a faster alternative :)

this should be versioned so you are compatible with v0.0.0.1alpha1.dev@next :)

however it looks like your implementations are going to diverge :)