Skip to content

Commit

Permalink
issue #114 - allow numbers in quote in yang
Browse files Browse the repository at this point in the history
  • Loading branch information
dhubler committed Jul 22, 2024
1 parent b01a955 commit 4939405
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parser/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,9 @@ func lexBegin(l *lexer) stateFunc {
if l.acceptToken(ttype) {
if !l.acceptToken(kywd_unbounded) {
if !l.acceptInteger(token_number) {
return l.error("expecting integer")
if !l.acceptToken(token_string) {
return l.error("expecting integer")
}
}
}
return l.acceptEndOfStatement()
Expand Down
1 change: 1 addition & 0 deletions parser/parser_samples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var yangTestFiles = []struct {

{"", "turing-machine"},
{"", "basic_config2"},
{"", "issue-114"},
}

// recursive, we can parse it but dumping to json is infinite recursion
Expand Down
21 changes: 21 additions & 0 deletions parser/testdata/gold/issue-114.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"module":{
"ident":"issue-114",
"description":"allowing for numbers wrapped in double quotes",
"namespace":"freeconf.org",
"prefix":"i",
"version":"\"1.1\"",
"dataDef":[
{
"ident":"a",
"list":{
"key":[],
"minElements":1,
"maxElements":10,
"dataDef":[
{
"ident":"x",
"leaf":{
"type":{
"ident":"string",
"format":"string"}}}]}}]}}
33 changes: 33 additions & 0 deletions parser/testdata/gold/issue-114.lex
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module "module"
[ident] "issue-114"
{ "{"
yang-version "yang-versi"...
[string] "\"1.1\""
; ";"
namespace "namespace"
[string] "\"freeconf."...
; ";"
prefix "prefix"
[string] "\"i\""
; ";"
description "descriptio"...
[string] "\"allowing "...
; ";"
list "list"
[ident] "a"
{ "{"
min-elements "min-elemen"...
[string] "\"1\""
; ";"
max-elements "max-elemen"...
[string] "\"10\""
; ";"
leaf "leaf"
[ident] "x"
{ "{"
type "type"
[ident] "string"
; ";"
} "}"
} "}"
} "}"
14 changes: 14 additions & 0 deletions parser/testdata/issue-114.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module issue-114 {
yang-version "1.1";
namespace "freeconf.org";
prefix "i";
description "allowing for numbers wrapped in double quotes";

list a {
min-elements "1";
max-elements "10";
leaf x {
type string;
}
}
}

0 comments on commit 4939405

Please sign in to comment.