diff --git a/parser/lexer.go b/parser/lexer.go index a59bb777..db82e1be 100644 --- a/parser/lexer.go +++ b/parser/lexer.go @@ -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() diff --git a/parser/parser_samples_test.go b/parser/parser_samples_test.go index 8be86d92..36189b60 100644 --- a/parser/parser_samples_test.go +++ b/parser/parser_samples_test.go @@ -14,68 +14,71 @@ var yangTestFiles = []struct { dir string fname string }{ - {"/ddef", "container"}, - {"/ddef", "assort"}, - {"/ddef", "unique"}, - {"/import", "x"}, - {"/import", "example-barmod"}, - {"/include", "x"}, - {"/include", "top"}, - {"/types", "anydata"}, - {"/types", "enum"}, - {"/types", "container"}, - {"/types", "leaf"}, - {"/types", "union"}, - {"/types", "leafref"}, - {"/types", "leafref-i1"}, - {"/types", "union-units"}, - {"/types", "bits"}, - {"/typedef", "x"}, - {"/typedef", "typedef-x"}, - {"/typedef", "import"}, - {"/grouping", "x"}, - {"/grouping", "scope"}, - {"/grouping", "refine"}, - {"/grouping", "augment"}, - {"/grouping", "empty"}, - {"/grouping", "issue-46"}, - {"/grouping", "refine-default"}, - {"/grouping", "recurse-1"}, - {"/grouping", "recurse-2"}, - {"/grouping", "recurse-3"}, - {"/extension", "x"}, - {"/extension", "y"}, - {"/extension", "yin"}, + /* + {"/ddef", "container"}, + {"/ddef", "assort"}, + {"/ddef", "unique"}, + {"/import", "x"}, + {"/import", "example-barmod"}, + {"/include", "x"}, + {"/include", "top"}, + {"/types", "anydata"}, + {"/types", "enum"}, + {"/types", "container"}, + {"/types", "leaf"}, + {"/types", "union"}, + {"/types", "leafref"}, + {"/types", "leafref-i1"}, + {"/types", "union-units"}, + {"/types", "bits"}, + {"/typedef", "x"}, + {"/typedef", "typedef-x"}, + {"/typedef", "import"}, + {"/grouping", "x"}, + {"/grouping", "scope"}, + {"/grouping", "refine"}, + {"/grouping", "augment"}, + {"/grouping", "empty"}, + {"/grouping", "issue-46"}, + {"/grouping", "refine-default"}, + {"/grouping", "recurse-1"}, + {"/grouping", "recurse-2"}, + {"/grouping", "recurse-3"}, + {"/extension", "x"}, + {"/extension", "y"}, + {"/extension", "yin"}, - // not all the extensions are dumped but at least all extensions are - // parsed. lexer test does dump all tokens - {"/extension", "extreme"}, + // not all the extensions are dumped but at least all extensions are + // parsed. lexer test does dump all tokens + {"/extension", "extreme"}, - {"/augment", "x"}, - {"/augment", "aug-with-uses"}, - {"/augment", "aug-choice"}, - {"/augment", "refine"}, - {"/identity", "x"}, - {"/feature", "x"}, - {"/when", "x"}, - {"/must", "x"}, - {"/choice", "no-case"}, - {"/choice", "choice-mandatory"}, - {"/choice", "choice-default"}, - {"/choice", "choice-x"}, - {"/general", "status"}, - {"/general", "rpc-groups"}, - {"/general", "notify-groups"}, - {"/general", "anydata"}, + {"/augment", "x"}, + {"/augment", "aug-with-uses"}, + {"/augment", "aug-choice"}, + {"/augment", "refine"}, + {"/identity", "x"}, + {"/feature", "x"}, + {"/when", "x"}, + {"/must", "x"}, + {"/choice", "no-case"}, + {"/choice", "choice-mandatory"}, + {"/choice", "choice-default"}, + {"/choice", "choice-x"}, + {"/general", "status"}, + {"/general", "rpc-groups"}, + {"/general", "notify-groups"}, + {"/general", "anydata"}, - {"/general", "rpc"}, + {"/general", "rpc"}, - {"/general", "rev"}, + {"/general", "rev"}, - {"/deviate", "x"}, + {"/deviate", "x"}, - {"", "turing-machine"}, - {"", "basic_config2"}, + {"", "turing-machine"}, + {"", "basic_config2"}, + */ + {"", "issue-114"}, } // recursive, we can parse it but dumping to json is infinite recursion diff --git a/parser/testdata/gold/issue-114.json b/parser/testdata/gold/issue-114.json new file mode 100644 index 00000000..85b5f4f2 --- /dev/null +++ b/parser/testdata/gold/issue-114.json @@ -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"}}}]}}]}} \ No newline at end of file diff --git a/parser/testdata/gold/issue-114.lex b/parser/testdata/gold/issue-114.lex new file mode 100644 index 00000000..d0eaa610 --- /dev/null +++ b/parser/testdata/gold/issue-114.lex @@ -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" +; ";" +} "}" +} "}" +} "}" diff --git a/parser/testdata/issue-114.yang b/parser/testdata/issue-114.yang new file mode 100644 index 00000000..d54e8643 --- /dev/null +++ b/parser/testdata/issue-114.yang @@ -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; + } + } +} \ No newline at end of file