SwiftStudies / OysterKit

OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR
BSD 2-Clause "Simplified" License
177 stars 23 forks source link

Nested expression matching #79

Closed wess closed 6 years ago

wess commented 6 years ago

One awesome thing would be ability to nest pattern matches/calls within your grammar, like a PEG, Antlr, or even a Flex/Bison:

Example:

statement = [a-zA-Z0-9]+
statements = statement + statements

It might do this, just didn't see anything in the docs about it.

ps. awesome work on regex support!

SwiftStudies commented 6 years ago

Yes this is fully supported (nerdy term for it is left hand recursion). STLR equivalent is:

statement = /[a-zA-Z0-9]+ / statements = statement statements

Although this could be done more efficiently as just

statement = /[a-zA-Z0-0]+ / statements = statement+