masak / alma

ALgoloid with MAcros -- a language with Algol-family syntax where macros take center stage
Artistic License 2.0
137 stars 14 forks source link

Make regexes a slang #231

Open masak opened 7 years ago

masak commented 7 years ago

Regexes stand out to me as the slang: a special-purpose DSL within 007/Perl 6 for matching strings. With its own closed universe of Q nodes and its own execution semantics (backtracking). Furthermore, values enter and values leave. It screams slang.

Because of that, I think it'd be good for us to make it a slang early, simply because it's the most obvious one. Use cases that are helpful to the regex slang are likely to be helpful to other slangs too.

vendethiel commented 7 years ago

How can we make is parsed work if it is a slang?

masak commented 7 years ago

How can we make is parsed work if it is a slang?

I figure it'd still need to come pre-loaded with the default 007. That's not a big problem; I mainly want to explore as soon as possible how we can make slangs support the needs of the regex syntax.

masak commented 6 years ago

Coming back to this issue, the work I'm doing right now on #293 has made me realize how "there's not just one parser"; what we thought of as the OpScope abstraction is actually the parser's current repertiore of statements, operators, etc in all the different categories. Instead of OpScopes forming a stack that follows the program's block structure, we'll have parsers forming that stack.

Usually, two parsers adjacent on the stack will either be equivalent, or differ only in a few extra definitions. But a slang distinguishes itself by bringing in a fresh parser from somewhere else with its own ruleset. Evolution vs revolution.

(Of course, slangs also want to "escape" back out into their "parent parser", at which point things work very much like in the non-slangy case — except instead of parsers stacking (A)(A'), the slang's parser is sandwiched in the middle: (A)(B)(A').)