added delay to parser

This commit is contained in:
Louis Heredero 2024-10-08 12:14:20 +02:00
parent 0bfe68b429
commit f369fc6e43
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7
3 changed files with 30 additions and 1 deletions

Binary file not shown.

View File

@ -267,6 +267,20 @@
@enduml @enduml
``` ```
), ),
(
[Delay],
```
@startuml
Alice -> Bob: Authentication Request
...
Bob --> Alice: Authentication Response
...5 minutes later...
Bob --> Alice: Good Bye !
@enduml
```
),
( (
[Space], [Space],
``` ```

View File

@ -1,6 +1,6 @@
#import "diagram.typ": diagram, _par, _evt, _gap #import "diagram.typ": diagram, _par, _evt, _gap
#import "participant.typ": SHAPES #import "participant.typ": SHAPES
#import "separator.typ": _sep #import "separator.typ": _sep, _delay
#import "sequence.typ": _seq, _ret #import "sequence.typ": _seq, _ret
#import "group.typ": _grp, _alt #import "group.typ": _grp, _alt
#import "note.typ": _note, SIDES #import "note.typ": _note, SIDES
@ -384,6 +384,19 @@
return _gap(size: size) return _gap(size: size)
} }
#let is-delay-stmt(line) = {
return line.starts-with("...")
}
#let parse-delay-stmt(line) = {
if line == "..." {
return _delay()
}
let m = line.match(regex("\.\.\.\s*(.*?)\s*\.\.\."))
let name = m.captures.first()
return _delay(name: name)
}
#let is-sep-stmt(line) = { #let is-sep-stmt(line) = {
return line.starts-with("==") and line.ends-with("==") return line.starts-with("==") and line.ends-with("==")
} }
@ -961,6 +974,8 @@
elmts += parse-par-stmt(line) elmts += parse-par-stmt(line)
} else if is-gap-stmt(line) { } else if is-gap-stmt(line) {
elmts += parse-gap-stmt(line) elmts += parse-gap-stmt(line)
} else if is-delay-stmt(line) {
elmts += parse-delay-stmt(line)
} else if is-sep-stmt(line) { } else if is-sep-stmt(line) {
elmts += parse-sep-stmt(line) elmts += parse-sep-stmt(line)
} else if is-evt-stmt(line) { } else if is-evt-stmt(line) {