Skip to content

Commit

Permalink
regexp2 bank-reference (too slow, will revert)
Browse files Browse the repository at this point in the history
  • Loading branch information
vipally committed Mar 18, 2021
1 parent f77f23e commit c41628a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion syntax.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var res = []*syntax{
&syntax{
name: "#if",
usage: "double-way branch selector by condition",
expr: `(?sm:^(?:[ |\t]*/{2,}[ |\t]*)#GOGP_IFDEF[ |\t]+(?P<IFCOND>[[:word:]<>\|!= \t]+)(?:.*?$[\r|\n]?)(?P<IFT>.*?)(?:(?:[ |\t]*/{2,}[ |\t]*)#GOGP_ELSE(?:.*?$[\r|\n]?)[\r|\n]*(?P<IFF>.*?))?(?:[ |\t]*/{2,}[ |\t]*)#GOGP_ENDIF.*?$[\r|\n]?)`,
expr: `(?sm:^(?:[ |\t]*/{2,}[ |\t]*)#GOGP_IFDEF[ |\t]+(?P<IFCOND>[[:word:]<>\|!= \t]+)(?P<IFNAME>//:[[:word:]<>]+)?(?:.*?$[\r|\n]?)(?P<IFT>.*?)(?:(?:[ |\t]*/{2,}[ |\t]*)#GOGP_ELSE(?:.*?$[\r|\n]?)[\r|\n]*(?P<IFF>.*?))?(?:[ |\t]*/{2,}[ |\t]*)#GOGP_ENDIF(?:[ |\t]*\k'IFNAME').*?$[\r|\n]?)`,
syntax: `
// #GOGP_IFDEF <key> || ! <key> || <key> == xxx || <key> != xxx
{true content}
Expand Down
15 changes: 14 additions & 1 deletion syntax_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAllRegexpSyntax(t *testing.T) {
elem := expAll.FindAllStringSubmatch(src, -1)[0]

for i, v := range groups {
if true && elem[i] != "" && i > 0 {
if true && elem[i] != "" && i >= 0 {
fmt.Printf("%d %s-------\n%s\n", i, v, elem[i])
}
}
Expand Down Expand Up @@ -140,11 +140,24 @@ head
// #GOGP_ONCE
{only generate once from a gp file}
// #GOGP_END_ONCE
---
// #GOGP_IFDEF xx //:outer
// #GOGP_IFDEF yy
{if-true content2}
// #GOGP_ENDIF
// #GOGP_ENDIF //:outer
tail
`

var xx = `
// #GOGP_ELSE //:outer
// #GOGP_IFDEF zz
{if-true content2}
// #GOGP_ENDIF
`
1 change: 1 addition & 0 deletions vendor/github.com/dlclark/regexp2/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c41628a

Please sign in to comment.