Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide function regex #18

Open
Kikobeats opened this issue Jul 17, 2016 · 1 comment
Open

Provide function regex #18

Kikobeats opened this issue Jul 17, 2016 · 1 comment

Comments

@Kikobeats
Copy link

Could be possible require a external library that export a function that evaluate if the current term is a token?

Example:

WORD             require('lodash.words')
@GerHobbelt
Copy link
Contributor

I see where such a thing would be handy, but when you want to do this at the macro level (rather than on the lexer rules) there's trouble using it like this, because macros are expanded into the lexer rule regexes, e.g.

// lexer macros:
WORDS  something

// lexer rules:
{WORDS}":"{WORDS}      return "MARKER";   // lexer token sent to parser

.             return "TEXT";

would be weird, language-wise, when WORDS require(lodash.words) would be code for WORDS as then the question is: what is {WORDS}:{WORDS} then as a rule to match?

If, instead, you'ld be looking something like this:

// lexer macros:
WORDS  something

// lexer rules:
{WORDS}":"{WORDS}      return "MARKER";   // lexer token sent to parser
/require(words)/       return "WORD"; // as recognized by require(words)

.             return "TEXT";

now that I can see working as one might expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants