ViktorQvarfordt / Sublime-WolframLanguage

Sublime Text 3 support for the Wolfram Language, the language used in Mathematica.
MIT License
31 stars 10 forks source link

Function definition regex issues #2

Closed chere005 closed 6 years ago

chere005 commented 7 years ago

try the following:

f[x_, OptionsPattern[]] :=
 {x, OptionValue[a]}

It no longer looks like a function definition because of the right bracket from ]

Also consider that if the := is on a different line like:

foo[
    bar_Integer,
    bas_Real
] :=

Lastly it would be nice if when typing a variable using Blank, anything on the right showed up like a function

fooInteger <- foo should look like a var name, and "Integer" should look like a function..

Also don't forget about cases like

foo[bar:(_Integer | _Real)] :=
foo[bar_?PositiveQ] :=

Blank patterns show up all over the place.. It would be nice if something like the following had some highlighting for x___

StringCases[foo, {"<" ~~ x___ ~~ ">" :> x}]
ViktorQvarfordt commented 7 years ago

Thanks for opening this issue!

  1. f[x_, OptionsPattern[]] := is now fixed in 49b4cd3

  2. := on a different line. This cannot be fixed because the := is scanned for with regex lookahead, which only matches until end of line. Many other language syntax highlighters have this issue (such as the built in syntax highlighting for JavaScript). See further discussion of this issue for the Julia language here.

  3. Regarding the other issues you raise, I'm not I see how these should be highlighted. Ideally you could give failing tests in syntax_test.wl by opening a PR with failing tests, in this way it is much easier for me to provide a fix, and you can have a go at it if you want as well.

ViktorQvarfordt commented 7 years ago

Any updates on this?

chere005 commented 7 years ago

Haven't had any time to look at this, sorry. I will try to in the next few weeks. The other fixes were necessary for me to keep working effectively :)

On Wed, May 24, 2017 at 8:53 AM, Viktor Qvarfordt notifications@github.com wrote:

Any updates on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ViktorQvarfordt/Sublime-WolframLanguage/issues/2#issuecomment-303730461, or mute the thread https://github.com/notifications/unsubscribe-auth/Aa3Cz2_IXDluxskAwUQuC6K6Qf6_J43-ks5r9DZNgaJpZM4NMCS0 .

shigma commented 6 years ago

Is the problem solved? @chere005

chere005 commented 6 years ago

This problem is solved after most recent PRs. Yay!