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

Allow starting with | in multiline match #18

Closed
cometkim opened this issue Mar 24, 2021 · 3 comments
Closed

Allow starting with | in multiline match #18

cometkim opened this issue Mar 24, 2021 · 3 comments

Comments

@cometkim
Copy link

I'm parsing bcp47 language tag using reghex and work perfectly!

Can we accept starting with a | character instead pattern when using a multiline match?

const irregular = match('irregular')`
-  ${/en-GB-oed/}
+ | ${/en-GB-oed/}
  | ${/i-ami/}
  | ${/i-bnn/}
  | ${/i-default/}
  | ${/i-enochian/}
  | ${/i-hak/}
  | ${/i-klingon/}
  | ${/i-lux/}
  | ${/i-mingo/}
  | ${/i-navajo/}
  | ${/i-pwn/}
  | ${/i-tao/}
  | ${/i-tay/}
  | ${/i-tsu/}
  | ${/sgn-BE-FR/}
  | ${/sgn-BE-NL/}
  | ${/sgn-CH-DE/}
`;
@fabiospampinato
Copy link

IMHO #17 would be a better fix for the alignment problem you are seeing. Also if basically broken syntax becomes acceptable it will become harder to spot issues, which is already kind of a problem given that there's no syntax highlighting for the DSL.

@kitten
Copy link
Member

kitten commented Apr 1, 2021

So, currently I'm actually inclined to add neither 😅

Regarding the extra pipe, I agree, it's an unnecessary addition that will make it harder to read if someone comes into the DSL without being used to it.

The same goes for arrays though. It wouldn't immediately be obvious whether they abstract a sequence or alternations. Furthermore it opens up new problems like sequences in an alternations which currently just works, so that could leave RegHex's DSL in a spot where it'd jump between string DSL and in-JS DSL, which I'd prefer to avoid

@cometkim
Copy link
Author

cometkim commented Apr 2, 2021

Since the *-in-JS solution uses JS module semantics, it becomes difficult to deal with the problem with Babel. When a user tries to import an external module into the DSL, somethings like code extraction and dependency tracking are may required aditionally. (ex. Linaria does)

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

3 participants