Skip to content

Commit

Permalink
Juniper: add support for more characters in GroupWildcard (batfish#5956)
Browse files Browse the repository at this point in the history
Juniper example:

  interfaces {
    "<ge-1/2/[5-8]>" {
      description "These interfaces reserved for Customer ABC";
    }
  }

Siva example on Batfish Slack: dd.d[dd]d.*.*/d[dd] where d is a digit
  • Loading branch information
dhalperi authored and kylehoferamzn committed Jul 21, 2020
1 parent 06f3f04 commit 239faeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ Rule ClassLiterals() {
@SuppressSubnodes
Rule AllLiterals() {
// Skipping special characters until proven otherwise
Rule base = FirstOf(ClassLiterals(), Dot());
Rule base = FirstOf(ClassLiterals(), NonClassLiterals(), Dot());
return Sequence(
base, // pop()
ZeroOrMore(base, push(pop(1) + pop())));
}

Rule NonClassLiterals() {
return Sequence(Ch('/'), push(match()));
}

Rule Dot() {
return Sequence(Ch('.'), push("\\."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public void testToJavaRegexWithCharacterClasses() {
assertThat(toJavaRegex("[0-9]"), equalTo("[0-9]"));
assertThat(toJavaRegex("[A-D]"), equalTo("[A-D]"));
assertThat(toJavaRegex("border-[0-9]-DC?-*"), equalTo("border-[0-9]-DC\\w-.*"));
assertThat(toJavaRegex("ge-1/2/[5-8]"), equalTo("ge-1/2/[5-8]"));
assertThat(toJavaRegex("12.1[23]4.*.*/2[89]"), equalTo("12\\.1[23]4\\..*\\..*/2[89]"));
}

@Test
Expand Down

0 comments on commit 239faeb

Please sign in to comment.