Skip to content

Commit

Permalink
improvement: add Regex and EBNF support to PlantUML file.
Browse files Browse the repository at this point in the history
  • Loading branch information
mindolph committed Mar 1, 2025
1 parent a8bb531 commit 3eb689d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,23 @@ private PlantUmlTemplates() {
content:
title: This is a YAML script
@endyaml
"""),
new Template("EBNF", """
@startebnf
'this file is created by Mindolph at %s
title Title
my_enbf = {"a", c , "a" (* Note on a *)}
| ? special ?
| "repetition", 4 * '2';
(* Global End Note *)
@endebnf
"""),
new Template("Regex", """
@startregex
'this file is created by Mindolph at %s
title minimumRepetition
ab{1}c{1,}
@endregex
""")
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public interface PlantUmlConstants extends SyntaxConstants {

String[] DIAGRAM_KEYWORDS_START = new String[]{
"startsalt", "startgantt", "startlatex", "startmath", "startdot",
"startuml", "startmindmap", "startwbs", "startyaml", "startjson"
"startuml", "startmindmap", "startwbs", "startyaml", "startjson", "startregex", "startebnf"
};

String[] DIAGRAM_KEYWORDS_END = new String[]{
"endsalt", "endgantt", "endlatex", "endmath", "enddot",
"enduml", "endmindmap", "endwbs", "endyaml", "endjson"
"enduml", "endmindmap", "endwbs", "endyaml", "endjson", "endregex", "endebnf"
};

String DIAGRAM_PATTERN = "@(" + String.join("|", ArrayUtils.addAll(DIAGRAM_KEYWORDS_START, DIAGRAM_KEYWORDS_END)) + ")";
Expand Down Expand Up @@ -44,15 +44,16 @@ public interface PlantUmlConstants extends SyntaxConstants {
"center", "footer", "return"
};
String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b";
String COMMENT_PATTERN = "(" + BLANK_CHAR + "*'.*)";
// include EBNF note
String COMMENT_PATTERN = "(%s*'.*)|(\\(\\*[.\\s\\S]+?\\*\\))".formatted(BLANK_CHAR);
String BLOCK_COMMENT_PATTERN = "\\/'[.\\s\\S]+?'\\/";

String ARROW1 = "[<>ox#\\*\\{\\}\\+\\^]";
String ARROW2 = "([\\|\\}\\<][\\|o])|([\\|o][\\|\\{\\>])";
String BAR = "-|\\.|(--)|(\\.\\.)";
String CONNECTOR = "((%s)|(%s))*(%s)((%s)|(%s))*".formatted(ARROW2, ARROW1, BAR, ARROW2, ARROW1);

String QUOTE_BLOCK = "(\"[^\"]*?\")|(\\[[^\\]]*?\\])";
// include EBNF quote
String QUOTE_BLOCK = "(\"[^\"]*?\")|(\\[[^\\]]*?\\])|(\\?[.\\s\\S]+?\\?)";

String ACTIVITY = ":[^;]*?;";
}

0 comments on commit 3eb689d

Please sign in to comment.