nearley icon indicating copy to clipboard operation
nearley copied to clipboard

Add a small syntax cheatsheet

Open abitrolly opened this issue 4 years ago • 4 comments

I grouped all Nearley matching constructs in one block to make them easier to find and compare with other languages.

  • "if" - match if literally
  • "if"i - match if case-insensitive
  • . - match any symbol except newline
  • [^] - match anything including newline
  • [a-zA-Z] - match symbols in range
  • [^a-zA-Z] - match symbols not in range
  • :+ - match previous construction one or more time
  • :* - match zero times or more
  • :? - zero time or one time

As I am editing this from the GitHub, I can not preview and format it to proper HTML, but I hope it makes documentation already a bit more useful. The completely undocumented thing was [^] and . behavior from #348 and #400.

abitrolly avatar Aug 26 '21 09:08 abitrolly

Can you also include the constructs for tokens matched by custom lexers?

kach avatar Aug 26 '21 14:08 kach

Can you also include the constructs for tokens matched by custom lexers?

I wish I could, but for now I am not sure what are those custom lexers, and what constructs they produce. Still trying to build my first Nearly parser.

abitrolly avatar Aug 26 '21 15:08 abitrolly

I've found that there are .md files that I should edit instead of .html. Fixed now.

As a side note, have you considered telling GitHub to serve content from the docs/ folder?

https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site

That would make it a little bit more intuitive for new users..

abitrolly avatar Aug 28 '21 09:08 abitrolly

Preview https://abitrolly.github.io/nearley/docs/grammar.html#matching-rules

abitrolly avatar Aug 28 '21 11:08 abitrolly