Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Terrabuild.Configuration.Tests/TestFiles/WORKSPACE2
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ configuration {
secret: $map.toto == "prod" ? 1234 : 5678
secret2: $list.2
secret3: !false + !true
secret4: format("1" 2 $toto true nothing)
secret4: format("1", 2, $toto, true, nothing)
}
}

Expand All @@ -48,7 +48,7 @@ extension dotnet {
defaults = {
configuration1: $map.toto
configuration2: $map.?titi
configuration3: replace("toto titi" "toto" "titi")
configuration3: replace("toto titi", "toto", "titi")
}
}

Expand Down
660 changes: 354 additions & 306 deletions src/Terrabuild.Configuration/Gen/ProjectParser.fs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Terrabuild.Configuration/Gen/ProjectParser.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ type nonTerminalId =
| NONTERM_ExprIndex
| NONTERM_Bool
| NONTERM_String
| NONTERM_ExprTuple
| NONTERM_ExprTupleContent
| NONTERM_ExprList
| NONTERM_ExprListContent
| NONTERM_ExprMap
Expand Down
576 changes: 312 additions & 264 deletions src/Terrabuild.Configuration/Gen/WorkspaceParser.fs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Terrabuild.Configuration/Gen/WorkspaceParser.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ type nonTerminalId =
| NONTERM_ExprIndex
| NONTERM_Bool
| NONTERM_String
| NONTERM_ExprTuple
| NONTERM_ExprTupleContent
| NONTERM_ExprList
| NONTERM_ExprListContent
| NONTERM_ExprMap
Expand Down
22 changes: 15 additions & 7 deletions src/Terrabuild.Configuration/ProjectParser/Parser.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let debugPrint s = ignore s
%left PLUS
%left DOT DOT_QUESTION
%right BANG
%left COMMA

%type <Terrabuild.Configuration.Project.AST.ProjectFile> ProjectFile
%%
Expand Down Expand Up @@ -141,13 +142,13 @@ Expr:
| Expr NOT_EQUAL Expr { Expr.Function (Function.NotEqual, [$1; $3]) }
| Expr PLUS Expr { Expr.Function (Function.Plus, [$1; $3]) }
| Expr MINUS Expr { Expr.Function (Function.Minus, [$1; $3]) }
| TRIM LPAREN Expr RPAREN { Expr.Function (Function.Trim, [$3]) }
| UPPER LPAREN Expr RPAREN { Expr.Function (Function.Upper, [$3]) }
| LOWER LPAREN Expr RPAREN { Expr.Function (Function.Lower, [$3]) }
| REPLACE LPAREN Expr Expr Expr RPAREN { Expr.Function (Function.Replace, [$3; $4; $5]) }
| COUNT LPAREN Expr RPAREN { Expr.Function (Function.Count, [$3])}
| VERSION LPAREN Expr RPAREN { Expr.Function (Function.Version, [$3]) }
| FORMAT LPAREN ExprListContent RPAREN { Expr.Function (Function.Format, $3) }
| TRIM ExprTuple { Expr.Function (Function.Trim, $2) }
| UPPER ExprTuple { Expr.Function (Function.Upper, $2) }
| LOWER ExprTuple { Expr.Function (Function.Lower, $2) }
| REPLACE ExprTuple { Expr.Function (Function.Replace, $2) }
| COUNT ExprTuple { Expr.Function (Function.Count, $2)}
| VERSION ExprTuple { Expr.Function (Function.Version, $2) }
| FORMAT ExprTuple { Expr.Function (Function.Format, $2) }
| Expr DOUBLE_QUESTION Expr { Expr.Function (Function.Coalesce, [$1; $3]) }
| Expr QUESTION Expr COLON Expr { Expr.Function (Function.Ternary, [$1; $3; $5] ) }
| BANG Expr { Expr.Function (Function.Not, [$2]) }
Expand All @@ -171,6 +172,13 @@ Bool:
String:
| STRING { $1 }

ExprTuple:
| LPAREN ExprTupleContent RPAREN { $2 }
ExprTupleContent:
| /* empty */ { [] }
| Expr { [$1] }
| ExprTupleContent COMMA Expr { $1 @ [$3] }

ExprList:
| LSQBRACKET ExprListContent RSQBRACKET { $2 }
ExprListContent:
Expand Down
22 changes: 15 additions & 7 deletions src/Terrabuild.Configuration/WorkspaceParser/Parser.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let debugPrint s = ignore s
%left PLUS
%left DOT DOT_QUESTION
%right BANG
%left COMMA

%type <Terrabuild.Configuration.Workspace.AST.WorkspaceFile> WorkspaceFile
%%
Expand Down Expand Up @@ -126,13 +127,13 @@ Expr:
| Expr NOT_EQUAL Expr { Expr.Function (Function.NotEqual, [$1; $3]) }
| Expr PLUS Expr { Expr.Function (Function.Plus, [$1; $3]) }
| Expr MINUS Expr { Expr.Function (Function.Minus, [$1; $3]) }
| TRIM LPAREN Expr RPAREN { Expr.Function (Function.Trim, [$3]) }
| UPPER LPAREN Expr RPAREN { Expr.Function (Function.Upper, [$3]) }
| LOWER LPAREN Expr RPAREN { Expr.Function (Function.Lower, [$3]) }
| REPLACE LPAREN Expr Expr Expr RPAREN { Expr.Function (Function.Replace, [$3; $4; $5]) }
| COUNT LPAREN Expr RPAREN { Expr.Function (Function.Count, [$3])}
| VERSION LPAREN Expr RPAREN { Expr.Function (Function.Version, [$3]) }
| FORMAT LPAREN ExprListContent RPAREN { Expr.Function (Function.Format, $3) }
| TRIM ExprTuple { Expr.Function (Function.Trim, $2) }
| UPPER ExprTuple { Expr.Function (Function.Upper, $2) }
| LOWER ExprTuple { Expr.Function (Function.Lower, $2) }
| REPLACE ExprTuple { Expr.Function (Function.Replace, $2) }
| COUNT ExprTuple { Expr.Function (Function.Count, $2)}
| VERSION ExprTuple { Expr.Function (Function.Version, $2) }
| FORMAT ExprTuple { Expr.Function (Function.Format, $2) }
| Expr DOUBLE_QUESTION Expr { Expr.Function (Function.Coalesce, [$1; $3]) }
| Expr QUESTION Expr COLON Expr { Expr.Function (Function.Ternary, [$1; $3; $5] ) }
| BANG Expr { Expr.Function (Function.Not, [$2]) }
Expand All @@ -156,6 +157,13 @@ Bool:
String:
| STRING { $1 }

ExprTuple:
| LPAREN ExprTupleContent RPAREN { $2 }
ExprTupleContent:
| /* empty */ { [] }
| Expr { [$1] }
| ExprTupleContent COMMA Expr { $1 @ [$3] }

ExprList:
| LSQBRACKET ExprListContent RSQBRACKET { $2 }
ExprListContent:
Expand Down
2 changes: 1 addition & 1 deletion src/Terrabuild.Expressions/Eval.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let rec eval (context: EvaluationContext) (expr: Expr) =
| Value.Bool b -> if b then "true" else "false"
| Value.Number n -> $"{n}"
| Value.String s -> s
| _ -> TerrabuildException.Raise($"Unsupported type for format")
| _ -> TerrabuildException.Raise($"Unsupported type for format {v}")

values
|> List.fold (fun acc value -> $"{acc}{formatValue value}") ""
Expand Down