Skip to content

Commit 3288f0c

Browse files
hoe-joramceb
authored andcommitted
parser for checking plantuml diagrams
This PR contains a parser to parse the following plantuml diagrams - component diagram - class diagram - sequence diagram. The resulting represenation is suitable for further checking of the content against requirements and implementation
1 parent 58581ab commit 3288f0c

252 files changed

Lines changed: 19626 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
# GitHub CODEOWNERS file is a simple way to automate review system on github,
15+
# by automatically assigning owners to a pull request based on which files
16+
# were modified. All directories should have a proper codeowner
17+
# Syntax: https://help.github.com/articles/about-codeowners/
18+
19+
/plantuml/ @castler @hoe-jo @LittleHuba @limdor @ramceb
20+
/bazel/rules/rules_score/ @castler @hoe-jo @LittleHuba @limdor @ramceb

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ copyright_checker(
2828
"python_basics",
2929
"starpls",
3030
"tools",
31+
"plantuml",
3132

3233
# Add other directories/files you want to check
3334
],

MODULE.bazel

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,69 @@ bazel_dep(name = "rules_multitool", version = "1.9.0")
3232
bazel_dep(name = "score_rust_policies", version = "0.0.2")
3333
bazel_dep(name = "bazel_skylib", version = "1.7.1")
3434
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
35+
bazel_dep(name = "flatbuffers", version = "25.9.23")
36+
37+
###############################################################################
38+
# Rust Toolchain
39+
###############################################################################
40+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
41+
rust.toolchain(edition = "2021")
42+
use_repo(rust, "rust_toolchains")
43+
44+
register_toolchains("@rust_toolchains//:all")
45+
46+
###############################################################################
47+
# Rust Crates (crate_universe)
48+
###############################################################################
49+
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
50+
crate.spec(
51+
package = "pest",
52+
version = "2.8.3",
53+
)
54+
crate.spec(
55+
package = "pest_derive",
56+
version = "2.8.3",
57+
)
58+
crate.spec(
59+
features = ["derive"],
60+
package = "clap",
61+
version = "4.5.0",
62+
)
63+
crate.spec(
64+
package = "thiserror",
65+
version = "1.0.44",
66+
)
67+
crate.spec(
68+
package = "log",
69+
version = "0.4",
70+
)
71+
crate.spec(
72+
package = "env_logger",
73+
version = "0.10",
74+
)
75+
crate.spec(
76+
features = ["derive"],
77+
package = "serde",
78+
version = "1.0",
79+
)
80+
crate.spec(
81+
package = "serde_json",
82+
version = "1.0",
83+
)
84+
crate.spec(
85+
package = "serde_yaml",
86+
version = "0.9",
87+
)
88+
crate.spec(
89+
package = "once_cell",
90+
version = "1.19",
91+
)
92+
crate.spec(
93+
package = "flatbuffers",
94+
version = "25.9.23",
95+
)
96+
crate.from_specs()
97+
use_repo(crate, "crates")
3598

3699
###############################################################################
37100
# Python Toolchain

REUSE.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,13 @@ SPDX-License-Identifier = "Apache-2.0"
4848
path = ["dash/org.eclipse.dash.licenses-1.1.0.jar"]
4949
SPDX-FileCopyrightText = "2020 Eclipse Foundation"
5050
SPDX-License-Identifier = "EPL-2.0"
51+
52+
[[annotations]]
53+
path = ["plantuml/**/*.json"]
54+
SPDX-FileCopyrightText = "Copyright (c) 2026 Contributors to the Eclipse Foundation"
55+
SPDX-License-Identifier = "Apache-2.0"
56+
57+
[[annotations]]
58+
path = ["plantuml/**/*.svg"]
59+
SPDX-FileCopyrightText = "Copyright (c) 2026 Contributors to the Eclipse Foundation"
60+
SPDX-License-Identifier = "Apache-2.0"

plantuml/parser/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
alias(
14+
name = "parser",
15+
actual = "//plantuml/parser/puml_cli:puml_cli",
16+
visibility = ["//visibility:public"],
17+
)

plantuml/parser/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<!--
2+
Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
4+
See the NOTICE file(s) distributed with this work for additional
5+
information regarding copyright ownership.
6+
7+
This program and the accompanying materials are made available under the
8+
terms of the Apache License Version 2.0 which is available at
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
SPDX-License-Identifier: Apache-2.0
12+
-->
13+
14+
# PlantUML Parser
15+
16+
The PlantUML Parser is a multi-file parser that processes PlantUML diagram files and converts them into structured data for traceability and architectural analysis. It handles preprocessing of include directives, supports multiple diagram types (Class, Sequence, Component), and generates FlatBuffers binary output for further downstream processing.
17+
18+
---
19+
20+
## What It Does
21+
22+
The parser takes `.puml` source files as input and produces:
23+
24+
- **FlatBuffers binary** (`.fbs.bin`) — primary structured output for downstream consumers
25+
- **LOBSTER traceability JSON** (`.lobster`) — for component diagrams, enables traceability linking via the LOBSTER toolchain
26+
- **Debug JSON** — raw and resolved ASTs when `--log-level debug` or higher is set
27+
28+
29+
Rust-based parser that produces an AST for the following PlantUML diagram types:
30+
31+
- Class Diagram
32+
- Sequence Diagram
33+
- Component Diagram
34+
35+
Outputs are `.fbs.bin` FlatBuffers binaries (diagram AST) and optionally `.lobster`
36+
traceability files (for component diagrams).
37+
38+
## Usage
39+
40+
### Build:
41+
```
42+
bazel build //tools/plantuml/parser
43+
```
44+
45+
### Run:
46+
```
47+
bazel run //tools/plantuml/parser -- [OPTIONS]
48+
```
49+
50+
Options:
51+
52+
| Option | Description | Default |
53+
|--------|-------------|---------|
54+
| `--file <FILE>...` | One or more PUML files to parse (repeatable) ||
55+
| `--folders <DIR>` | Folder containing PUML files ||
56+
| `--log-level <error\|warn\|info\|debug\|trace>` | Logging verbosity | `warn` |
57+
| `--diagram-type <component\|class\|sequence\|none>` | Diagram type hint | `none` |
58+
| `--fbs-output-dir <DIR>` | Output directory for `.fbs.bin` FlatBuffers files | none (no output) |
59+
| `--lobster-output-dir <DIR>` | Output directory for `.lobster` traceability files | none (no output) |
60+
61+
At least one of `--file` or `--folders` is required.
62+
63+
Example:
64+
```
65+
bazel run //tools/plantuml/parser -- \
66+
--file $PWD/tools/plantuml/parser/integration_test/component_diagram/simple_component.puml \
67+
--log-level trace \
68+
--diagram-type component \
69+
--fbs-output-dir $PWD/tools/plantuml/parser
70+
```
71+
## Architecture
72+
73+
The parser is organized into separate crate modules per diagram type:
74+
75+
```
76+
puml_parser/
77+
├── src/
78+
│ ├── class_diagram/ # Class diagram parser (pest grammar → AST)
79+
│ ├── component_diagram/ # Component diagram parser
80+
│ ├── sequence_diagram/ # Sequence diagram parser (two-stage: syntax → logic)
81+
│ └── ... # Shared utilities (parser_core, puml_utils)
82+
puml_cli/ # CLI entry point (clap-based)
83+
```
84+
85+
Each diagram parser uses [pest](https://pest.rs/) PEG grammars to tokenize PlantUML input,
86+
then builds a typed AST. The CLI (`puml_cli`) dispatches to the appropriate parser based on
87+
`--diagram-type` or auto-detection.
88+
89+
For the detailed design and users Guide, see [README](docs/README.md).

0 commit comments

Comments
 (0)