-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Scheme: Improvements #2263
Scheme: Improvements #2263
Conversation
// <b.o.x. number> := <b.o.x. prefix>[+-]?<b.o.x. complex> | ||
// | ||
// <number> := <dec number>|<b.o.x. number> | ||
pattern: /([\s()])(?:(?:#d(?:#[ei])?|#[ei](?:#d)?)?[+-]?(?:(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)(?:[+-](?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)?|(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)|(?:#[box](?:#[ei])?|#[ei](?:#[box])?)[+-]?(?:[\da-fA-F]+(?:\/[\da-fA-F]+)?(?:[+-][\da-fA-F]+(?:\/[\da-fA-F]+)?i)?|[\da-fA-F]+(?:\/[\da-fA-F]+)?i))(?=[\s()]|$)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I don't.
It explains the pattern by showing its simpler components, yes, but how do you know that the pattern is actually what's written there? I actually manually "generated" the pattern by substituting the rules myself, so I can tell you it's a pain... especially if you change something...
I'd rather have the pattern generated from a BNF.
We could implement a BNF-like syntax with #2190 and a syntax like this:
bnf({
// Decimal numbers
'dec real' : /\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+/.source,
'dec complex' : /<dec real>(?:[+-]<dec real>i)?|<dec real>i/.source,
'dec prefix' : /(?:#d(?:#[ei])?|#[ei](?:#d)?)?/.source,
'dec number' : /<dec prefix>[+-]?<complex>/.source,
// Binary, octal, and hexadecimal numbers
'box real' : /[\da-fA-F]+(?:\/[\da-fA-F]+)?/.source,
'box complex' : /<box real>(?:[+-]<box real>i)?|<box real>i/.source,
'box prefix' : /#[box](?:#[ei])?|#[ei](?:#[box])?/.source,
'box number' : /<box prefix>[+-]?<box complex>/.source,
'out' : /<dec number>|<box number>/.source,
}); // returns a RegExp
But this has a whole range of problems associated with it one of them being that minification basically impossible.
This makes some improvements to the Scheme language in an effort to fix the remaining TODOs in #1451.