Skip to content

Commit 8699cd7

Browse files
authored
Merge pull request #3 from TypedUseCase/fix/add-missing-keyword-if
Add missing KeyWord value to KeyWordIf
2 parents 80365ae + 48c3789 commit 8699cd7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<!-- There is always Unreleased section on the top. Subsections (Add, Changed, Fix, Removed) should be Add as needed. -->
44
## Unreleased
5+
- Add missing `KeyWord` value to `KeyWordIf`
56

67
## 2.0.0 - 2020-11-06
78
- [**BC**] Add `alias` keyWord location to Parsed Participant Definition

src/Tuc/ParsedTypes.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,13 @@ and ParsedKeyWordWithBody<'Type> = {
153153

154154
and ParsedKeyWordIf<'Type> = {
155155
Value: 'Type
156+
IfKeyWord: KeyWord
156157
IfLocation: ParsedLocation
157158
ConditionLocation: ParsedLocation
158-
ElseLocation: ParsedLocation option
159159
Body: Parsed<TucPart> list
160+
161+
ElseKeyWord: KeyWord option
162+
ElseLocation: ParsedLocation option
160163
ElseBody: (Parsed<TucPart> list) option
161164
}
162165

@@ -239,7 +242,7 @@ module Parsed =
239242
| Parsed.KeyWord k -> Parsed.KeyWord { KeyWord = k.KeyWord; KeyWordLocation = k.KeyWordLocation; ValueLocation = k.ValueLocation; Value = k.Value |> f }
240243
| Parsed.KeyWordWithoutValue k -> Parsed.KeyWordWithoutValue { KeyWord = k.KeyWord; KeyWordLocation = k.KeyWordLocation }
241244
| Parsed.KeyWordWithBody k -> Parsed.KeyWordWithBody { KeyWord = k.KeyWord; KeyWordLocation = k.KeyWordLocation; ValueLocation = k.ValueLocation; Body = k.Body; Value = k.Value |> f }
242-
| Parsed.KeyWordIf k -> Parsed.KeyWordIf { IfLocation = k.IfLocation; ConditionLocation = k.ConditionLocation; ElseLocation = k.ElseLocation; Body = k.Body; ElseBody = k.ElseBody; Value = k.Value |> f }
245+
| Parsed.KeyWordIf k -> Parsed.KeyWordIf { IfKeyWord = k.IfKeyWord; IfLocation = k.IfLocation; ConditionLocation = k.ConditionLocation; ElseKeyWord = k.ElseKeyWord; ElseLocation = k.ElseLocation; Body = k.Body; ElseBody = k.ElseBody; Value = k.Value |> f }
243246
| Parsed.ParticipantDefinition p -> Parsed.ParticipantDefinition { Context = p.Context; Domain = p.Domain; Alias = p.Alias; Value = p.Value |> f }
244247
| Parsed.ComponentDefinition c -> Parsed.ComponentDefinition { Context = c.Context; Domain = c.Domain; Participants = c.Participants; Value = c.Value |> f }
245248
| Parsed.Lifeline l -> Parsed.Lifeline { ParticipantLocation = l.ParticipantLocation; Execution = l.Execution; Value = l.Value |> f }

src/Tuc/Parser/Parser.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ module Parser =
858858
Body = body |> List.map Parsed.value
859859
Else = elseBody |> Option.map (List.map Parsed.value)
860860
}
861+
IfKeyWord = KeyWord.If
861862
IfLocation = {
862863
Value = "if"
863864
Location = ifRange |> location
@@ -866,6 +867,7 @@ module Parser =
866867
Value = condition
867868
Location = ifRange |> Range.fromEnd 1 condition.Length |> location
868869
}
870+
ElseKeyWord = elseRange |> Option.map (fun _ -> KeyWord.Else)
869871
ElseLocation = elseRange |> Option.map (fun elseRange ->
870872
{
871873
Value = "else"

0 commit comments

Comments
 (0)