-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Loading the following from file fails (not sure if this is invalid YANG, I didn't see anything in the spec, or get any complaints from pyang)
YANG file:
module x {
namespace "";
prefix "";
revision 0;
} // foo
example:
package main
import (
"github.com/freeconf/yang/parser"
"github.com/freeconf/yang/source"
"github.com/freeconf/yang/fc"
)
func main() {
fc.DebugLog(true)
// load model
_, errLdMdl := parser.LoadModule(source.Dir("yang"), "foo")
if errLdMdl != nil {
panic(errLdMdl.Error())
}
}
Output:
panic: runtime error: index out of range [63] with length 63
goroutine 1 [running]:
github.com/freeconf/yang/parser.(*lexer).acceptWS(0xc00010c5a0)
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/lexer.go:278 +0xcf
github.com/freeconf/yang/parser.(*lexer).emit(0x55a63b?, 0xc00010c5a0?)
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/lexer.go:766 +0xb8
github.com/freeconf/yang/parser.(*lexer).acceptToken(0xc00010c5a0, 0xe007)
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/lexer.go:328 +0x19a
github.com/freeconf/yang/parser.lexBegin(0xc00010c5a0)
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/lexer.go:724 +0x122e
github.com/freeconf/yang/parser.(*lexer).nextToken(0xc00010c5a0)
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/lexer.go:792 +0x38
github.com/freeconf/yang/parser.(*lexer).Lex(0xc000059ba0?, 0xc000132588)
parser.y:24 +0x18
github.com/freeconf/yang/parser.yylex1({0x607fe0?, 0xc00010c5a0?}, 0x0?)
yaccpar:119 +0x2b
github.com/freeconf/yang/parser.(*yyParserImpl).Parse(0xc000132588, {0x607fe0, 0xc00010c5a0})
yaccpar:204 +0x7e33
github.com/freeconf/yang/parser.yyParse(...)
yaccpar:153
github.com/freeconf/yang/parser.(*parser).parseModule(0x6079e0?, {0xc000020140?, 0x3f?}, 0x0, {0x608008, 0xc0000308a0}, 0x796d20?)
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/loader.go:80 +0xe6
github.com/freeconf/yang/parser.(*parser).loadAndParseModule(0xc000048040, 0x0, {0x5b6d04, 0xf}, {0x467399?, 0x10?}, {0x608008, 0xc0000308a0}, 0xc000016140)
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/loader.go:110 +0x278
github.com/freeconf/yang/parser.LoadModuleWithOptions(0xc0000120a8, {0x5b6d04, 0xf}, {{0x0?, 0x0?}, {0x0?, 0xc0000061c0?}})
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/loader.go:68 +0x12f
github.com/freeconf/yang/parser.LoadModule(...)
/dev/go/pkg/mod/github.com/freeconf/yang@v0.0.0-20240722123345-493940563c44/parser/loader.go:16
main.main()
/dev/scratch/freeconf/main.go:22 +0x65
The culprit is the little // foo comment after the module definition
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels