microsoft / vscode-textmate

A library that helps tokenize text using Text Mate grammars.
MIT License
562 stars 108 forks source link

Incorrect 'no more matches'? #220

Open senyai opened 7 months ago

senyai commented 7 months ago

Hello!

I'm writing my first TextMate grammar and I can't figure out why (<->) rule does not math. This is my pikchr.tmLanguage.json and my code sample is arrow <-> down 70% from last box.s. To see that the rule doesn't match I run npm run inspect pikchr.tmLanguage.json example.pikchr

@@scanNext 5: | <-> down 70% from last box.s\n|
  scanning for (linePos: 5, anchorPosition: 5)
   - -1: \s*([\n;])
   - 13: ^\s*from)\s+
   - 23: (\bthen\b)?\s*(\bgo\b)?\s*\b(right|down|left|up)\b
   - 27: \b(\d*\.)?\d+(in|cm|px|pt|pc|mm|%)?(^|\s)
   - 28: ^[a-z_$@][\w$@]*
   - 29: \b(red|green|blue)\b
   - 30: %
   - 31: \b(close)\b
   - 32: (?=\s*")
   - 35: \b(diameter|ht|height|rad|radius|thickness|width|wid)(\s+)
   - 37: (<->)
   - 38: \b(same|cw|ccw|invis(ible)?|thick|thin|solid|chop|fit)\b
   - 4: \#(\s.+)?(\n|$)
   - 5: /\*
   - 6: (//).*$\n?
   - 8: ^\s*(box|circle|ellipse|oval|cylinder|file|line|arrow|spline|dot|arc|text|move)\b
   - 32: (?=\s*")
  no more matches.
  token: | <-> down 70% from last box.s\n|
      * source.pikchr

When I enable regexp debugging by adding | 8 to options (https://github.com/microsoft/vscode-textmate/blob/8b07a3c2be6fe4674f9ce6bba6d5c962a7f50df5/src/rule.ts#L884)

const result = this.scanner.findNextMatchSync(string, startPosition, options | 8);

the rule (<->) does match. Does anyone have any ideas what's going on? I'm using main branch and node v18.18.0.

RedCMD commented 7 months ago

I haven't test it but you do have 2 errors in "path-attribute" image

and I think you mean $ for end of line, instead of ^; start of line image

senyai commented 7 months ago

I haven't test it but you do have 2 errors in "path-attribute"

Thank you, @RedCMD. I do. How did you get that nice highlighting? Fixing this, fixed the matching. I will keep the issue open, as I hope to see inspect command to not hide this kind of errors.

RedCMD commented 7 months ago

How did you get that nice highlighting?

My textmate extension