[YANGTOOLS-544] YangSyntaxErrorException depending of the restictions/extensions order for the String type Created: 11/Nov/15  Updated: 10/Apr/22  Resolved: 08/Dec/15

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Ícaro Franco Damiani Assignee: Ícaro Franco Damiani
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


External issue ID: 4623

 Description   

module extension-def {
namespace "urn:simple.extension.typedefs";
prefix "ext";

extension unknown

{ argument "ext-arg"; description "Extension with single argument definition."; }

}

module types {
namespace "urn:custom.types.demo";
prefix "types";

import extension-def

{ prefix "ext"; }

leaf leaf-length-unknown-pattern {
type string

{ length "2..10"; ext:unknown "unknown"; pattern "[0-9a-fA-F]"; }

}
}

The given example results in "YangSyntaxErrorException: mismatched input 'pattern' expecting

{'}

'" because of the type string restriction order.

type string {
length "2..10"; <--- String restriction
ext:unknown "unknown"; <--- extension
pattern "[0-9a-fA-F]"; <--- String restriction
}

According to the YangParser.g4

type body for string type:
type_body_stmts: (identifier_stmt)* (string_restriction) (identifier_stmt)*;
string_restrictions : (length_stmt |pattern_stmt)*;

Recomended solution:

string_restrictions : (length_stmt | identifier_stmt | pattern_stmt)*;

It will allow any order of restrictions and extensions.



 Comments   
Comment by Ícaro Franco Damiani [ 19/Nov/15 ]

https://git.opendaylight.org/gerrit/#/c/29930/

Comment by Martin Ciglan [ 20/Nov/15 ]

just to add, this needs to be cherry-picked to stable/lithium branch in order to apply it in old parser.

Beryllium master uses new statement parser with different grammar.

Comment by Ícaro Franco Damiani [ 20/Nov/15 ]

Done.

https://git.opendaylight.org/gerrit/#/c/29984/

Should I abandon the old one?

Comment by Martin Ciglan [ 23/Nov/15 ]

Old YANG parser code is present in Beryllium master code base, so you can keep it. Thank you.

Comment by Tony Tkacik [ 01/Dec/15 ]

Merged into master, still waiting for unfreezing stable/lithium branch

Generated at Wed Feb 07 20:53:33 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.