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

Some syntax ideas #11

Open
gjvnq opened this issue Feb 17, 2022 · 4 comments
Open

Some syntax ideas #11

gjvnq opened this issue Feb 17, 2022 · 4 comments
Labels
compiler Related to the Melody compiler enhancement New feature or request syntax Concerning the Melody language syntax

Comments

@gjvnq
Copy link

gjvnq commented Feb 17, 2022

Just some syntax ideas you may find useful.

Melody Regex Status
maybe a little of or lazily *? ❔
rematch 𝐷 \𝐷 ❔
rematch π‘›π‘Žπ‘šπ‘’ \k<π‘›π‘Žπ‘šπ‘’> ❔
unicode class ... \p{...} ❔
unicode except clas ... \P{...} ❔
U+𝑋𝑋𝑋𝑋 \u𝑋𝑋𝑋𝑋 ❔
X+𝑋𝑋 \x𝑋𝑋 ❔
o𝐷𝐷𝐷 (e.g. o700) \𝐷𝐷𝐷 ❔
^π‘Œ \cπ‘Œ ❔
word boundary \b ❔
word non boundary \B ❔
rematch 1 $1 ❔
insert { until match } $` ❔
insert { full match } $& ❔
Could not find this notation anywhere. Typo? x20 ❔
Could not find this notation anywhere. Typo? x{06fa} ❔

Also, allow multiple regexps per file and let them refer to previous ones, e.g.:

regexp iso-date {
  4 of digit;
  "-";
  2 of digit;
  "-";
  2 of digit;
}

regexp iso-range {
  match iso-date;
  "/";
  match iso-date;
}
@joshuakb2
Copy link
Contributor

Potential alternate syntax for bindings and macros:

let iso-date = {
  4 of digit;
  "-";
  2 of digit;
  "-";
  2 of digit;
};

let twoOf x between = {
  $x;
  $between;
  $x;
};

$twoOf $iso-date <space>

@kgutwin
Copy link

kgutwin commented Feb 17, 2022

How about some dedicated syntax for common idioms? Things like

anything;  // equivalent to .*

That's the only thing I can come up with at the moment but I'm sure there are others...

@gjvnq
Copy link
Author

gjvnq commented Feb 18, 2022 via email

@yoav-lavi
Copy link
Owner

yoav-lavi commented Feb 18, 2022

Thank you for the suggestions!

Will consider these, leaving open for now

@yoav-lavi yoav-lavi added syntax Concerning the Melody language syntax enhancement New feature or request compiler Related to the Melody compiler labels Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Related to the Melody compiler enhancement New feature or request syntax Concerning the Melody language syntax
Projects
None yet
Development

No branches or pull requests

4 participants