question: where is wrong? #203
puccoonhuang
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I try to code a demo of participle usage
but got a err msg, "parse error:5:9: invalid input text "(\n\tgithub.com/al..."", where is wrong?
here is my code.
package main
import (
"fmt"
)
type GoModFile struct {
Module string
"module" @String
Statements []Statement
@@*
}
type Statement struct {
GoVersion string
"go" @Version
Requirements []Dependency
| ("require (" @@* ")") | ("require" @@)
Replacements []Dependency
| ("replace (" @@* ")") | ("replace" @@)
Excludes []Dependency
| ("exclude (" @@* ")") | ("exclude" @@)
}
type Dependency struct {
ModuleName string
@String
Version string
(@Version | @"latest")
Comment string
(@Comment |"")
}
type Replacement struct {
FromModule string
@String "=>"
ToModule Dependency
@@
}
var (
modContent = `
module useparticiple
go 1.16
require (
github.com/alecthomas/participle v0.7.1 # test
github.com/alecthomas/participle v0.7.1 # test
)
gomodLexer = lexer.Must(lexer.NewSimple([]lexer.Rule{ {"Version",
[v]?\d+[.]+\d+[.]?\d+, nil}, {"String",
[a-zA-Z0-9_+.@-/]+, nil}, {"Comment",
# [^\n]*, nil}, {"whitespace",
\s+`, nil}, //special}))
)
func main() {
}
Beta Was this translation helpful? Give feedback.
All reactions