HippoEDIT - Programmers text editor

General Category => Syntax Files => Topic started by: ccpaging on February 23, 2016, 06:07:18 am

Title: Go lang: some functions not matched
Post by: ccpaging on February 23, 2016, 06:07:18 am
Code: [Select]
<Label group="Function" match="func\s+(\w+)([^\{]*)\{" name="\1" descr="\1 \2" scope="1" image="18"/>

can match

Code: [Select]
func NewEncoding(encoder string) *Encoding {

but not match

Code: [Select]
func (enc *Encoding) EncodeToString(src []byte) string {

As c++, "(enc *Encoding)" is "class", EncodeToString is "method".
Title: Re: Go lang: some functions not matched
Post by: ccpaging on February 23, 2016, 03:12:28 pm
Code: [Select]
<Label group="Function" match="func\s+([^\{]*)\{" name="\1" descr="\1 \2" scope="1" image="18"/>
This may better.
Title: Re: Go lang: some functions not matched
Post by: alex on February 23, 2016, 11:51:19 pm
Hi,

thanks for feedback and suggestion!. Honestly I have written schema, but now one has validated it before. So it may happen that it is not optimal and probably does not have some newest syntax schema features (fex Scope Exits)..

You mostly correct, except of fact that than 2 capture is gone. But I think it is OK.
This version may be even better ;)
Code: XML
  1. <Label group="Function" match="func\s+([^\{]+?)\s+?\{" name="\1" descr="\1" scope="1" image="18"/>

I have version in Online repository also. So you can update your schema manually or with Update Manager (Help->Check for updates...).

Best regards,
Alex.
P.S: If you will have some more comments/suggestions for Go schema, I will be happy to update it.
Title: Re: Go lang: some functions not matched
Post by: ccpaging on February 24, 2016, 05:04:35 am
That is fine.

[attach=2]
Title: Re: Go lang: some functions not matched
Post by: ccpaging on July 11, 2017, 03:48:52 pm
Code: [Select]
func Logf(lvl Level, format string, args ...interface{}) {
Global.intLogf(lvl, format, args...)
}

This is not in function list.
Title: Re: Go lang: some functions not matched
Post by: alex on July 11, 2017, 11:37:54 pm
To get that working one need more complex regexp :) And who knows how long it will survive (at least until one would use () inside of the parameters section).
The Label definition from below shall work better:
Code: XML
  1. <Label group="Function" match="func\s+(?:(\([^\)]+?\))\s+)?(\w+)\s*(\([^\)]+?\))\s*(?:([^\{]+?)\s*)?\{" name="\1 \2 \3 \4" descr="\1" scope="1" image="18"/>
Title: Re: Go lang: some functions not matched
Post by: ccpaging on July 18, 2017, 01:45:40 pm
It is working.   ;)

But others is missing.

The attach file is a sample.

Thanks very much.
Title: Re: Go lang: some functions not matched
Post by: alex on July 20, 2017, 03:09:10 pm
To be precise: "some other missing" :)
Please validate this one:
Code: XML
  1. <Label group="Function" match="func\s+(?:(\([^\)]+?\))\s+)?(\w+)\s*(\([^\)]*?\))\s*(?:([^\{]+?)\s*)?\{" name="\1 \2 \3 \4" descr="\1" scope="1" image="18" style="function" highlight="\2"/>

You can try it with a syntax schema file attached - there are some other features added.
Title: Re: Go lang: some functions not matched
Post by: ccpaging on July 25, 2017, 04:28:39 pm
 :) :) :) The last one is fine, everything.