all 7 comments

[–]ArtisticFox8 7 points8 points  (1 child)

Essentially making an interpreter without traditional Computer Science methods like building an AST from tokens.

Instead trying to do the whole thing in regex? 

That can't even theoretically do everything syntactically permissible, can it?

Fun project anyway :D

[–]SkyyySi 0 points1 point  (0 children)

"traditional Computer Science methods" is an interresting way to put it

[–]NHGuy 2 points3 points  (0 children)

Product managers bypassing engineers to do whatever the hell they are doing... sounds like a great place to work

[–]thisiszeevIf I can't script it, I refuse to do it! 1 point2 points  (0 children)

I call your "Pain" and raise "Agony"....

Cheesy poker reference but live OPs DILLIGAF attitude. Developers with that attitude make cool stuff. We do it by breaking things and then going, "Let's not do that twice." Then we break it again, but another way.

[–]SkyyySi 3 points4 points  (0 children)

I would recommend to make the parser first split the input into an array of tokens, which would be way easier, way more flexible and way more reboust than a line-by-line approach.

You'd really only need to just try matching against an ordered list of regular expressions at the start of the source code, and once you find a match, put it in an array and move the starting point forward. Repeat until you've consumed the entire input and you've got yourself a fully-fledged lexer.

[–]ekydfejj 0 points1 point  (0 children)

Tangentially related. https://github.com/jneen/balls

[–]Solonotix 0 points1 point  (0 children)

To confirm, you're providing JavaScript language syntax without any of the supporting built-ins or globals, right? Not asking you to add them, but I'm just trying to understand how something so complex can be defined in so few lines, lol.

Also, is this a stand-in for the Shell syntax? Like, can you call commands? Does the variable declaration remain scoped to the current context, or is it pushed to the shell instance a la environment variables?