diff --git a/src/Visp.Compiler/Parser.fsy b/src/Visp.Compiler/Parser.fsy index 5ad3d1f..162be1b 100644 --- a/src/Visp.Compiler/Parser.fsy +++ b/src/Visp.Compiler/Parser.fsy @@ -1262,13 +1262,13 @@ rawConstant: function_def: | FN function_def_name function_def_args expr_list %prec prec_fn - { SynExpr.FunctionDef($2, FunctionFlags.None, $3, $4, (lhs parseState)) } + { SynExpr.FunctionDef($2, FunctionFlags.None, $3, $4, None, (lhs parseState)) } | FN INLINE function_def_name function_def_args expr_list %prec prec_fn - { SynExpr.FunctionDef($3, FunctionFlags.Inline, $4, $5, (lhs parseState)) } + { SynExpr.FunctionDef($3, FunctionFlags.Inline, $4, $5, None, (lhs parseState)) } | FN REC INLINE function_def_name function_def_args expr_list %prec prec_fn - { SynExpr.FunctionDef($4, FunctionFlags.Recursive ||| FunctionFlags.Inline, $5, $6, (lhs parseState)) } + { SynExpr.FunctionDef($4, FunctionFlags.Recursive ||| FunctionFlags.Inline, $5, $6, None, (lhs parseState)) } | FN REC function_def_name function_def_args expr_list %prec prec_fn - { SynExpr.FunctionDef($3, FunctionFlags.Recursive, $4, $5, (lhs parseState)) } + { SynExpr.FunctionDef($3, FunctionFlags.Recursive, $4, $5, None, (lhs parseState)) } | FN function_def_args expr_list %prec prec_lambda_def { SynExpr.LambdaDef(SynLambda($2, $3, (lhs parseState))) } | FNSTAR function_def_args expr_list @@ -1290,15 +1290,15 @@ invalid_function_def: { SynExpr.LambdaDef(SynLambda(mkRecoveryPat parseState, [], (lhs parseState))) } // TODO: Report | FN function_def_name %prec prec_invalid_fn - { SynExpr.FunctionDef($2, FunctionFlags.None, mkRecoveryPat parseState, [], lhs parseState) } + { SynExpr.FunctionDef($2, FunctionFlags.None, mkRecoveryPat parseState, [], None, lhs parseState) } // TODO: Report | FN function_def_args %prec prec_invalid_fn { SynExpr.LambdaDef(SynLambda(mkRecoveryPat parseState, [], (lhs parseState))) } // TODO: Report | FN function_def_name function_def_args %prec prec_invalid_fn - { SynExpr.FunctionDef($2, FunctionFlags.None, $3, [], (lhs parseState)) } + { SynExpr.FunctionDef($2, FunctionFlags.None, $3, [], None, (lhs parseState)) } | FN INLINE function_def_name function_def_args %prec prec_invalid_fn - { SynExpr.FunctionDef($3, FunctionFlags.Inline, $4, [], (lhs parseState)) } + { SynExpr.FunctionDef($3, FunctionFlags.Inline, $4, [], None, (lhs parseState)) } function_call: | expr expr_list { Syntax.mkFunctionCallOrCexpr $1 $2 (lhs parseState)} diff --git a/src/Visp.Compiler/Syntax/FsLexYaccOutput/Parser.fs b/src/Visp.Compiler/Syntax/FsLexYaccOutput/Parser.fs index 7c2f09a..35b640c 100644 --- a/src/Visp.Compiler/Syntax/FsLexYaccOutput/Parser.fs +++ b/src/Visp.Compiler/Syntax/FsLexYaccOutput/Parser.fs @@ -7281,7 +7281,7 @@ let _fsyacc_reductions = lazy [| ( ( # 1265 "Parser.fsy" - SynExpr.FunctionDef(_2, FunctionFlags.None, _3, _4, (lhs parseState)) + SynExpr.FunctionDef(_2, FunctionFlags.None, _3, _4, None, (lhs parseState)) ) # 1265 "Parser.fsy" : 'gentype_function_def)); @@ -7294,7 +7294,7 @@ let _fsyacc_reductions = lazy [| ( ( # 1267 "Parser.fsy" - SynExpr.FunctionDef(_3, FunctionFlags.Inline, _4, _5, (lhs parseState)) + SynExpr.FunctionDef(_3, FunctionFlags.Inline, _4, _5, None, (lhs parseState)) ) # 1267 "Parser.fsy" : 'gentype_function_def)); @@ -7307,7 +7307,7 @@ let _fsyacc_reductions = lazy [| ( ( # 1269 "Parser.fsy" - SynExpr.FunctionDef(_4, FunctionFlags.Recursive ||| FunctionFlags.Inline, _5, _6, (lhs parseState)) + SynExpr.FunctionDef(_4, FunctionFlags.Recursive ||| FunctionFlags.Inline, _5, _6, None, (lhs parseState)) ) # 1269 "Parser.fsy" : 'gentype_function_def)); @@ -7320,7 +7320,7 @@ let _fsyacc_reductions = lazy [| ( ( # 1271 "Parser.fsy" - SynExpr.FunctionDef(_3, FunctionFlags.Recursive, _4, _5, (lhs parseState)) + SynExpr.FunctionDef(_3, FunctionFlags.Recursive, _4, _5, None, (lhs parseState)) ) # 1271 "Parser.fsy" : 'gentype_function_def)); @@ -7444,7 +7444,7 @@ let _fsyacc_reductions = lazy [| ( ( # 1293 "Parser.fsy" - SynExpr.FunctionDef(_2, FunctionFlags.None, mkRecoveryPat parseState, [], lhs parseState) + SynExpr.FunctionDef(_2, FunctionFlags.None, mkRecoveryPat parseState, [], None, lhs parseState) ) # 1293 "Parser.fsy" : 'gentype_invalid_function_def)); @@ -7467,7 +7467,7 @@ let _fsyacc_reductions = lazy [| ( ( # 1299 "Parser.fsy" - SynExpr.FunctionDef(_2, FunctionFlags.None, _3, [], (lhs parseState)) + SynExpr.FunctionDef(_2, FunctionFlags.None, _3, [], None, (lhs parseState)) ) # 1299 "Parser.fsy" : 'gentype_invalid_function_def)); @@ -7479,7 +7479,7 @@ let _fsyacc_reductions = lazy [| ( ( # 1301 "Parser.fsy" - SynExpr.FunctionDef(_3, FunctionFlags.Inline, _4, [], (lhs parseState)) + SynExpr.FunctionDef(_3, FunctionFlags.Inline, _4, [], None, (lhs parseState)) ) # 1301 "Parser.fsy" : 'gentype_invalid_function_def)); diff --git a/src/Visp.Compiler/Syntax/SynWriter.fs b/src/Visp.Compiler/Syntax/SynWriter.fs index bc3ff9f..507efb3 100644 --- a/src/Visp.Compiler/Syntax/SynWriter.fs +++ b/src/Visp.Compiler/Syntax/SynWriter.fs @@ -758,7 +758,7 @@ module Write = () - | SynExpr.FunctionDef(name_, flags, args, body, range) -> + | SynExpr.FunctionDef(name_, flags, args, body, retty, range) -> startExpr w st range string w "let " @@ -773,6 +773,14 @@ module Write = space w //writeArgsOrEmpty w args synPat w args + + match retty with + | None -> () + | Some(ty) -> + string w " : " + writeType w ty + () + string w " =" use _ = withIndent w false diff --git a/src/Visp.Compiler/Syntax/Syntax.fs b/src/Visp.Compiler/Syntax/Syntax.fs index 0dd3e3e..c1ceca9 100644 --- a/src/Visp.Compiler/Syntax/Syntax.fs +++ b/src/Visp.Compiler/Syntax/Syntax.fs @@ -267,6 +267,7 @@ type SynExpr = flags: FunctionFlags * args: SynPat * body: SynExpr list * + returnType: SynType option * range: range | FunctionCall of name: SynExpr * args: SynExpr list * range: range | LambdaShort of expr: SynExpr * range: range @@ -657,7 +658,7 @@ module Patterns = | SynExpr.Symbol(SynSymbol(id)) -> id.idText | _ -> "" - let (|SymbolText|) (it: SynExpr) = + let (|SymbolText|_|) (it: SynExpr) = match it with | SynExpr.Symbol(sym) -> Some(sym.Text) | _ -> None diff --git a/src/Visp.Compiler/Syntax/SyntaxPrinter.fs b/src/Visp.Compiler/Syntax/SyntaxPrinter.fs index 08f5e52..0fded2b 100644 --- a/src/Visp.Compiler/Syntax/SyntaxPrinter.fs +++ b/src/Visp.Compiler/Syntax/SyntaxPrinter.fs @@ -235,7 +235,7 @@ let rec exprToDoc = | SynExpr.LambdaDef(def) -> lambdaToDoc def - | SynExpr.FunctionDef(name, flags, args, body, _) -> + | SynExpr.FunctionDef(name, flags, args, body, _, _) -> parens <| hcat diff --git a/src/Visp.Compiler/Transforms/Helpers.fs b/src/Visp.Compiler/Transforms/Helpers.fs index a2cb084..a671842 100644 --- a/src/Visp.Compiler/Transforms/Helpers.fs +++ b/src/Visp.Compiler/Transforms/Helpers.fs @@ -49,8 +49,8 @@ let rec transform (func: SynExpr -> SynExpr) expr = Option.map bound_transform alt, range ) - | SynExpr.FunctionDef(name, is, args, body, range) -> - SynExpr.FunctionDef(name, is, args, List.map bound_transform body, range) + | SynExpr.FunctionDef(name, is, args, body, retty, range) -> + SynExpr.FunctionDef(name, is, args, List.map bound_transform body, retty, range) | SynExpr.FunctionCall(name, args, range) -> SynExpr.FunctionCall(bound_transform name, List.map bound_transform args, range) | SynExpr.LambdaDef(SynLambda(args, body, lambdaRange)) -> diff --git a/src/Visp.Compiler/Transforms/StringLifter.fs b/src/Visp.Compiler/Transforms/StringLifter.fs index 00b42d8..9642866 100644 --- a/src/Visp.Compiler/Transforms/StringLifter.fs +++ b/src/Visp.Compiler/Transforms/StringLifter.fs @@ -10,35 +10,239 @@ open Visp.Compiler.Text open Visp.Common open Visp.Compiler +type private Str = string * SynStringKind * range + +let inline private toListAndReturn (lst: ResizeArray<'T>) = + let mutable res = ([]: 'T list) + + for i = lst.Count - 1 downto 0 do + res <- lst[i] :: res + + lst.ReturnToPool() + + res + +let private handleInterpolatedString nest ((raw, kind, stringRange): Str) (constRange: range) = + let normalized = Visp.Runtime.Library.StringMethods.normalizeIndent raw + let tempSb = PooledStringBuilder.Get() + + for _ = 1 to nest do + ignore <| tempSb.Append('{') + + let openBraces = tempSb.ToStringAndClear() + + for _ = 1 to nest do + ignore <| tempSb.Append('}') + + let closeBraces = tempSb.ToStringAndClear() + + let mutable argIndex = 0 + let variables = PooledList.Get() + let expressions = PooledList.Get() + + let mutable span = normalized.AsSpan() + let mutable loop = true + + let resultSb = PooledStringBuilder.Get() + resultSb.EnsureCapacity(raw.Length) |> ignore + + while loop && not span.IsEmpty do + let openIndex = span.IndexOf(openBraces) + + if openIndex = -1 then + resultSb.Append(span) |> ignore + loop <- false + else + resultSb.Append(span.Slice(0, openIndex)) |> ignore + + let currentSlice = span.Slice(openIndex + openBraces.Length) + let closeIndex = currentSlice.IndexOf(closeBraces) + + if closeIndex = -1 then + resultSb.Append(span) |> ignore + loop <- false + else + let varNameSlice = currentSlice.Slice(0, closeIndex) + let colonIndex = varNameSlice.IndexOf(':') + + let (varName, fmt) = + if colonIndex = -1 then + let name = tempSb.Append(varNameSlice).ToStringAndClear() + (name, "") + else + let fmtSlice = varNameSlice.Slice(colonIndex) + let fmt = tempSb.Append(fmtSlice).ToStringAndClear() + let varNameSlice = varNameSlice.Slice(0, colonIndex) + let name = tempSb.Append(varNameSlice).ToStringAndClear() + (name, fmt) + + let expr = ParseUtils.parseStringToExpr constRange.FileName varName + + let needsArg = + match expr with + | SynExpr.Symbol it -> it.Text.Contains('.') + | _ -> true + + if needsArg then + let argName = tempSb.Append("exprArg").Append(argIndex).ToStringAndClear() + + variables.Add(argName) + argIndex <- argIndex + 1 + + resultSb.Append(openBraces).Append(argName).Append(fmt).Append(closeBraces) + |> ignore + + expressions.Add(expr) + else + resultSb.Append(openBraces).Append(varName).Append(fmt).Append(closeBraces) + |> ignore + + match Seq.tryFindIndex (fun it -> it = varName) variables with + | Some _ -> () + | None -> + variables.Add(varName) + expressions.Add(expr) + + + span <- currentSlice.Slice(closeIndex + closeBraces.Length) + () + + () + + () + + tempSb.ReturnToPool() + + let newStrConst = + SynExpr.Const(SynConst.String(resultSb.ToStringAndReturn(), kind, stringRange), constRange) + + (newStrConst, toListAndReturn variables, toListAndReturn expressions) + +let fmtTypeFactory (name: string) range = + SynType.Ident( + Ident( + (if name.StartsWith("Printf.") then + name + else + "Printf." + name), + range + ) + ) + +let private (|ArgMatch|_|) (index: int) (args: 'a list) = + match index with + | 0 -> + match args with + | it :: _ -> Some(it) + | _ -> None + | 1 -> + match args with + | _ :: it :: _ -> Some(it) + | _ -> None + | 2 -> + match args with + | _ :: _ :: it :: _ -> Some(it) + | _ -> None + | _ -> None + +type private FmtMethod = + { name: string + typeName: string + fmtArgPos: int } + +let private mkFmtMethod n t a = + { name = n + typeName = t + fmtArgPos = a } + +// https://github.com/dotnet/fsharp/blob/99514c0fafa1f4a9ddf63e0439ec8804d87276eb/src/FSharp.Core/printf.fsi#L101-L443 +let private fmtMethods = + [ mkFmtMethod "bprintf" "BuilderFormat<_>" 1 + mkFmtMethod "fprintf" "TextWriterFormat<_>" 1 + mkFmtMethod "fprintfn" "TextWriterFormat<_>" 1 + mkFmtMethod "eprintf" "TextWriterFormat<_>" 0 + mkFmtMethod "eprintfn" "TextWriterFormat<_>" 0 + mkFmtMethod "printf" "TextWriterFormat<_>" 0 + mkFmtMethod "printfn" "TextWriterFormat<_>" 0 + mkFmtMethod "sprintf" "StringFormat<_>" 0 + mkFmtMethod "kbprintf" "BuilderFormat<_, _>" 2 + mkFmtMethod "kfprintf" "TextWriterFormat<_, _>" 2 + mkFmtMethod "kprintf" "StringFormat<_, _>" 1 + mkFmtMethod "ksprintf" "StringFormat<_, _>" 1 + mkFmtMethod "failwithf" "StringFormat<_, _>" 0 ] + +/// match method name based on the last non-dotted part +let private matchesFmtMethod (str: string) (met: FmtMethod) = + let mutable strSpan = str.AsSpan() + let dotIndex = str.IndexOf('.') + + if dotIndex > -1 then + strSpan <- strSpan.Slice(dotIndex + 1) + + strSpan.Equals(met.name, StringComparison.Ordinal) + +let private tryGetFmtMethod (str: string) = + fmtMethods |> List.tryFind (matchesFmtMethod str) + +let private (|FormatMethod|_|) (ex: SynExpr) = + match ex with + | Patterns.SymbolText maybeFmt -> tryGetFmtMethod maybeFmt + | _ -> None + let liftLiteralStrings (file: ParsedFile) = - let liftableStrings = new ResizeArray<_>() + use liftableStringsPooled = PooledDictionary.GetPooled() + let liftableStrings = liftableStringsPooled.Value let mutable strIndex = 0 - let mutable minRange = range.Zero - let mutable maxRange = range.Zero + + let getNextName (constRange: range) = + let fileName = System.IO.Path.GetFileNameWithoutExtension constRange.FileName + let name = $"LiftedString{strIndex}_{fileName}" + let nameExpr = Syntax.mkSynSymbolExpr name constRange + strIndex <- strIndex + 1 + (name, nameExpr) + + let (|InterpolatedStringCall|_|) (ex: SynExpr) = + match ex with + | SynExpr.FunctionCall(Patterns.SymbolWith maybeLifted, _, _) -> + match liftableStrings.TryGetValue maybeLifted with + | true, ex -> Some((maybeLifted, ex)) + | _ -> None + | _ -> None let file = file |> Helpers.transformParsedFile (function - | SynExpr.Const(SynConst.String(raw, kind, stringRange), constRange) as ex -> - - if strIndex = 0 then - minRange <- constRange + | SynExpr.FunctionCall(FormatMethod fmtMethod, args, _) as it -> + let argIndex = fmtMethod.fmtArgPos - maxRange <- constRange + match args with + | ArgMatch argIndex (InterpolatedStringCall(name, + SynExpr.FunctionDef(fnname, + flags, + args, + body, + None, + range))) -> - let fileName = System.IO.Path.GetFileNameWithoutExtension stringRange.FileName + let retTy = fmtTypeFactory fmtMethod.typeName range - let name = $"LiftedString{strIndex}_{fileName}" - strIndex <- strIndex + 1 + liftableStrings[name] <- + SynExpr.FunctionDef(fnname, flags, args, body, Some retTy, range) - let normalized = Visp.Runtime.Library.StringMethods.normalizeIndent raw - let nameExpr = Syntax.mkSynSymbolExpr name constRange + () + | _ -> () + it + | SynExpr.Const(SynConst.String(raw, kind, stringRange), constRange) as ex -> match kind with | SynStringKind.Verbatim | SynStringKind.Regular | SynStringKind.TripleQuote -> if Visp.Runtime.Library.StringMethods.isMultilineString raw then + let (name, nameExpr) = getNextName constRange + + let normalized = Visp.Runtime.Library.StringMethods.normalizeIndent raw + let bind = SynExpr.LetOrUse( Syntax.mkInferredNamePat name constRange, @@ -51,113 +255,41 @@ let liftLiteralStrings (file: ParsedFile) = constRange ) - liftableStrings.Add(bind) + liftableStrings[name] <- bind nameExpr else ex | SynStringKind.Interpolated(plain = nest) | SynStringKind.InterpolatedTripleQuote(triple = nest) -> - let sb = PooledStringBuilder.Get() - - for _ = 1 to nest do - ignore <| sb.Append('{') - - let op = sb.ToStringAndClear() - - for _ = 1 to nest do - ignore <| sb.Append('}') - - let cl = sb.ToStringAndClear() - - let mutable argIndex = 0 - let variables = ResizeArray<_>() - let expressions = ResizeArray<_>() - - let mutable span = normalized.AsSpan() - let mutable loop = true - - let resultSb = PooledStringBuilder.Get() - - while loop && not span.IsEmpty do - let openIndex = span.IndexOf(op) - - if openIndex = -1 then - resultSb.Append(span) |> ignore - loop <- false - else - resultSb.Append(span.Slice(0, openIndex)) |> ignore - - let currentSlice = span.Slice(openIndex + op.Length) - let closeIndex = currentSlice.IndexOf(cl) - - if closeIndex = -1 then - resultSb.Append(span) |> ignore - loop <- false - else - sb.Append(currentSlice.Slice(0, closeIndex)) |> ignore - let varName = sb.ToStringAndClear() - - let expr = ParseUtils.parseStringToExpr constRange.FileName varName - - let needsArg = - match expr with - | SynExpr.Symbol it -> it.Text.Contains('.') - | _ -> true - - if needsArg then - sb.Append("exprArg").Append(argIndex) |> ignore - let argName = sb.ToStringAndClear() - variables.Add(argName) - argIndex <- argIndex + 1 - resultSb.Append(op).Append(argName).Append(cl) |> ignore - expressions.Add(expr) - else - resultSb.Append(op).Append(varName).Append(cl) |> ignore - - match Seq.tryFindIndex (fun it -> it = varName) variables with - | Some _ -> () - | None -> - variables.Add(varName) - expressions.Add(expr) - - - span <- currentSlice.Slice(closeIndex + cl.Length) - () - - () - - () + let (name, nameExpr) = getNextName constRange - sb.ReturnToPool() + let (newConst, variables, expressions) = + handleInterpolatedString nest (raw, kind, stringRange) constRange let args = - variables - |> Seq.map (fun it -> Syntax.mkInferredNamePat it constRange) - |> List.ofSeq + variables |> List.map (fun it -> Syntax.mkInferredNamePat it constRange) let func = SynExpr.FunctionDef( Syntax.mkSynSymbol name constRange, FunctionFlags.Inline, SynPat.Args(SynArgPats.List(args), constRange), - [ SynExpr.Const( - SynConst.String(resultSb.ToStringAndReturn(), kind, stringRange), - constRange - ) ], + [ newConst ], + None, constRange ) - liftableStrings.Add(func) - SynExpr.FunctionCall(nameExpr, expressions |> List.ofSeq, constRange) + liftableStrings[name] <- func + SynExpr.FunctionCall(nameExpr, expressions, constRange) | it -> it) let moduleDecls = - liftableStrings - |> Seq.map (fun expr -> SynModuleDecl.Expr(expr, expr.Range)) + liftableStrings.Values + |> Seq.map (fun expr -> + ParsedFileFragment.AnonModule([ SynModuleDecl.Expr(expr, expr.Range) ], expr.Range)) |> List.ofSeq - |> (fun its -> ParsedFileFragment.AnonModule(its, Range.unionRanges minRange maxRange)) let (ParsedFile frags) = file - ParsedFile(moduleDecls :: frags) + ParsedFile(moduleDecls @ frags) diff --git a/src/Visp.Compiler/Transforms/Traversal.fs b/src/Visp.Compiler/Transforms/Traversal.fs index 2bdf8eb..adaa95b 100644 --- a/src/Visp.Compiler/Transforms/Traversal.fs +++ b/src/Visp.Compiler/Transforms/Traversal.fs @@ -181,7 +181,7 @@ let depthFirstExprsUntilFalse (pred: SynExpr -> bool) (expr: SynExpr) = | Some a -> yield! loop a | None -> () - | SynExpr.FunctionDef(_, _, _, args, _) -> + | SynExpr.FunctionDef(_, _, _, args, _, _) -> for arg in args do yield! loop arg diff --git a/src/Visp.LanguageServer/LanguageServer.fs b/src/Visp.LanguageServer/LanguageServer.fs index 580afd7..2b5a1f3 100644 --- a/src/Visp.LanguageServer/LanguageServer.fs +++ b/src/Visp.LanguageServer/LanguageServer.fs @@ -337,7 +337,7 @@ let findAllSymbolDetails (syms: ResizeArray<_>) expr = syms.Add(SymbolDetails.SyntaxMacro(text, textRangeToSyntaxRange range)) () - | SynExpr.FunctionDef(name, _, args, _, _) -> + | SynExpr.FunctionDef(name, _, args, _, _, _) -> let r = Syntax.rangeOfSymbol name diff --git a/src/Visp.Runtime.Library/StringMethods.fs b/src/Visp.Runtime.Library/StringMethods.fs index e664bfc..92b884f 100644 --- a/src/Visp.Runtime.Library/StringMethods.fs +++ b/src/Visp.Runtime.Library/StringMethods.fs @@ -22,13 +22,15 @@ let normalizeIndent (str: string) = while lines.MoveNext() do let cur = lines.Current - let mutable enu = cur.GetEnumerator() - let mutable isDone = false + let len = cur.Length + let mutable isDone = false let mutable level = 0 + let mutable index = 0 - while not isDone && enu.MoveNext() do - let ch = enu.Current + while not isDone && index < len do + let ch = cur[index] + index <- index + 1 if not (System.Char.IsWhiteSpace ch) then isDone <- true @@ -43,31 +45,35 @@ let normalizeIndent (str: string) = if finalIndentLevel = 0 then str else + let len = str.Length let mutable sb = PooledStringBuilder.Get() - ignore <| sb.EnsureCapacity(str.Length) + ignore <| sb.EnsureCapacity(len) let mutable lastNewline = false let mutable indent = 1 - let mutable enu = str.GetEnumerator() + let mutable index = 0 - while (enu.MoveNext()) do - let mutable ch = enu.Current + while index < len do + let mutable ch = str[index] + index <- index + 1 if ch = '\n' && finalIndentLevel > 0 then lastNewline <- true indent <- 1 sb <- sb.Append ch else if lastNewline && ch = ' ' then - while (indent < finalIndentLevel && ch = ' ' && enu.MoveNext()) do + while (indent < finalIndentLevel && ch = ' ' && index < len) do + ch <- str[index] indent <- indent + 1 - ch <- enu.Current + index <- index + 1 () if ch <> ' ' then sb <- sb.Append ch - while ch = ' ' && enu.MoveNext() do - ch <- enu.Current + while ch = ' ' && index < len do + ch <- str[index] sb <- sb.Append ch + index <- index + 1 () lastNewline <- false diff --git a/tests/Visp.Compiler.UnitTests/ParsingTests.generated.fs b/tests/Visp.Compiler.UnitTests/ParsingTests.generated.fs index ec921b2..d62945f 100644 --- a/tests/Visp.Compiler.UnitTests/ParsingTests.generated.fs +++ b/tests/Visp.Compiler.UnitTests/ParsingTests.generated.fs @@ -65,6 +65,11 @@ module ``tests_type_custom-comparison-0`` = [] let ``can parse`` () = TestUtils.runTest "tests/type/custom-comparison-0.visp" +[] +module ``tests_type_byrefs-0`` = + [] + let ``can parse`` () = TestUtils.runTest "tests/type/byrefs-0.visp" + [] module ``tests_type_static-members-0`` = [] @@ -155,6 +160,11 @@ module ``tests_parsing_match-0`` = [] let ``can parse`` () = TestUtils.runTest "tests/parsing/match-0.visp" +[] +module ``tests_parsing_strings-interpolation-3`` = + [] + let ``can parse`` () = TestUtils.runTest "tests/parsing/strings-interpolation-3.visp" + [] module ``tests_parsing_sym-with-arrow-in-macro-0`` = [] @@ -230,6 +240,11 @@ module ``tests_parsing_tupled-special-forms-0`` = [] let ``can parse`` () = TestUtils.runTest "tests/parsing/tupled-special-forms-0.visp" +[] +module ``tests_parsing_strings-interpolation-2`` = + [] + let ``can parse`` () = TestUtils.runTest "tests/parsing/strings-interpolation-2.visp" + [] module ``tests_parsing_operators-1`` = [] diff --git a/tests/Visp.Compiler.UnitTests/StructuredOutputTests.generated.fs b/tests/Visp.Compiler.UnitTests/StructuredOutputTests.generated.fs index 7aa267b..4d3bf35 100644 --- a/tests/Visp.Compiler.UnitTests/StructuredOutputTests.generated.fs +++ b/tests/Visp.Compiler.UnitTests/StructuredOutputTests.generated.fs @@ -65,6 +65,11 @@ module ``tests_type_custom-comparison-0`` = [] let ``structured output`` () = TestUtils.runStructuredOutputTest "tests/type/custom-comparison-0.visp" +[] +module ``tests_type_byrefs-0`` = + [] + let ``structured output`` () = TestUtils.runStructuredOutputTest "tests/type/byrefs-0.visp" + [] module ``tests_type_static-members-0`` = [] @@ -155,6 +160,11 @@ module ``tests_parsing_match-0`` = [] let ``structured output`` () = TestUtils.runStructuredOutputTest "tests/parsing/match-0.visp" +[] +module ``tests_parsing_strings-interpolation-3`` = + [] + let ``structured output`` () = TestUtils.runStructuredOutputTest "tests/parsing/strings-interpolation-3.visp" + [] module ``tests_parsing_sym-with-arrow-in-macro-0`` = [] @@ -230,6 +240,11 @@ module ``tests_parsing_tupled-special-forms-0`` = [] let ``structured output`` () = TestUtils.runStructuredOutputTest "tests/parsing/tupled-special-forms-0.visp" +[] +module ``tests_parsing_strings-interpolation-2`` = + [] + let ``structured output`` () = TestUtils.runStructuredOutputTest "tests/parsing/strings-interpolation-2.visp" + [] module ``tests_parsing_operators-1`` = [] diff --git a/tests/Visp.Compiler.UnitTests/TokenOutputTests.generated.fs b/tests/Visp.Compiler.UnitTests/TokenOutputTests.generated.fs index 675c159..4d0f0fa 100644 --- a/tests/Visp.Compiler.UnitTests/TokenOutputTests.generated.fs +++ b/tests/Visp.Compiler.UnitTests/TokenOutputTests.generated.fs @@ -65,6 +65,11 @@ module ``tests_type_custom-comparison-0`` = [] let ``returns tokens`` () = TestUtils.runTokenTest "tests/type/custom-comparison-0.visp" +[] +module ``tests_type_byrefs-0`` = + [] + let ``returns tokens`` () = TestUtils.runTokenTest "tests/type/byrefs-0.visp" + [] module ``tests_type_static-members-0`` = [] @@ -155,6 +160,11 @@ module ``tests_parsing_match-0`` = [] let ``returns tokens`` () = TestUtils.runTokenTest "tests/parsing/match-0.visp" +[] +module ``tests_parsing_strings-interpolation-3`` = + [] + let ``returns tokens`` () = TestUtils.runTokenTest "tests/parsing/strings-interpolation-3.visp" + [] module ``tests_parsing_sym-with-arrow-in-macro-0`` = [] @@ -230,6 +240,11 @@ module ``tests_parsing_tupled-special-forms-0`` = [] let ``returns tokens`` () = TestUtils.runTokenTest "tests/parsing/tupled-special-forms-0.visp" +[] +module ``tests_parsing_strings-interpolation-2`` = + [] + let ``returns tokens`` () = TestUtils.runTokenTest "tests/parsing/strings-interpolation-2.visp" + [] module ``tests_parsing_operators-1`` = [] diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_atom_atom-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_atom_atom-0.structured output.verified.txt index f7095e1..324290b 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_atom_atom-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_atom_atom-0.structured output.verified.txt @@ -12,7 +12,7 @@ (SynSymbol +, [Const (Int64 1L, (12,19--12,21)); FunctionCall (Symbol (SynSymbol unwrapInt), [Symbol (SynSymbol v)], (12,23--12,34))], - (12,17--12,35)))], (12,5--12,36))], (11,1--12,37)), (11,0--12,38)); + (12,17--12,35)))], (12,5--12,36))], None, (11,1--12,37)), (11,0--12,38)); Expr (LetOrUse (Named (SynSymbol count, (13,5--13,10)), Atom (Const (Int64 0L, (13,17--13,19)), (13,12--13,19)), None, [], diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_builtin-macros_thread-first-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_builtin-macros_thread-first-1.structured output.verified.txt index db4021f..1b00970 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_builtin-macros_thread-first-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_builtin-macros_thread-first-1.structured output.verified.txt @@ -3,7 +3,7 @@ ([Expr (FunctionDef (SynSymbol identity, None, Args (List [Named (SynSymbol arg, (9,14--9,17))], (9,13--9,18)), - [Symbol (SynSymbol arg)], (9,1--9,22)), (9,0--9,23)); + [Symbol (SynSymbol arg)], None, (9,1--9,22)), (9,0--9,23)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (11,0--17,6)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_cexpr_cexpr-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_cexpr_cexpr-1.structured output.verified.txt index f52cdcb..c3f393b 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_cexpr_cexpr-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_cexpr_cexpr-1.structured output.verified.txt @@ -16,7 +16,7 @@ FunctionCall (Symbol (SynSymbol printfn), [Const (String ("continuing...", Regular, (13,16--13,31)), (13,16--13,31))], (13,8--13,31)); - FsReturn (Const (Int32 1, (14,15--14,16)), false, (14,8--14,16))], (11,3--14,17))], (10,1--15,3)), + FsReturn (Const (Int32 1, (14,15--14,16)), false, (14,8--14,16))], (11,3--14,17))], None, (10,1--15,3)), (10,0--15,4)); Expr (LetOrUse diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-0.structured output.verified.txt index f450a81..ed49d1b 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-0.structured output.verified.txt @@ -7,7 +7,7 @@ [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("hello %s", Regular, (12,13--12,23)), (12,13--12,23)); Symbol (SynSymbol name)], - (12,5--12,28))], (10,1--12,29)), (10,0--12,30)); + (12,5--12,28))], None, (10,1--12,29)), (10,0--12,30)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (14,0--14,15)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-1.structured output.verified.txt index f245e59..f7f766a 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-1.structured output.verified.txt @@ -7,14 +7,14 @@ [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("hello %s", Regular, (12,13--12,23)), (12,13--12,23)); Symbol (SynSymbol name)], - (12,5--12,28))], (10,1--12,29)), (10,0--12,30)); + (12,5--12,28))], None, (10,1--12,29)), (10,0--12,30)); Expr (FunctionDef (SynSymbol hello-no-types, None, Args (List [Named (SynSymbol name, (16,20--16,24))], (16,19--16,25)), [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("hello %s", Regular, (17,13--17,23)), (17,13--17,23)); Symbol (SynSymbol name)], - (17,5--17,28))], (16,1--17,29)), (16,0--17,30)); + (17,5--17,28))], None, (16,1--17,29)), (16,0--17,30)); Expr (FunctionDef (SynSymbol hello-with-vector, None, @@ -22,7 +22,7 @@ [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("hello %s", Regular, (21,13--21,23)), (21,13--21,23)); Symbol (SynSymbol name)], - (21,5--21,28))], (20,1--21,29)), (20,0--21,30)); + (21,5--21,28))], None, (20,1--21,29)), (20,0--21,30)); Expr (LetOrUse (Named (SynSymbol anon, (24,5--24,9)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-11.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-11.structured output.verified.txt index 6f28a3e..6b80f31 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-11.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-11.structured output.verified.txt @@ -17,7 +17,7 @@ (SynSymbol hello, None, Args (List [], (12,14--12,16)), [FunctionCall (Symbol (SynSymbol printfn), - [Const (String ("hello world", Regular, (13,17--13,30)), (13,17--13,30))], (13,9--13,30))], + [Const (String ("hello world", Regular, (13,17--13,30)), (13,17--13,30))], (13,9--13,30))], None, (12,5--13,31)), (12,4--13,32)); Expr (FunctionCall (Symbol (SynSymbol hello), [], (15,5--15,10)), (15,4--15,11))], (10,1--15,11)); Expr diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-2.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-2.structured output.verified.txt index c8d501e..272d8ac 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-2.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_examples_example-2.structured output.verified.txt @@ -7,7 +7,7 @@ FunctionCall (Symbol (SynSymbol printfn), [Const (String ("hello %s", Regular, (13,13--13,23)), (13,13--13,23)); Symbol (SynSymbol name)], - (13,5--13,28))], (10,1--13,29)), (10,0--13,30)); + (13,5--13,28))], None, (10,1--13,29)), (10,0--13,30)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (15,0--15,15)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_for-to_for-to-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_for-to_for-to-0.structured output.verified.txt index 2b69b0b..0945615 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_for-to_for-to-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_for-to_for-to-0.structured output.verified.txt @@ -11,7 +11,7 @@ (10,5--10,21))], false, (9,3--10,22)); FunctionCall (Symbol (SynSymbol printfn), [Const (String ("", Regular, (11,11--11,13)), (11,11--11,13))], - (11,3--11,13))], (8,1--11,14)), (8,0--11,15)); + (11,3--11,13))], None, (8,1--11,14)), (8,0--11,15)); Expr (FunctionDef (SynSymbol func2, None, Args (List [], (13,10--13,12)), @@ -23,7 +23,7 @@ (15,5--15,21))], true, (14,3--15,22)); FunctionCall (Symbol (SynSymbol printfn), [Const (String ("", Regular, (16,11--16,13)), (16,11--16,13))], - (16,3--16,13))], (13,1--16,14)), (13,0--16,15)); + (16,3--16,13))], None, (13,1--16,14)), (13,0--16,15)); Expr (FunctionCall (Symbol (SynSymbol func1), [], (18,1--18,6)), (18,0--18,7)); Expr (FunctionCall (Symbol (SynSymbol func2), [], (19,1--19,6)), (19,0--19,7)); Expr @@ -35,7 +35,7 @@ (SynSymbol -, [Symbol (SynSymbol x); Op (Infix (SynSymbol *, [Const (Int32 2, (21,24--21,25)); Symbol (SynSymbol y)], (21,22--21,27)))], - (21,17--21,28)))], (21,1--21,29)), (21,0--21,30)); + (21,17--21,28)))], None, (21,1--21,29)), (21,0--21,30)); Expr (FunctionDef (SynSymbol end, None, @@ -45,7 +45,7 @@ (SynSymbol +, [Symbol (SynSymbol x); Op (Infix (SynSymbol *, [Const (Int32 2, (22,22--22,23)); Symbol (SynSymbol y)], (22,20--22,25)))], - (22,15--22,26)))], (22,1--22,27)), (22,0--22,28)); + (22,15--22,26)))], None, (22,1--22,27)), (22,0--22,28)); Expr (FunctionDef (SynSymbol func3, None, @@ -60,7 +60,7 @@ (26,5--26,21))], false, (25,3--26,22)); FunctionCall (Symbol (SynSymbol printfn), [Const (String ("", Regular, (27,11--27,13)), (27,11--27,13))], - (27,3--27,13))], (24,1--27,14)), (24,0--28,1)); + (27,3--27,13))], None, (24,1--27,14)), (24,0--28,1)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (30,0--30,12)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_functions_apply-method-args-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_functions_apply-method-args-0.structured output.verified.txt index 3ac70bc..ad20430 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_functions_apply-method-args-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_functions_apply-method-args-0.structured output.verified.txt @@ -35,7 +35,7 @@ [DotProperty (Symbol (SynSymbol p), SynSymbol X, (20,10--20,14)); FunctionCall (Symbol (SynSymbol dec), [DotProperty (Symbol (SynSymbol p), SynSymbol Y, (20,22--20,26))], - (20,17--20,27))], (20,3--20,28))], (19,1--20,29)), (19,0--20,30)); + (20,17--20,27))], (20,3--20,28))], None, (19,1--20,29)), (19,0--20,30)); Expr (Type (SynSymbol TileMap, @@ -245,7 +245,7 @@ FunctionCall (Symbol (SynSymbol printfn), [Const (String ("%A", Regular, (84,11--84,15)), (84,11--84,15)); Symbol (SynSymbol tm)], (84,3--84,18)); - Const (Unit, (86,2--86,4))], (72,1--86,4)), (72,0--86,5)); + Const (Unit, (86,2--86,4))], None, (72,1--86,4)), (72,0--86,5)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (88,0--88,14)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_functions_cons-concat-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_functions_cons-concat-0.structured output.verified.txt index d6dab92..19e4619 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_functions_cons-concat-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_functions_cons-concat-0.structured output.verified.txt @@ -13,7 +13,7 @@ (SynSymbol up!, [Symbol (SynSymbol up!); Symbol (SynSymbol lst); List (Paren, [Symbol (SynSymbol cons); Symbol (SynSymbol i)], (12,13--12,21))], (12,5--12,21)))], - false, (11,3--12,22)); Symbol (SynSymbol lst)], (8,1--14,5)), (8,0--14,6)); + false, (11,3--12,22)); Symbol (SynSymbol lst)], None, (8,1--14,5)), (8,0--14,6)); Expr (LetOrUse (Named (SynSymbol concat123, (16,5--16,14)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_if_if-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_if_if-0.structured output.verified.txt index d05fe61..083c993 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_if_if-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_if_if-0.structured output.verified.txt @@ -2,16 +2,16 @@ [AnonModule ([Expr (FunctionDef - (SynSymbol condition, None, Args (List [], (8,14--8,16)), [Const (Bool false, (8,17--8,22))], (8,1--8,22)), - (8,0--8,23)); + (SynSymbol condition, None, Args (List [], (8,14--8,16)), [Const (Bool false, (8,17--8,22))], None, + (8,1--8,22)), (8,0--8,23)); Expr (FunctionDef (SynSymbol then, None, Args (List [], (9,9--9,11)), - [Const (String ("then", Regular, (9,12--9,18)), (9,12--9,18))], (9,1--9,18)), (9,0--9,19)); + [Const (String ("then", Regular, (9,12--9,18)), (9,12--9,18))], None, (9,1--9,18)), (9,0--9,19)); Expr (FunctionDef (SynSymbol alt, None, Args (List [], (10,8--10,10)), - [Const (String ("alt", Regular, (10,11--10,16)), (10,11--10,16))], (10,1--10,16)), (10,0--10,17)); + [Const (String ("alt", Regular, (10,11--10,16)), (10,11--10,16))], None, (10,1--10,16)), (10,0--10,17)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (12,0--14,10)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_nested-macro-expansion-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_nested-macro-expansion-1.structured output.verified.txt index d8bd80e..e36743f 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_nested-macro-expansion-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_nested-macro-expansion-1.structured output.verified.txt @@ -24,14 +24,14 @@ (17,5--17,22)); DotMethod (Symbol (SynSymbol work), SynSymbol RemoveAt, [Const (Int32 0, (18,20--18,21))], Tuple, - (18,5--18,21)); Symbol (SynSymbol r)], (16,3--19,5)); + (18,5--18,21)); Symbol (SynSymbol r)], None, (16,3--19,5)); FunctionDef (SynSymbol EnqueueWork, None, Args (List [Named (SynSymbol bi, (21,19--21,21)); Named (SynSymbol offsetEnd, (21,22--21,31)); Named (SynSymbol nextPos, (21,32--21,39)); Named (SynSymbol count, (21,40--21,45))], - (21,18--21,46)), [Const (Unit, (22,4--22,6))], (21,3--22,6)); + (21,18--21,46)), [Const (Unit, (22,4--22,6))], None, (21,3--22,6)); LetOrUse (Named (SynSymbol result, (24,7--24,13)), Const (Int64 0L, (24,14--24,16)), Mutable, [], (24,3--24,16)); While @@ -198,8 +198,8 @@ List (Paren, [Symbol (SynSymbol inc); Symbol (SynSymbol bi)], (59,25--59,33)); Symbol (SynSymbol offsetEnd); Symbol (SynSymbol nextPossibleIndex); Symbol (SynSymbol count)], (59,12--59,68))], (54,10--60,11))], (38,9--60,11))); - Const (Unit, (62,8--62,10))], (28,7--62,10))], (27,5--63,7))], (26,3--63,8))], (9,1--64,5)), - (9,0--65,1)); + Const (Unit, (62,8--62,10))], (28,7--62,10))], (27,5--63,7))], (26,3--63,8))], None, + (9,1--64,5)), (9,0--65,1)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (67,0--67,14)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_syntax-macro-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_syntax-macro-0.structured output.verified.txt index 2d8950a..7c07f91 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_syntax-macro-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_syntax-macro-0.structured output.verified.txt @@ -44,7 +44,7 @@ [Op (Infix (SynSymbol +, [Symbol (SynSymbol a); Symbol (SynSymbol b)], (28,19--28,24)))], (28,5--28,25)); SynMatch (Discard (29,5--29,6), None, [Const (Int32 0, (29,7--29,8))], (29,5--29,8))], (27,3--29,9))], - (26,1--29,10)), (26,0--29,11)); + None, (26,1--29,10)), (26,0--29,11)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (31,0--33,23)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_up-macro-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_up-macro-0.structured output.verified.txt index 0ce3199..2fe2e79 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_up-macro-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_macros_up-macro-0.structured output.verified.txt @@ -13,7 +13,8 @@ (SynSymbol up!, [Symbol (SynSymbol up!); Symbol (SynSymbol items); List (Paren, [Symbol (SynSymbol Set.add); Symbol (SynSymbol i)], (12,15--12,26))], - (12,5--12,26)))], false, (11,3--12,27)); Symbol (SynSymbol items)], (8,1--14,7)), (8,0--14,8)); + (12,5--12,26)))], false, (11,3--12,27)); Symbol (SynSymbol items)], None, (8,1--14,7)), + (8,0--14,8)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (17,0--17,28)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_match-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_match-1.structured output.verified.txt index 0b10fb2..69e64dd 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_match-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_match-1.structured output.verified.txt @@ -9,7 +9,7 @@ [SynMatch (IsInst (Ident string, (10,5--10,16)), None, [Const (Bool true, (10,17--10,21))], (10,5--10,21)); SynMatch (Discard (11,5--11,6), None, [Const (Bool false, (11,7--11,12))], (11,5--11,12))], - (9,3--11,13))], (8,1--12,3)), (8,0--12,4)); + (9,3--11,13))], None, (8,1--12,3)), (8,0--12,4)); Expr (FunctionDef (SynSymbol AreEqualStrings, None, @@ -38,7 +38,7 @@ [Op (Infix (SynSymbol =, [Symbol (SynSymbol lhss); Symbol (SynSymbol rhss)], (17,7--17,18)))], (16,5--17,19)); SynMatch (Discard (19,5--19,6), None, [Const (Bool false, (19,7--19,12))], (19,5--19,12))], - (15,3--19,13))], (14,1--20,3)), (14,0--21,1)); + (15,3--19,13))], None, (14,1--20,3)), (14,0--21,1)); Expr (FunctionCall (Symbol (SynSymbol printfn), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_operators-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_operators-0.structured output.verified.txt index 003e4ad..f1f7ce9 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_operators-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_operators-0.structured output.verified.txt @@ -4,13 +4,13 @@ (FunctionDef (SynSymbol OrTest, None, Args (List [Named (SynSymbol a, (8,12--8,13)); Named (SynSymbol b, (8,14--8,15))], (8,11--8,16)), - [Op (Infix (SynSymbol ||, [Symbol (SynSymbol a); Symbol (SynSymbol b)], (8,17--8,24)))], (8,1--8,25)), + [Op (Infix (SynSymbol ||, [Symbol (SynSymbol a); Symbol (SynSymbol b)], (8,17--8,24)))], None, (8,1--8,25)), (8,0--8,26)); Expr (FunctionDef (SynSymbol AndTest, None, Args (List [Named (SynSymbol a, (9,13--9,14)); Named (SynSymbol b, (9,15--9,16))], (9,12--9,17)), - [Op (Infix (SynSymbol &&, [Symbol (SynSymbol a); Symbol (SynSymbol b)], (9,18--9,25)))], (9,1--9,26)), + [Op (Infix (SynSymbol &&, [Symbol (SynSymbol a); Symbol (SynSymbol b)], (9,18--9,25)))], None, (9,1--9,26)), (9,0--9,27)); Expr (FunctionCall diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_operators-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_operators-1.structured output.verified.txt index 6adfaaf..611e4b3 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_operators-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_operators-1.structured output.verified.txt @@ -6,11 +6,11 @@ (9,1--9,32)), (9,0--9,33)); Expr (FunctionDef - (SynSymbol dummyfn>>, None, Args (List [], (10,14--10,16)), [Const (Int32 99, (10,17--10,19))], + (SynSymbol dummyfn>>, None, Args (List [], (10,14--10,16)), [Const (Int32 99, (10,17--10,19))], None, (10,1--10,19)), (10,0--10,20)); Expr (FunctionDef - (SynSymbol <int32), [Symbol (SynSymbol span1)], (12,3--12,20))], (10,1--12,21)), - (10,0--13,1)); + FunctionCall (Symbol (SynSymbol span->int32), [Symbol (SynSymbol span1)], (12,3--12,20))], None, + (10,1--12,21)), (10,0--13,1)); Expr (FunctionCall (Symbol (SynSymbol printfn), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-0.structured output.verified.txt index 18436c6..cd43325 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-0.structured output.verified.txt @@ -34,7 +34,7 @@ let ``can parse %s`` = |> Async.AwaitTask ", TripleQuote, (22,25--26,5)), (22,25--26,5)); Symbol (SynSymbol path); Symbol (SynSymbol path)], (22,17--26,15)), None, [], - (22,3--26,16)); Symbol (SynSymbol template)], (21,1--28,10)), (21,0--28,11)); + (22,3--26,16)); Symbol (SynSymbol template)], None, (21,1--28,10)), (21,0--28,11)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (30,0--30,49)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-1.structured output.verified.txt index f1a1171..61a0046 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-1.structured output.verified.txt @@ -62,7 +62,7 @@ module %s ", TripleQuote, (25,16--34,5)), (25,16--34,5)); Symbol (SynSymbol moduleName); Symbol (SynSymbol moduleName)], (25,8--34,27)), - (25,7--34,28))], (25,3--34,28))], (24,1--35,5)), (24,0--35,6)); + (25,7--34,28))], (25,3--34,28))], None, (24,1--35,5)), (24,0--35,6)); Expr (LetOrUse (Named (SynSymbol lf, (37,5--37,7)), Symbol (SynSymbol System.Environment.NewLine), None, [], (37,1--37,34)), @@ -135,7 +135,7 @@ [Symbol (SynSymbol template); Symbol (SynSymbol lf); Symbol (SynSymbol template2); Symbol (SynSymbol lf); Symbol (SynSymbol template3); Symbol (SynSymbol lf); Symbol (SynSymbol template4); Symbol (SynSymbol lf)], (61,7--61,59)))], Do, (44,5--61,60))], - Do, (43,3--62,5))], (39,1--62,6)), (39,0--63,1)); + Do, (43,3--62,5))], None, (39,1--62,6)), (39,0--63,1)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (65,0--65,91)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-interpolation-2.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-interpolation-2.structured output.verified.txt new file mode 100644 index 0000000..0477107 --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-interpolation-2.structured output.verified.txt @@ -0,0 +1,23 @@ +ParsedFile + [AnonModule + ([Open (SynSymbol System, (7,1--7,12)); + Expr + (LetOrUse + (Named (SynSymbol dt, (9,5--9,7)), + New + (Ident DateTime, + [Const (Int32 2023, (9,22--9,26)); Const (Int32 12, (9,27--9,29)); Const (Int32 26, (9,30--9,32))], + (9,9--9,32)), None, [], (9,1--9,33)), (9,0--9,34)); + Expr + (LetOrUse + (Named (SynSymbol visp_result_todo, (11,0--11,58)), + FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("string is '%s'", Regular, (11,9--11,25)), (11,9--11,25)); + Const (String ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, (11,26--11,57)), (11,26--11,57))], + (11,1--11,57)), None, [], (11,0--11,58)), (11,0--11,58)); + Expr + (FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("%A", Regular, (11,0--11,58)), (11,0--11,58)); Symbol (SynSymbol visp_result_todo)], + (11,0--11,58)), (11,0--11,58))], (7,0--11,58))] \ No newline at end of file diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-interpolation-3.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-interpolation-3.structured output.verified.txt new file mode 100644 index 0000000..7df6aa0 --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_strings-interpolation-3.structured output.verified.txt @@ -0,0 +1,152 @@ +ParsedFile + [AnonModule + ([Open (SynSymbol System, (7,1--7,12)); Open (SynSymbol System.Text, (8,1--8,17)); + Open (SynSymbol System.IO, (9,1--9,15)); + Expr + (LetOrUse + (Named (SynSymbol dt, (11,5--11,7)), + New + (Ident DateTime, + [Const (Int32 2023, (11,22--11,26)); Const (Int32 12, (11,27--11,29)); Const (Int32 26, (11,30--11,32))], + (11,9--11,32)), None, [], (11,1--11,33)), (11,0--11,34)); + Expr + (FunctionDef + (SynSymbol FailwithButDoNotCall, None, Args (List [], (13,25--13,27)), + [FunctionCall + (Symbol (SynSymbol failwithf), + [Const (String ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, (14,13--14,44)), (14,13--14,44))], + (14,3--14,44))], None, (13,1--14,45)), (13,0--14,46)); + Expr + (FunctionDef + (SynSymbol printfn_test, None, Args (List [], (16,17--16,19)), + [FunctionCall + (Symbol (SynSymbol printfn), + [Const + (String ("printfn_test: Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, (17,11--17,56)), + (17,11--17,56))], (17,3--17,56))], None, (16,1--17,57)), (16,0--17,58)); + Expr + (FunctionDef + (SynSymbol printfn_multiline_test, None, Args (List [], (19,27--19,29)), + [FunctionDef + (SynSymbol SomeFunction, None, Args (List [], (20,19--20,21)), + [FunctionCall + (Symbol (SynSymbol printfn), + [Const + (String (" + printfn_multiline_test: start + Date is: {dt:``yyyy-MM-dd``} + printfn_multiline_test: end + ", InterpolatedTripleQuote 1, (21,13--25,7)), + (21,13--25,7))], (21,5--25,7))], None, (20,3--25,8)); + FunctionCall (Symbol (SynSymbol SomeFunction), [], (27,3--27,15))], None, (19,1--27,16)), (19,0--27,17)); + Expr + (FunctionDef + (SynSymbol bprintf_test, None, Args (List [], (29,17--29,19)), + [LetOrUse + (Named (SynSymbol buf, (30,7--30,10)), New (Ident StringBuilder, [], (30,12--30,29)), None, [], + (30,3--30,30)); + FunctionCall + (Symbol (SynSymbol Printf.bprintf), + [Symbol (SynSymbol buf); + Const (String ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, (31,22--31,53)), (31,22--31,53))], + (31,3--31,53)); + FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("bprintf_test: %s", Regular, (32,11--32,29)), (32,11--32,29)); + DotMethod (Symbol (SynSymbol buf), SynSymbol ToString, [], Tuple, (32,31--32,44))], (32,3--32,45))], + None, (29,1--32,46)), (29,0--32,47)); + Expr + (FunctionDef + (SynSymbol kbprintf_test, None, Args (List [], (34,18--34,20)), + [LetOrUse + (Named (SynSymbol buf, (35,7--35,10)), New (Ident StringBuilder, [], (35,12--35,29)), None, [], + (35,3--35,30)); + FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("kbprintf_test: %s", Regular, (36,11--36,30)), (36,11--36,30)); + FunctionCall + (Symbol (SynSymbol Printf.kbprintf), + [LambdaDef + (SynLambda + (Args (List [], (36,52--36,54)), + [DotMethod (Symbol (SynSymbol buf), SynSymbol ToString, [], Tuple, (36,56--36,69))], + (36,49--36,70))); Symbol (SynSymbol buf); + Const (String ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, (36,76--36,107)), (36,76--36,107))], + (36,32--36,107))], (36,3--36,108))], None, (34,1--36,109)), (34,0--36,110)); + Expr + (FunctionDef + (SynSymbol kfprintf_test, None, Args (List [], (38,18--38,20)), + [LetOrUse + (Named (SynSymbol sw, (39,7--39,9)), New (Ident StringWriter, [], (39,11--39,27)), None, [], + (39,3--39,28)); + FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("kfprintf_test: %s", Regular, (40,11--40,30)), (40,11--40,30)); + FunctionCall + (Symbol (SynSymbol Printf.kfprintf), + [LambdaDef + (SynLambda + (Args (List [], (40,52--40,54)), + [DotMethod (Symbol (SynSymbol sw), SynSymbol ToString, [], Tuple, (40,56--40,68))], + (40,49--40,69))); Symbol (SynSymbol sw); + Const (String ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, (40,74--40,105)), (40,74--40,105))], + (40,32--40,105))], (40,3--40,106))], None, (38,1--40,107)), (38,0--40,108)); + Expr + (FunctionDef + (SynSymbol fprintfn_test, None, Args (List [], (42,18--42,20)), + [LetOrUse + (Named (SynSymbol sw, (43,7--43,9)), New (Ident StringWriter, [], (43,11--43,27)), None, [], + (43,3--43,28)); + FunctionCall + (Symbol (SynSymbol fprintfn), + [Symbol (SynSymbol sw); + Const + (String (" + fprintfn_test: start + Date is: {dt:``yyyy-MM-dd``} + fprintfn_test: end + ", InterpolatedTripleQuote 1, (44,15--48,7)), + (44,15--48,7))], (44,3--48,7)); + FunctionCall + (Symbol (SynSymbol printf), + [Const (String ("fprintfn_test: %s", Regular, (49,10--49,29)), (49,10--49,29)); + DotMethod (Symbol (SynSymbol sw), SynSymbol ToString, [], Tuple, (49,31--49,43))], (49,3--49,44))], + None, (42,1--49,45)), (42,0--49,46)); + Expr + (FunctionDef + (SynSymbol sprintf_test, None, Args (List [], (51,17--51,19)), + [FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("sprintf_test: %s", Regular, (52,11--52,29)), (52,11--52,29)); + FunctionCall + (Symbol (SynSymbol sprintf), + [Const (String ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, (52,39--52,70)), (52,39--52,70))], + (52,31--52,70))], (52,3--52,71))], None, (51,1--52,72)), (51,0--52,73)); + Expr + (LetOrUse + (Named (SynSymbol tests, (54,5--54,10)), + Collection + (SynCollection + (FsArray, + [Symbol (SynSymbol printfn_test); Symbol (SynSymbol printfn_multiline_test); + Symbol (SynSymbol fprintfn_test); Symbol (SynSymbol bprintf_test); Symbol (SynSymbol kbprintf_test); + Symbol (SynSymbol kfprintf_test); Symbol (SynSymbol sprintf_test)], (54,11--61,16))), None, [], + (54,1--61,16)), (54,0--61,17)); + Expr + (Op + (Infix + (SynSymbol |>, + [Symbol (SynSymbol tests); + FunctionCall + (Symbol (SynSymbol Array.iter), + [LambdaShort (FunctionCall (Symbol (SynSymbol %1), [], (63,24--63,26)), (63,22--63,27))], + (63,11--63,27))], (63,0--63,28))), (63,0--63,29)); + Expr + (LetOrUse + (Named (SynSymbol visp_result_todo, (65,0--65,2)), Const (Unit, (65,0--65,2)), None, [], (65,0--65,2)), + (65,0--65,2)); + Expr + (FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("%A", Regular, (65,0--65,2)), (65,0--65,2)); Symbol (SynSymbol visp_result_todo)], + (65,0--65,2)), (65,0--65,2))], (7,0--65,2))] \ No newline at end of file diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_sym-with-arrow-in-macro-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_sym-with-arrow-in-macro-0.structured output.verified.txt index 2e7b512..9261bf0 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_sym-with-arrow-in-macro-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_parsing_sym-with-arrow-in-macro-0.structured output.verified.txt @@ -13,7 +13,7 @@ Expr (FunctionDef (SynSymbol something->nothing, Inline, Args (List [Named (SynSymbol i, (13,31--13,32))], (13,30--13,33)), - [Symbol (SynSymbol i)], (13,1--13,35)), (13,0--13,36)); + [Symbol (SynSymbol i)], None, (13,1--13,35)), (13,0--13,36)); Expr (FunctionDef (SynSymbol Test, Inline, Args (List [Named (SynSymbol i, (15,17--15,18))], (15,16--15,19)), @@ -22,7 +22,7 @@ (SynSymbol noop-macro-1, [Symbol (SynSymbol noop-macro-1); List (Paren, [Symbol (SynSymbol something->nothing); Symbol (SynSymbol i)], (16,16--16,38))], - (16,3--16,38)))], (15,1--16,39)), (15,0--16,40)); + (16,3--16,38)))], None, (15,1--16,39)), (15,0--16,40)); Expr (FunctionCall (Symbol (SynSymbol printfn), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_fn-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_fn-0.structured output.verified.txt index a585fd3..5533bbf 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_fn-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_fn-0.structured output.verified.txt @@ -6,7 +6,7 @@ [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("no-type %A", Regular, (8,25--8,37)), (8,25--8,37)); Symbol (SynSymbol s)], - (8,17--8,39))], (8,1--8,40)), (8,0--8,41)); + (8,17--8,39))], None, (8,1--8,40)), (8,0--8,41)); Expr (FunctionCall (Symbol (SynSymbol no-type), [Const (String ("hello", Regular, (9,9--9,16)), (9,9--9,16))], (9,1--9,16)), @@ -18,7 +18,7 @@ [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("with-type %A", Regular, (11,37--11,51)), (11,37--11,51)); Symbol (SynSymbol s)], - (11,29--11,53))], (11,1--11,54)), (11,0--11,55)); + (11,29--11,53))], None, (11,1--11,54)), (11,0--11,55)); Expr (FunctionCall (Symbol (SynSymbol with-type), [Const (String ("hello", Regular, (12,11--12,18)), (12,11--12,18))], @@ -37,7 +37,7 @@ FunctionCall (Symbol (SynSymbol printfn), [Const (String ("with-type-multiple %A", Regular, (16,11--16,34)), (16,11--16,34)); - Symbol (SynSymbol b)], (16,3--16,36))], (14,1--16,37)), (14,0--17,3)); + Symbol (SynSymbol b)], (16,3--16,36))], None, (14,1--16,37)), (14,0--17,3)); Expr (FunctionCall (Symbol (SynSymbol with-type-multiple), @@ -56,8 +56,8 @@ [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("with-tuple %A", Regular, (20,33--20,48)), (20,33--20,48)); - Tuple ([Symbol (SynSymbol x); Symbol (SynSymbol y)], (20,50--20,55))], (20,25--20,56))], (20,1--20,57)), - (20,0--20,58)); + Tuple ([Symbol (SynSymbol x); Symbol (SynSymbol y)], (20,50--20,55))], (20,25--20,56))], None, + (20,1--20,57)), (20,0--20,58)); Expr (FunctionCall (Symbol (SynSymbol with-tuple), @@ -79,8 +79,8 @@ [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("with-tuple-type %A", Regular, (23,51--23,71)), (23,51--23,71)); - Tuple ([Symbol (SynSymbol x); Symbol (SynSymbol y)], (23,73--23,78))], (23,43--23,79))], (23,1--23,80)), - (23,0--23,81)); + Tuple ([Symbol (SynSymbol x); Symbol (SynSymbol y)], (23,73--23,78))], (23,43--23,79))], None, + (23,1--23,80)), (23,0--23,81)); Expr (FunctionCall (Symbol (SynSymbol with-tuple-type), @@ -114,7 +114,7 @@ FunctionCall (Symbol (SynSymbol printfn), [Const (String ("with-tuple-multiple %A", Regular, (28,11--28,35)), (28,11--28,35)); - Tuple ([Symbol (SynSymbol x2); Symbol (SynSymbol y2)], (28,37--28,44))], (28,3--28,45))], + Tuple ([Symbol (SynSymbol x2); Symbol (SynSymbol y2)], (28,37--28,44))], (28,3--28,45))], None, (26,1--28,46)), (26,0--29,3)); Expr (FunctionCall diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_fn-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_fn-1.structured output.verified.txt index ddb9cee..2b3bf5b 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_fn-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_fn-1.structured output.verified.txt @@ -9,7 +9,8 @@ (Named (SynSymbol pred, (8,15--8,19)), Paren (Fun (Ident ^T, Ident bool, (8,22--8,32)), (8,21--8,33)), (8,14--8,34)); Named (SynSymbol t, (8,35--8,36))], (8,13--8,37)), - [FunctionCall (Symbol (SynSymbol pred), [Symbol (SynSymbol t)], (9,3--9,9))], (8,1--9,10)), (8,0--9,11)); + [FunctionCall (Symbol (SynSymbol pred), [Symbol (SynSymbol t)], (9,3--9,9))], None, (8,1--9,10)), + (8,0--9,11)); Expr (FunctionCall (Symbol (SynSymbol printfn), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_record-pat-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_record-pat-0.structured output.verified.txt index de44805..75127f5 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_record-pat-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_pats_record-pat-0.structured output.verified.txt @@ -38,7 +38,7 @@ (Symbol (SynSymbol printfn), [Const (String ("dir %A", Regular, (17,11--17,19)), (17,11--17,19)); Tuple ([Symbol (SynSymbol dx); Symbol (SynSymbol dy); Symbol (SynSymbol dz)], (17,21--17,31))], - (17,3--17,32))], (15,1--17,33)), (15,0--18,1)); + (17,3--17,32))], None, (15,1--17,33)), (15,0--18,1)); Expr (FunctionDef (SynSymbol DoStuffWithDirOnly, None, @@ -57,7 +57,7 @@ (Symbol (SynSymbol printfn), [Const (String ("dir %A", Regular, (21,11--21,19)), (21,11--21,19)); Tuple ([Symbol (SynSymbol dx); Symbol (SynSymbol dy); Symbol (SynSymbol dz)], (21,21--21,31))], - (21,3--21,32))], (20,1--21,33)), (20,0--22,1)); + (21,3--21,32))], None, (20,1--21,33)), (20,0--22,1)); Expr (FunctionDef (SynSymbol MatchRecord, None, Args (List [Named (SynSymbol ray, (24,17--24,20))], (24,16--24,21)), @@ -79,7 +79,7 @@ FunctionCall (Symbol (SynSymbol printfn), [Const (String ("dy %A", Regular, (28,15--28,22)), (28,15--28,22)); Symbol (SynSymbol dy)], - (28,7--28,25))], (26,5--28,26))], (25,3--29,5))], (24,1--30,3)), (24,0--31,1)); + (28,7--28,25))], (26,5--28,26))], (25,3--29,5))], None, (24,1--30,3)), (24,0--31,1)); Expr (FunctionDef (SynSymbol LetRecord, None, Args (List [Named (SynSymbol ray, (33,15--33,18))], (33,14--33,19)), @@ -89,7 +89,7 @@ FunctionCall (Symbol (SynSymbol printfn), [Const (String ("dir is %A", Regular, (35,11--35,22)), (35,11--35,22)); Symbol (SynSymbol dd)], - (35,3--35,25))], (33,1--35,26)), (33,0--35,27)); + (35,3--35,25))], None, (33,1--35,26)), (33,0--35,27)); Expr (FunctionCall (Symbol (SynSymbol DoStuffWithRay), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_byrefs-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_byrefs-0.structured output.verified.txt new file mode 100644 index 0000000..cb9d3a0 --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_byrefs-0.structured output.verified.txt @@ -0,0 +1,135 @@ +ParsedFile + [AnonModule + ([Open (SynSymbol System, (9,1--9,12)); + Expr + (Type + (SynSymbol C1, Args (Tuple [], (11,9--11,11)), + [Let + (Named (SynSymbol nums, (12,7--12,11)), + Collection + (SynCollection + (FsArray, + [Const (Int32 1, (12,15--12,16)); Const (Int32 3, (12,17--12,18)); + Const (Int32 7, (12,19--12,20)); Const (Int32 15, (12,21--12,23)); + Const (Int32 31, (12,24--12,26)); Const (Int32 63, (12,27--12,29)); + Const (Int32 127, (12,30--12,33)); Const (Int32 255, (12,34--12,37)); + Const (Int32 511, (12,38--12,41)); Const (Int32 1023, (12,42--12,46))], (12,12--12,49))), + Mutable, [], (12,3--12,49)); + MemberFn + (SynSymbol _.ToString, Args (List [], (13,26--13,28)), + [DotMethod + (Symbol (SynSymbol System.String), SynSymbol Join, + [Const (Char ' ', (13,50--13,57)); Symbol (SynSymbol nums)], Tuple, (13,30--13,62))], Override, [], + (13,3--13,63)); + MemberFn + (SynSymbol _.FindLargestSmallerThan, + Args (List [Named (SynSymbol target, (15,39--15,45))], (15,38--15,46)), + [LetOrUse + (Named (SynSymbol ctr, (16,9--16,12)), + FunctionCall + (Symbol (SynSymbol dec), + [DotProperty (Symbol (SynSymbol nums), SynSymbol Length, (16,19--16,31))], (16,14--16,32)), + Mutable, [], (16,5--16,33)); + While + (Op + (Infix + (SynSymbol &&, + [Op + (Infix + (SynSymbol >, [Symbol (SynSymbol ctr); Const (Int32 0, (18,22--18,23))], (18,16--18,23))); + Op + (Infix + (SynSymbol >=, + [DotIndex (Symbol (SynSymbol nums), [Symbol (SynSymbol ctr)], (18,30--18,41)); + Symbol (SynSymbol target)], (18,26--18,49)))], (18,11--18,50))), + [SyntaxMacroCall + (SynMacroCall + (SynSymbol up!, [Symbol (SynSymbol up!); Symbol (SynSymbol ctr); Symbol (SynSymbol dec)], + (19,7--19,18)))], (18,5--19,19)); + If + (Op (Infix (SynSymbol >, [Symbol (SynSymbol ctr); Const (Int32 0, (21,15--21,16))], (21,9--21,16))), + DotIndex (Symbol (SynSymbol &nums), [Symbol (SynSymbol ctr)], (22,7--22,19)), + Some (DotIndex (Symbol (SynSymbol &nums), [Const (Int32 0, (23,9--23,10))], (23,7--23,17))), + (21,5--23,18))], Default, [], (15,3--24,5))], [], (11,1--24,6)), (11,0--24,7)); + Expr + (FunctionDef + (SynSymbol C1Test, None, Args (List [], (26,11--26,13)), + [LetOrUse + (Named (SynSymbol c1, (27,7--27,9)), FunctionCall (Symbol (SynSymbol C1), [], (27,11--27,13)), None, [], + (27,3--27,14)); + FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("Original sequence: %O{c1}", Interpolated 1, (28,11--28,39)), (28,11--28,39))], + (28,3--28,39)); + LetOrUse + (Named (SynSymbol v, (29,7--29,8)), + DotMethod + (Symbol (SynSymbol &c1), SynSymbol FindLargestSmallerThan, [Const (Int32 16, (29,38--29,40))], Tuple, + (29,10--29,40)), None, [], (29,3--29,41)); + Set + (Symbol (SynSymbol v), + Op (Infix (SynSymbol *, [Symbol (SynSymbol v); Const (Int32 2, (30,15--30,16))], (30,11--30,16))), + (30,3--30,17)); + FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("New sequence: %O{c1}", Interpolated 1, (31,11--31,39)), (31,11--31,39))], + (31,3--31,39))], None, (26,1--31,40)), (26,0--31,41)); + Expr (FunctionCall (Symbol (SynSymbol C1Test), [], (33,1--33,7)), (33,0--33,8)); + Expr + (FunctionDef + (SynSymbol f_inref, None, + Args + (List + [Typed + (Named (SynSymbol dt, (35,14--35,16)), Generic (Ident inref, [Ident DateTime], (35,18--35,33)), + (35,13--35,34))], (35,12--35,35)), + [FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("Now: {dt:``yyyy-MM-dd``}", Interpolated 1, (36,11--36,38)), (36,11--36,38))], + (36,3--36,38))], None, (35,1--36,39)), (35,0--36,40)); + Expr + (FunctionDef + (SynSymbol f_byref, None, + Args + (List + [Typed + (Named (SynSymbol dt, (38,14--38,16)), Generic (Ident byref, [Ident DateTime], (38,18--38,33)), + (38,13--38,34))], (38,12--38,35)), + [FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("Now: {dt:``yyyy-MM-dd``}", Interpolated 1, (39,11--39,38)), (39,11--39,38))], + (39,3--39,38)); + Set + (Symbol (SynSymbol dt), + DotMethod + (Symbol (SynSymbol dt), SynSymbol AddDays, [Const (Int32 1, (40,24--40,25))], Tuple, (40,12--40,25)), + (40,3--40,26))], None, (38,1--40,27)), (38,0--40,28)); + Expr + (FunctionDef + (SynSymbol UsingByrefs, None, Args (List [], (42,16--42,18)), + [LetOrUse + (Named (SynSymbol dt, (43,7--43,9)), + New + (Ident DateTime, + [Const (Int32 2023, (43,24--43,28)); Const (Int32 12, (43,29--43,31)); + Const (Int32 26, (43,32--43,34))], (43,11--43,34)), None, [], (43,3--43,35)); + FunctionCall (Symbol (SynSymbol f_inref), [Symbol (SynSymbol &dt)], (44,3--44,14)); + LetOrUse + (Named (SynSymbol dt, (46,7--46,9)), + New + (Ident DateTime, + [Const (Int32 2023, (46,24--46,28)); Const (Int32 12, (46,29--46,31)); + Const (Int32 26, (46,32--46,34))], (46,11--46,34)), Mutable, [], (46,3--46,35)); + FunctionCall (Symbol (SynSymbol f_byref), [Symbol (SynSymbol &dt)], (47,3--47,14)); + FunctionCall (Symbol (SynSymbol f_inref), [Symbol (SynSymbol &dt)], (48,3--48,14)); + Const (Unit, (50,2--50,4))], None, (42,1--50,4)), (42,0--50,5)); + Expr (FunctionCall (Symbol (SynSymbol UsingByrefs), [], (52,1--52,12)), (52,0--52,13)); + Expr + (LetOrUse + (Named (SynSymbol visp_result_todo, (54,0--54,2)), Const (Unit, (54,0--54,2)), None, [], (54,0--54,2)), + (54,0--54,2)); + Expr + (FunctionCall + (Symbol (SynSymbol printfn), + [Const (String ("%A", Regular, (54,0--54,2)), (54,0--54,2)); Symbol (SynSymbol visp_result_todo)], + (54,0--54,2)), (54,0--54,2))], (9,0--54,2))] \ No newline at end of file diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_lambda-shorthand-record-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_lambda-shorthand-record-0.structured output.verified.txt index 5e4ff07..503bc30 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_lambda-shorthand-record-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_lambda-shorthand-record-0.structured output.verified.txt @@ -13,7 +13,7 @@ [Named (SynSymbol lhs, (12,17--12,20)); Named (SynSymbol rhs, (12,21--12,24)); Named (SynSymbol mkRecord, (12,25--12,33))], (12,16--12,34)), [FunctionCall - (Symbol (SynSymbol mkRecord), [Symbol (SynSymbol lhs); Symbol (SynSymbol rhs)], (13,3--13,19))], + (Symbol (SynSymbol mkRecord), [Symbol (SynSymbol lhs); Symbol (SynSymbol rhs)], (13,3--13,19))], None, (12,1--13,20)), (12,0--13,21)); Expr (LetOrUse diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_object-exprs-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_object-exprs-0.structured output.verified.txt index 6a3e449..14582b3 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_object-exprs-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_object-exprs-0.structured output.verified.txt @@ -46,7 +46,7 @@ (SynSymbol +, [Symbol (SynSymbol delim1); Symbol (SynSymbol value); Symbol (SynSymbol delim2)], (22,9--22,30))), Some (Symbol (SynSymbol value)), (21,7--23,13))], Default, [], - (20,5--24,7))], (19,3--24,8))], (18,1--24,9)), (18,0--24,10)); + (20,5--24,7))], (19,3--24,8))], None, (18,1--24,9)), (18,0--24,10)); Expr (LetOrUse (Named (SynSymbol obj2, (26,5--26,9)), @@ -79,7 +79,7 @@ [FunctionCall (Symbol (SynSymbol printfn), [Const (String ("Disposing %s", Regular, (34,15--34,29)), (34,15--34,29)); - Symbol (SynSymbol name)], (34,7--34,34))], Default, [], (33,5--34,35))], (32,3--34,36))], + Symbol (SynSymbol name)], (34,7--34,34))], Default, [], (33,5--34,35))], (32,3--34,36))], None, (30,1--34,37)), (30,0--34,38)); Expr (FunctionDef @@ -96,7 +96,7 @@ FunctionCall (Symbol (SynSymbol makeDisposable), [Const (String ("do-scope", Regular, (39,27--39,37)), (39,27--39,37))], (39,12--39,37)), Use, [], - (39,5--39,38)); Const (Unit, (40,4--40,6))], Do, (38,3--40,6)); Const (Unit, (41,2--41,4))], + (39,5--39,38)); Const (Unit, (40,4--40,6))], Do, (38,3--40,6)); Const (Unit, (41,2--41,4))], None, (36,1--41,4)), (36,0--41,5)); Expr (FunctionCall (Symbol (SynSymbol DisposeExample), [], (43,1--43,15)), (43,0--43,16)); Expr diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_record-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_record-1.structured output.verified.txt index bfc388c..0889eca 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_record-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_record-1.structured output.verified.txt @@ -30,7 +30,7 @@ (21,18--21,33)), [Tuple ([FunctionCall (Symbol (SynSymbol dec), [Symbol (SynSymbol x)], (21,36--21,41)); Symbol (SynSymbol y)], - (21,35--21,45))], (21,1--21,46)), (21,0--21,47)); + (21,35--21,45))], None, (21,1--21,46)), (21,0--21,47)); Expr (FunctionDef (SynSymbol RightOf, Inline, @@ -45,7 +45,7 @@ (22,19--22,34)), [Tuple ([FunctionCall (Symbol (SynSymbol inc), [Symbol (SynSymbol x)], (22,37--22,42)); Symbol (SynSymbol y)], - (22,36--22,46))], (22,1--22,47)), (22,0--22,48)); + (22,36--22,46))], None, (22,1--22,47)), (22,0--22,48)); Expr (FunctionDef (SynSymbol UpOf, Inline, @@ -60,7 +60,7 @@ (23,16--23,31)), [Tuple ([Symbol (SynSymbol x); FunctionCall (Symbol (SynSymbol dec), [Symbol (SynSymbol y)], (23,37--23,42))], - (23,33--23,43))], (23,1--23,44)), (23,0--23,45)); + (23,33--23,43))], None, (23,1--23,44)), (23,0--23,45)); Expr (FunctionDef (SynSymbol DownOf, Inline, @@ -75,7 +75,7 @@ (24,18--24,33)), [Tuple ([Symbol (SynSymbol x); FunctionCall (Symbol (SynSymbol inc), [Symbol (SynSymbol y)], (24,39--24,44))], - (24,35--24,45))], (24,1--24,46)), (24,0--24,47)); + (24,35--24,45))], None, (24,1--24,46)), (24,0--24,47)); Expr (FunctionDef (SynSymbol GetDirFun, Inline, @@ -86,7 +86,7 @@ SynMatch (Named (SynSymbol Down, (29,5--29,9)), None, [Symbol (SynSymbol DownOf)], (29,5--29,16)); SynMatch (Named (SynSymbol Left, (30,5--30,9)), None, [Symbol (SynSymbol LeftOf)], (30,5--30,16)); SynMatch (Named (SynSymbol Right, (31,5--31,10)), None, [Symbol (SynSymbol RightOf)], (31,5--31,18))], - (27,3--31,19))], (26,1--32,3)), (26,0--32,4)); + (27,3--31,19))], None, (26,1--32,3)), (26,0--32,4)); Expr (FunctionDef (SynSymbol MoveNode, None, @@ -111,7 +111,7 @@ FunctionCall (Symbol (SynSymbol inc), [DotProperty (Symbol (SynSymbol v), SynSymbol steps, (38,37--38,45))], (38,32--38,46)), Some (Const (Int32 1, (38,48--38,49))), (38,11--38,49)), (38,4--38,50))], - (35,2--39,4))], (34,1--39,4)), (34,0--40,1)); + (35,2--39,4))], None, (34,1--39,4)), (34,0--40,1)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (42,0--42,14)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_record-3.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_record-3.structured output.verified.txt index b7a3ca2..aad1f8f 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_record-3.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_record-3.structured output.verified.txt @@ -29,7 +29,7 @@ SyntaxMacroCall (SynMacroCall (SynSymbol up!, [Symbol (SynSymbol up!); Symbol (SynSymbol counter); Symbol (SynSymbol inc)], - (18,5--18,20)))], (16,3--18,21)); Symbol (SynSymbol value)], (11,1--21,7)), (11,0--22,1)); + (18,5--18,20)))], (16,3--18,21)); Symbol (SynSymbol value)], None, (11,1--21,7)), (11,0--22,1)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (24,0--24,40)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_type-alias-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_type-alias-0.structured output.verified.txt index 45803f3..79c7c8e 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_type-alias-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_type_type-alias-0.structured output.verified.txt @@ -15,7 +15,7 @@ (SynSymbol +, [FunctionCall (Symbol (SynSymbol fst), [Symbol (SynSymbol r)], (11,6--11,11)); FunctionCall (Symbol (SynSymbol snd), [Symbol (SynSymbol r)], (11,14--11,19))], (11,3--11,20)))], - (10,1--11,21)), (10,0--11,22)); + None, (10,1--11,21)), (10,0--11,22)); Expr (LetOrUse (Named (SynSymbol visp_result_todo, (13,0--13,41)), diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_while_while-0.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_while_while-0.structured output.verified.txt index 139f4b7..637235a 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_while_while-0.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_while_while-0.structured output.verified.txt @@ -12,7 +12,7 @@ (SynSymbol +, [Const (Int64 1L, (12,19--12,21)); FunctionCall (Symbol (SynSymbol unwrapInt), [Symbol (SynSymbol v)], (12,23--12,34))], - (12,17--12,35)))], (12,5--12,36))], (11,1--12,37)), (11,0--12,38)); + (12,17--12,35)))], (12,5--12,36))], None, (11,1--12,37)), (11,0--12,38)); Expr (LetOrUse (Named (SynSymbol count, (14,5--14,10)), Atom (Const (Int64 0L, (14,17--14,19)), (14,12--14,19)), None, [], diff --git a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_while_while-1.structured output.verified.txt b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_while_while-1.structured output.verified.txt index 2705618..b106608 100644 --- a/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_while_while-1.structured output.verified.txt +++ b/tests/Visp.Compiler.UnitTests/parsing-snapshots/tests_while_while-1.structured output.verified.txt @@ -60,7 +60,7 @@ (Symbol (SynSymbol index), FunctionCall (Symbol (SynSymbol inc), [Symbol (SynSymbol index)], (23,17--23,26)), (23,5--23,27))], (13,3--23,28)); - Op (Infix (SynSymbol =, [Symbol (SynSymbol diff); Const (Int32 1, (26,10--26,11))], (26,3--26,11)))], + Op (Infix (SynSymbol =, [Symbol (SynSymbol diff); Const (Int32 1, (26,10--26,11))], (26,3--26,11)))], None, (8,1--26,12)), (8,0--26,13)); Expr (LetOrUse diff --git a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-0.can parse.verified.txt b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-0.can parse.verified.txt index 9312597..e8c0193 100644 --- a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-0.can parse.verified.txt +++ b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-0.can parse.verified.txt @@ -7,35 +7,35 @@ open Visp.Runtime.Library let state = { Todo = () } // line 9 @"strings-0.visp" [] -let ``LiftedString1_strings-0`` = " +let ``LiftedString0_strings-0`` = " this is a multiline string " // line 15 @"strings-0.visp" [] -let ``LiftedString3_strings-0`` = """ +let ``LiftedString1_strings-0`` = """ this is a multiline string """ // line 22 @"strings-0.visp" [] -let ``LiftedString4_strings-0`` = """ +let ``LiftedString2_strings-0`` = """ let ``can parse %s`` = TestUtils.runTest %s |> Async.AwaitTask """ // line 9 @"strings-0.visp" -printfn "string is: '%s'" ``LiftedString1_strings-0`` +printfn "string is: '%s'" ``LiftedString0_strings-0`` // line 15 @"strings-0.visp" -printfn "string is: '%s'" ``LiftedString3_strings-0`` +printfn "string is: '%s'" ``LiftedString1_strings-0`` // line 21 @"strings-0.visp" let ``generate-test`` path = // line 22 @"strings-0.visp" let template = // line 22 @"strings-0.visp" - sprintf ``LiftedString4_strings-0`` path path + sprintf ``LiftedString2_strings-0`` path path template // line 30 @"strings-0.visp" diff --git a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-1.can parse.verified.txt b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-1.can parse.verified.txt index e12b219..40868fd 100644 --- a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-1.can parse.verified.txt +++ b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-1.can parse.verified.txt @@ -7,17 +7,17 @@ open Visp.Runtime.Library let state = { Todo = () } // line 13 @"strings-1.visp" [] -let ``LiftedString7_strings-1`` = """ +let ``LiftedString0_strings-1`` = """ multiple lines are okay? """ // line 19 @"strings-1.visp" [] -let ``LiftedString9_strings-1`` = """ +let ``LiftedString1_strings-1`` = """ multiple lines are okay? """ // line 25 @"strings-1.visp" [] -let ``LiftedString10_strings-1`` = """ +let ``LiftedString2_strings-1`` = """ // AUTO GENERATED // DO NOT MODIFY BY HAND @@ -29,26 +29,26 @@ module %s """ // line 45 @"strings-1.visp" [] -let ``LiftedString15_strings-1`` = """ +let ``LiftedString3_strings-1`` = """ [] let ``%s %s`` () = TestUtils.runTest "%s" """ // line 49 @"strings-1.visp" -let inline ``LiftedString16_strings-1`` prefix testname path = +let inline ``LiftedString4_strings-1`` prefix testname path = $""" [] let ``interpolated {prefix} {testname}`` () = TestUtils.runTest "{path}" """ // line 53 @"strings-1.visp" -let inline ``LiftedString17_strings-1`` prefix testname path = +let inline ``LiftedString5_strings-1`` prefix testname path = $$""" [] let ``interpolated {{prefix}} {{testname}}`` () = TestUtils.runTest "{{path}} {path}" """ // line 57 @"strings-1.visp" -let inline ``LiftedString18_strings-1`` prefix testname exprArg0 exprArg1 = +let inline ``LiftedString6_strings-1`` prefix testname exprArg0 exprArg1 = $$""" [] let ``interpolated {{prefix}} {{testname}}`` () = TestUtils.runTest "{{exprArg0}} {{exprArg1}} {(+ 1 2 3)}" @@ -63,7 +63,7 @@ printfn "string is '%s'" """r:\rt:\tn:\na:\a""" // line 12 @"strings-1.visp" printfn "string is '%s'" """r:\rt:\tn:\na:\a""" // line 13 @"strings-1.visp" -printfn "string is '%s'" ``LiftedString7_strings-1`` +printfn "string is '%s'" ``LiftedString0_strings-1`` // line 16 @"strings-1.visp" ( // line 17 @"strings-1.visp" @@ -71,11 +71,11 @@ printfn "string is '%s'" ``LiftedString7_strings-1`` // line 18 @"strings-1.visp" ( // line 19 @"strings-1.visp" - printfn "string is '%s'" ``LiftedString9_strings-1``))) + printfn "string is '%s'" ``LiftedString1_strings-1``))) // line 24 @"strings-1.visp" let genTestHeader moduleName = // line 25 @"strings-1.visp" - sprintf ``LiftedString10_strings-1`` moduleName moduleName + sprintf ``LiftedString2_strings-1`` moduleName moduleName // line 37 @"strings-1.visp" let lf = System.Environment.NewLine @@ -99,19 +99,19 @@ let genTestTemplate (prefix: string) (path: string) = // line 45 @"strings-1.visp" let template = // line 45 @"strings-1.visp" - sprintf ``LiftedString15_strings-1`` prefix testname path + sprintf ``LiftedString3_strings-1`` prefix testname path // line 49 @"strings-1.visp" let template2 = // line 49 @"strings-1.visp" - ``LiftedString16_strings-1`` prefix testname path + ``LiftedString4_strings-1`` prefix testname path // line 53 @"strings-1.visp" let template3 = // line 53 @"strings-1.visp" - ``LiftedString17_strings-1`` prefix testname path + ``LiftedString5_strings-1`` prefix testname path // line 57 @"strings-1.visp" let template4 = // line 57 @"strings-1.visp" - ``LiftedString18_strings-1`` prefix testname (1 + 2 + 3) (1 + 2 + 3) + ``LiftedString6_strings-1`` prefix testname (1 + 2 + 3) (1 + 2 + 3) // line 61 @"strings-1.visp" (template + lf + template2 + lf + template3 + lf + template4 + lf))) diff --git a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-0.can parse.verified.txt b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-0.can parse.verified.txt index 22cab34..03efeea 100644 --- a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-0.can parse.verified.txt +++ b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-0.can parse.verified.txt @@ -6,33 +6,33 @@ open Visp.Runtime.Library let state = { Todo = () } // line 10 @"strings-interpolation-0.visp" -let inline ``LiftedString2_strings-interpolation-0`` value exprArg0 = +let inline ``LiftedString0_strings-interpolation-0`` value exprArg0 = $"interpolated: {value} {exprArg0}" // line 11 @"strings-interpolation-0.visp" -let inline ``LiftedString4_strings-interpolation-0`` value exprArg0 = +let inline ``LiftedString1_strings-interpolation-0`` value exprArg0 = $"""interpolated: {value} {exprArg0}""" // line 12 @"strings-interpolation-0.visp" -let inline ``LiftedString6_strings-interpolation-0`` value exprArg0 = +let inline ``LiftedString2_strings-interpolation-0`` value exprArg0 = $$"""interpolated: {value} {{ value }} {{exprArg0}}""" // line 13 @"strings-interpolation-0.visp" -let inline ``LiftedString8_strings-interpolation-0`` value exprArg0 = +let inline ``LiftedString3_strings-interpolation-0`` value exprArg0 = $$$"""interpolated: {value} {{ value }} {{{ value }}} {{{exprArg0}}}""" // line 8 @"strings-interpolation-0.visp" let value = "hello world" // line 10 @"strings-interpolation-0.visp" -printfn "string is '%s'" (``LiftedString2_strings-interpolation-0`` value value.Length) +printfn "string is '%s'" (``LiftedString0_strings-interpolation-0`` value value.Length) // line 11 @"strings-interpolation-0.visp" -printfn "string is '%s'" (``LiftedString4_strings-interpolation-0`` value value.Length) +printfn "string is '%s'" (``LiftedString1_strings-interpolation-0`` value value.Length) // line 12 @"strings-interpolation-0.visp" -printfn "string is '%s'" (``LiftedString6_strings-interpolation-0`` value value.Length) +printfn "string is '%s'" (``LiftedString2_strings-interpolation-0`` value value.Length) // line 13 @"strings-interpolation-0.visp" let visp_result_todo = // line 13 @"strings-interpolation-0.visp" - printfn "string is '%s'" (``LiftedString8_strings-interpolation-0`` value value.Length) + printfn "string is '%s'" (``LiftedString3_strings-interpolation-0`` value value.Length) // line 13 @"strings-interpolation-0.visp" printfn "%A" visp_result_todo diff --git a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-1.can parse.verified.txt b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-1.can parse.verified.txt index 495ec26..812da10 100644 --- a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-1.can parse.verified.txt +++ b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-1.can parse.verified.txt @@ -6,7 +6,7 @@ open Visp.Runtime.Library let state = { Todo = () } // line 10 @"strings-interpolation-1.visp" -let inline ``LiftedString2_strings-interpolation-1`` value = +let inline ``LiftedString0_strings-interpolation-1`` value = $"interpolated: {value} {value} {value}" // line 8 @"strings-interpolation-1.visp" @@ -14,7 +14,7 @@ let value = "hello world" // line 10 @"strings-interpolation-1.visp" let visp_result_todo = // line 10 @"strings-interpolation-1.visp" - printfn "string is '%s'" (``LiftedString2_strings-interpolation-1`` value) + printfn "string is '%s'" (``LiftedString0_strings-interpolation-1`` value) // line 10 @"strings-interpolation-1.visp" printfn "%A" visp_result_todo diff --git a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-2.can parse.verified.txt b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-2.can parse.verified.txt new file mode 100644 index 0000000..b9ca2bf --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-2.can parse.verified.txt @@ -0,0 +1,25 @@ +// This file is auto-generated + +#nowarn "0020" // unused results from functions + +open Visp.Runtime.Library + +let state = { Todo = () } +// line 11 @"strings-interpolation-2.visp" +let inline ``LiftedString0_strings-interpolation-2`` dt = + $"Date is: {dt:``yyyy-MM-dd``}" + +// line 7 @"strings-interpolation-2.visp" +open System + +// line 9 @"strings-interpolation-2.visp" +let dt = + // line 9 @"strings-interpolation-2.visp" + (new DateTime(2023, 12, 26)) +// line 11 @"strings-interpolation-2.visp" +let visp_result_todo = + // line 11 @"strings-interpolation-2.visp" + printfn "string is '%s'" (``LiftedString0_strings-interpolation-2`` dt) +// line 11 @"strings-interpolation-2.visp" +printfn "%A" visp_result_todo + diff --git a/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-3.can parse.verified.txt b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-3.can parse.verified.txt new file mode 100644 index 0000000..691db7f --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/snapshots/tests_parsing_strings-interpolation-3.can parse.verified.txt @@ -0,0 +1,142 @@ +// This file is auto-generated + +#nowarn "0020" // unused results from functions + +open Visp.Runtime.Library + +let state = { Todo = () } +// line 14 @"strings-interpolation-3.visp" +let inline ``LiftedString0_strings-interpolation-3`` dt : Printf.StringFormat<_, _> = + $"Date is: {dt:``yyyy-MM-dd``}" + +// line 17 @"strings-interpolation-3.visp" +let inline ``LiftedString1_strings-interpolation-3`` dt : Printf.TextWriterFormat<_> = + $"printfn_test: Date is: {dt:``yyyy-MM-dd``}" + +// line 21 @"strings-interpolation-3.visp" +let inline ``LiftedString2_strings-interpolation-3`` dt : Printf.TextWriterFormat<_> = + $""" + printfn_multiline_test: start + Date is: {dt:``yyyy-MM-dd``} + printfn_multiline_test: end +""" + +// line 31 @"strings-interpolation-3.visp" +let inline ``LiftedString3_strings-interpolation-3`` dt : Printf.BuilderFormat<_> = + $"Date is: {dt:``yyyy-MM-dd``}" + +// line 36 @"strings-interpolation-3.visp" +let inline ``LiftedString4_strings-interpolation-3`` dt : Printf.BuilderFormat<_, _> = + $"Date is: {dt:``yyyy-MM-dd``}" + +// line 40 @"strings-interpolation-3.visp" +let inline ``LiftedString5_strings-interpolation-3`` dt : Printf.TextWriterFormat<_, _> = + $"Date is: {dt:``yyyy-MM-dd``}" + +// line 44 @"strings-interpolation-3.visp" +let inline ``LiftedString6_strings-interpolation-3`` dt : Printf.TextWriterFormat<_> = + $""" + fprintfn_test: start + Date is: {dt:``yyyy-MM-dd``} + fprintfn_test: end +""" + +// line 52 @"strings-interpolation-3.visp" +let inline ``LiftedString7_strings-interpolation-3`` dt : Printf.StringFormat<_> = + $"Date is: {dt:``yyyy-MM-dd``}" + +// line 7 @"strings-interpolation-3.visp" +open System + +// line 8 @"strings-interpolation-3.visp" +open System.Text + +// line 9 @"strings-interpolation-3.visp" +open System.IO + +// line 11 @"strings-interpolation-3.visp" +let dt = + // line 11 @"strings-interpolation-3.visp" + (new DateTime(2023, 12, 26)) +// line 13 @"strings-interpolation-3.visp" +let FailwithButDoNotCall () = + // line 14 @"strings-interpolation-3.visp" + failwithf (``LiftedString0_strings-interpolation-3`` dt) + +// line 16 @"strings-interpolation-3.visp" +let printfn_test () = + // line 17 @"strings-interpolation-3.visp" + printfn (``LiftedString1_strings-interpolation-3`` dt) + +// line 19 @"strings-interpolation-3.visp" +let printfn_multiline_test () = + // line 20 @"strings-interpolation-3.visp" + let SomeFunction () = + // line 21 @"strings-interpolation-3.visp" + printfn (``LiftedString2_strings-interpolation-3`` dt) + + // line 27 @"strings-interpolation-3.visp" + SomeFunction () + +// line 29 @"strings-interpolation-3.visp" +let bprintf_test () = + // line 30 @"strings-interpolation-3.visp" + let buf = + // line 30 @"strings-interpolation-3.visp" + (new StringBuilder()) + // line 31 @"strings-interpolation-3.visp" + Printf.bprintf buf (``LiftedString3_strings-interpolation-3`` dt) + // line 32 @"strings-interpolation-3.visp" + printfn "bprintf_test: %s" ((buf.ToString())) + +// line 34 @"strings-interpolation-3.visp" +let kbprintf_test () = + // line 35 @"strings-interpolation-3.visp" + let buf = + // line 35 @"strings-interpolation-3.visp" + (new StringBuilder()) + // line 36 @"strings-interpolation-3.visp" + printfn "kbprintf_test: %s" (Printf.kbprintf ((fun () -> + // line 36 @"strings-interpolation-3.visp" + buf.ToString())) buf (``LiftedString4_strings-interpolation-3`` dt)) + +// line 38 @"strings-interpolation-3.visp" +let kfprintf_test () = + // line 39 @"strings-interpolation-3.visp" + let sw = + // line 39 @"strings-interpolation-3.visp" + (new StringWriter()) + // line 40 @"strings-interpolation-3.visp" + printfn "kfprintf_test: %s" (Printf.kfprintf ((fun () -> + // line 40 @"strings-interpolation-3.visp" + sw.ToString())) sw (``LiftedString5_strings-interpolation-3`` dt)) + +// line 42 @"strings-interpolation-3.visp" +let fprintfn_test () = + // line 43 @"strings-interpolation-3.visp" + let sw = + // line 43 @"strings-interpolation-3.visp" + (new StringWriter()) + // line 44 @"strings-interpolation-3.visp" + fprintfn sw (``LiftedString6_strings-interpolation-3`` dt) + // line 49 @"strings-interpolation-3.visp" + printf "fprintfn_test: %s" ((sw.ToString())) + +// line 51 @"strings-interpolation-3.visp" +let sprintf_test () = + // line 52 @"strings-interpolation-3.visp" + printfn "sprintf_test: %s" (sprintf (``LiftedString7_strings-interpolation-3`` dt)) + +// line 54 @"strings-interpolation-3.visp" +let tests = + // line 54 @"strings-interpolation-3.visp" + [|printfn_test;printfn_multiline_test;fprintfn_test;bprintf_test;kbprintf_test;kfprintf_test;sprintf_test|] +// line 63 @"strings-interpolation-3.visp" +(tests |> (Array.iter ((fun arg1 -> + // line 63 @"strings-interpolation-3.visp" + arg1 ())))) +// line 65 @"strings-interpolation-3.visp" +let visp_result_todo = () +// line 65 @"strings-interpolation-3.visp" +printfn "%A" visp_result_todo + diff --git a/tests/Visp.Compiler.UnitTests/snapshots/tests_type_byrefs-0.can parse.verified.txt b/tests/Visp.Compiler.UnitTests/snapshots/tests_type_byrefs-0.can parse.verified.txt new file mode 100644 index 0000000..31ae2a4 --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/snapshots/tests_type_byrefs-0.can parse.verified.txt @@ -0,0 +1,113 @@ +// This file is auto-generated + +#nowarn "0020" // unused results from functions + +open Visp.Runtime.Library + +let state = { Todo = () } +// line 28 @"byrefs-0.visp" +let inline ``LiftedString0_byrefs-0`` c1 : Printf.TextWriterFormat<_> = + $"Original sequence: %O{c1}" + +// line 31 @"byrefs-0.visp" +let inline ``LiftedString1_byrefs-0`` c1 : Printf.TextWriterFormat<_> = + $"New sequence: %O{c1}" + +// line 36 @"byrefs-0.visp" +let inline ``LiftedString2_byrefs-0`` dt : Printf.TextWriterFormat<_> = + $"Now: {dt:``yyyy-MM-dd``}" + +// line 39 @"byrefs-0.visp" +let inline ``LiftedString3_byrefs-0`` dt : Printf.TextWriterFormat<_> = + $"Now: {dt:``yyyy-MM-dd``}" + +// line 9 @"byrefs-0.visp" +open System + +// line 11 @"byrefs-0.visp" +type C1 () = + // line 12 @"byrefs-0.visp" + let mutable nums = + // line 12 @"byrefs-0.visp" + [|1;3;7;15;31;63;127;255;511;1023|] + // line 13 @"byrefs-0.visp" + override _.ToString () = + // line 13 @"byrefs-0.visp" + System.String.Join(' ', nums) + // line 15 @"byrefs-0.visp" + member _.FindLargestSmallerThan target = + // line 16 @"byrefs-0.visp" + let mutable ctr = + // line 16 @"byrefs-0.visp" + dec ((nums.Length)) + // line 18 @"byrefs-0.visp" + while CoreMethods.isTruthy(((ctr > 0) && ((nums.[ctr]) >= target))) do + // line 19 @"byrefs-0.visp" + + // line 19 @"byrefs-0.visp" + ctr <- dec ctr + // line 21 @"byrefs-0.visp" + if CoreMethods.isTruthy( + (ctr > 0)) + then + // line 22 @"byrefs-0.visp" + (&nums.[ctr]) + else + // line 23 @"byrefs-0.visp" + (&nums.[0]) +// line 26 @"byrefs-0.visp" +let C1Test () = + // line 27 @"byrefs-0.visp" + let c1 = + // line 27 @"byrefs-0.visp" + C1 () + // line 28 @"byrefs-0.visp" + printfn (``LiftedString0_byrefs-0`` c1) + // line 29 @"byrefs-0.visp" + let v = + // line 29 @"byrefs-0.visp" + &c1.FindLargestSmallerThan(16) + // line 30 @"byrefs-0.visp" + v <- (v * 2) + // line 31 @"byrefs-0.visp" + printfn (``LiftedString1_byrefs-0`` c1) + +// line 33 @"byrefs-0.visp" +C1Test () +// line 35 @"byrefs-0.visp" +let f_inref (dt: inref) = + // line 36 @"byrefs-0.visp" + printfn (``LiftedString2_byrefs-0`` dt) + +// line 38 @"byrefs-0.visp" +let f_byref (dt: byref) = + // line 39 @"byrefs-0.visp" + printfn (``LiftedString3_byrefs-0`` dt) + // line 40 @"byrefs-0.visp" + dt <- (dt.AddDays(1)) + +// line 42 @"byrefs-0.visp" +let UsingByrefs () = + // line 43 @"byrefs-0.visp" + let dt = + // line 43 @"byrefs-0.visp" + (new DateTime(2023, 12, 26)) + // line 44 @"byrefs-0.visp" + f_inref &dt + // line 46 @"byrefs-0.visp" + let mutable dt = + // line 46 @"byrefs-0.visp" + (new DateTime(2023, 12, 26)) + // line 47 @"byrefs-0.visp" + f_byref &dt + // line 48 @"byrefs-0.visp" + f_inref &dt + () + +// line 52 @"byrefs-0.visp" +UsingByrefs () +// line 54 @"byrefs-0.visp" +let visp_result_todo = () +// line 54 @"byrefs-0.visp" +printfn "%A" visp_result_todo + diff --git a/tests/Visp.Compiler.UnitTests/snapshots/tests_type_object-exprs-0.can parse.verified.txt b/tests/Visp.Compiler.UnitTests/snapshots/tests_type_object-exprs-0.can parse.verified.txt index de30e4b..a4839d6 100644 --- a/tests/Visp.Compiler.UnitTests/snapshots/tests_type_object-exprs-0.can parse.verified.txt +++ b/tests/Visp.Compiler.UnitTests/snapshots/tests_type_object-exprs-0.can parse.verified.txt @@ -6,7 +6,7 @@ open Visp.Runtime.Library let state = { Todo = () } // line 16 @"object-exprs-0.visp" -let inline ``LiftedString2_object-exprs-0`` obj1 = +let inline ``LiftedString0_object-exprs-0`` obj1 = $"{obj1}" // line 13 @"object-exprs-0.visp" @@ -18,7 +18,7 @@ let obj1 = member _.ToString () = "visp-fs"} // line 16 @"object-exprs-0.visp" -printfn "%s" (``LiftedString2_object-exprs-0`` obj1) +printfn "%s" (``LiftedString0_object-exprs-0`` obj1) // line 18 @"object-exprs-0.visp" let delimiter delim1 delim2 value = // line 19 @"object-exprs-0.visp" diff --git a/tests/Visp.Compiler.UnitTests/token-snapshots/tests_parsing_strings-interpolation-2.returns tokens.verified.txt b/tests/Visp.Compiler.UnitTests/token-snapshots/tests_parsing_strings-interpolation-2.returns tokens.verified.txt new file mode 100644 index 0000000..ea40722 --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/token-snapshots/tests_parsing_strings-interpolation-2.returns tokens.verified.txt @@ -0,0 +1,21 @@ +LPAREN Default 0 1 LParen +OPEN Default 0 1 LParen +SYMBOL "System" Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +LET Default 0 1 LParen +SYMBOL "dt" Default 0 1 LParen +LPAREN Default 0 2 LParen +NEW Default 0 2 LParen +SYMBOL "DateTime" Default 0 2 LParen +INT32 (2023, false) Default 0 2 LParen +INT32 (12, false) Default 0 2 LParen +INT32 (26, false) Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +SYMBOL "printfn" Default 0 1 LParen +STRING ("string is '%s'", Regular, Token []) Default 0 1 LParen +STRING ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 1 LParen +RPAREN Default 0 0 Default +EOF Default 0 0 Default \ No newline at end of file diff --git a/tests/Visp.Compiler.UnitTests/token-snapshots/tests_parsing_strings-interpolation-3.returns tokens.verified.txt b/tests/Visp.Compiler.UnitTests/token-snapshots/tests_parsing_strings-interpolation-3.returns tokens.verified.txt new file mode 100644 index 0000000..2aa77de --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/token-snapshots/tests_parsing_strings-interpolation-3.returns tokens.verified.txt @@ -0,0 +1,228 @@ +LPAREN Default 0 1 LParen +OPEN Default 0 1 LParen +SYMBOL "System" Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +OPEN Default 0 1 LParen +SYMBOL "System.Text" Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +OPEN Default 0 1 LParen +SYMBOL "System.IO" Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +LET Default 0 1 LParen +SYMBOL "dt" Default 0 1 LParen +LPAREN Default 0 2 LParen +NEW Default 0 2 LParen +SYMBOL "DateTime" Default 0 2 LParen +INT32 (2023, false) Default 0 2 LParen +INT32 (12, false) Default 0 2 LParen +INT32 (26, false) Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "FailwithButDoNotCall" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "failwithf" Default 0 2 LParen +STRING ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "printfn_test" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("printfn_test: Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "printfn_multiline_test" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +FN Default 0 2 LParen +SYMBOL "SomeFunction" Default 0 2 LParen +LPAREN Default 0 3 LParen +RPAREN Default 0 2 LParen +LPAREN Default 0 3 LParen +SYMBOL "printfn" Default 0 3 LParen +STRING (" + printfn_multiline_test: start + Date is: {dt:``yyyy-MM-dd``} + printfn_multiline_test: end + ", InterpolatedTripleQuote 1, Token []) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "SomeFunction" Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "bprintf_test" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +LET Default 0 2 LParen +SYMBOL "buf" Default 0 2 LParen +LPAREN Default 0 3 LParen +NEW Default 0 3 LParen +SYMBOL "StringBuilder" Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "Printf.bprintf" Default 0 2 LParen +SYMBOL "buf" Default 0 2 LParen +STRING ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("bprintf_test: %s", Regular, Token []) Default 0 2 LParen +LPAREN Default 0 3 LParen +DOT_METHOD ".ToString" Default 0 3 LParen +SYMBOL "buf" Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "kbprintf_test" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +LET Default 0 2 LParen +SYMBOL "buf" Default 0 2 LParen +LPAREN Default 0 3 LParen +NEW Default 0 3 LParen +SYMBOL "StringBuilder" Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("kbprintf_test: %s", Regular, Token []) Default 0 2 LParen +LPAREN Default 0 3 LParen +SYMBOL "Printf.kbprintf" Default 0 3 LParen +LPAREN Default 0 4 LParen +FN Default 0 4 LParen +LPAREN Default 0 5 LParen +RPAREN Default 0 4 LParen +LPAREN Default 0 5 LParen +DOT_METHOD ".ToString" Default 0 5 LParen +SYMBOL "buf" Default 0 5 LParen +RPAREN Default 0 4 LParen +RPAREN Default 0 3 LParen +SYMBOL "buf" Default 0 3 LParen +STRING ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "kfprintf_test" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +LET Default 0 2 LParen +SYMBOL "sw" Default 0 2 LParen +LPAREN Default 0 3 LParen +NEW Default 0 3 LParen +SYMBOL "StringWriter" Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("kfprintf_test: %s", Regular, Token []) Default 0 2 LParen +LPAREN Default 0 3 LParen +SYMBOL "Printf.kfprintf" Default 0 3 LParen +LPAREN Default 0 4 LParen +FN Default 0 4 LParen +LPAREN Default 0 5 LParen +RPAREN Default 0 4 LParen +LPAREN Default 0 5 LParen +DOT_METHOD ".ToString" Default 0 5 LParen +SYMBOL "sw" Default 0 5 LParen +RPAREN Default 0 4 LParen +RPAREN Default 0 3 LParen +SYMBOL "sw" Default 0 3 LParen +STRING ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "fprintfn_test" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +LET Default 0 2 LParen +SYMBOL "sw" Default 0 2 LParen +LPAREN Default 0 3 LParen +NEW Default 0 3 LParen +SYMBOL "StringWriter" Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "fprintfn" Default 0 2 LParen +SYMBOL "sw" Default 0 2 LParen +STRING (" + fprintfn_test: start + Date is: {dt:``yyyy-MM-dd``} + fprintfn_test: end + ", InterpolatedTripleQuote 1, Token []) Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printf" Default 0 2 LParen +STRING ("fprintfn_test: %s", Regular, Token []) Default 0 2 LParen +LPAREN Default 0 3 LParen +DOT_METHOD ".ToString" Default 0 3 LParen +SYMBOL "sw" Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "sprintf_test" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("sprintf_test: %s", Regular, Token []) Default 0 2 LParen +LPAREN Default 0 3 LParen +SYMBOL "sprintf" Default 0 3 LParen +STRING ("Date is: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +LET Default 0 1 LParen +SYMBOL "tests" Default 0 1 LParen +BRACKET_BAR Default 0 1 LParen +SYMBOL "printfn_test" Default 0 1 LParen +SYMBOL "printfn_multiline_test" Default 0 1 LParen +SYMBOL "fprintfn_test" Default 0 1 LParen +SYMBOL "bprintf_test" Default 0 1 LParen +SYMBOL "kbprintf_test" Default 0 1 LParen +SYMBOL "kfprintf_test" Default 0 1 LParen +SYMBOL "sprintf_test" Default 0 1 LParen +BAR_BRACKET Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +INFIX_OP "|>" Default 0 1 LParen +SYMBOL "tests" Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "Array.iter" Default 0 2 LParen +HASH_PAREN Default 0 3 LParen +SYMBOL "%1" Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +EOF Default 0 0 Default \ No newline at end of file diff --git a/tests/Visp.Compiler.UnitTests/token-snapshots/tests_type_byrefs-0.returns tokens.verified.txt b/tests/Visp.Compiler.UnitTests/token-snapshots/tests_type_byrefs-0.returns tokens.verified.txt new file mode 100644 index 0000000..7fc1292 --- /dev/null +++ b/tests/Visp.Compiler.UnitTests/token-snapshots/tests_type_byrefs-0.returns tokens.verified.txt @@ -0,0 +1,239 @@ +LPAREN Default 0 1 LParen +OPEN Default 0 1 LParen +SYMBOL "System" Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +TYPE Default 0 1 Type +SYMBOL "C1" Default 0 1 Type +LPAREN Default 0 2 Type +RPAREN Default 0 1 Type +LPAREN Default 0 2 Type +MUT Default 0 2 Type +SYMBOL "nums" Default 0 2 Type +BRACKET_BAR Default 0 2 Type +INT32 (1, false) Default 0 2 Type +INT32 (3, false) Default 0 2 Type +INT32 (7, false) Default 0 2 Type +INT32 (15, false) Default 0 2 Type +INT32 (31, false) Default 0 2 Type +INT32 (63, false) Default 0 2 Type +INT32 (127, false) Default 0 2 Type +INT32 (255, false) Default 0 2 Type +INT32 (511, false) Default 0 2 Type +INT32 (1023, false) Default 0 2 Type +BAR_BRACKET Default 0 2 Type +RPAREN Default 0 1 Type +LPAREN Default 0 2 Type +OVERRIDE Default 0 2 Type +FN Default 0 2 Type +SYMBOL "_.ToString" Default 0 2 Type +LPAREN Default 0 3 Type +RPAREN Default 0 2 Type +LPAREN Default 0 3 Type +DOT_METHOD ".Join" Default 0 3 Type +SYMBOL "System.String" Default 0 3 Type +CHAR "#\space" Default 0 3 Type +SYMBOL "nums" Default 0 3 Type +RPAREN Default 0 2 Type +RPAREN Default 0 1 Type +LPAREN Default 0 2 Type +MEMBER Default 0 2 Member +FN Default 0 2 Member +SYMBOL "_.FindLargestSmallerThan" Default 0 2 Member +LPAREN Default 0 3 Member +SYMBOL "target" Default 0 3 Member +RPAREN Default 0 2 Member +LPAREN Default 0 3 Member +MUT Default 0 3 Member +SYMBOL "ctr" Default 0 3 Member +LPAREN Default 0 4 Member +SYMBOL "dec" Default 0 4 Member +LPAREN Default 0 5 Member +PROP_PLUS "+Length" Default 0 5 Member +SYMBOL "nums" Default 0 5 Member +RPAREN Default 0 4 Member +RPAREN Default 0 3 Member +RPAREN Default 0 2 Member +LPAREN Default 0 3 Member +WHILE Default 0 3 Member +LPAREN Default 0 4 Member +INFIX_OP "&&" Default 0 4 Member +LPAREN Default 0 5 Member +OP_GREATER Default 0 5 Member +SYMBOL "ctr" Default 0 5 Member +INT32 (0, false) Default 0 5 Member +RPAREN Default 0 4 Member +LPAREN Default 0 5 Member +GREATER_EQUALS Default 0 5 Member +LPAREN Default 0 6 Member +DOT_BRACKET Default 0 6 Member +SYMBOL "ctr" Default 0 6 Member +RBRACKET Default 0 6 Member +SYMBOL "nums" Default 0 6 Member +RPAREN Default 0 5 Member +SYMBOL "target" Default 0 5 Member +RPAREN Default 0 4 Member +RPAREN Default 0 3 Member +LPAREN Default 0 4 Member +MACRO_NAME "up!" TokenStream Macro 1 4 Member +SYMBOL "ctr" TokenStream Macro 1 4 Member +SYMBOL "dec" TokenStream Macro 1 4 Member +RPAREN Default 0 3 Member +RPAREN Default 0 2 Member +LPAREN Default 0 3 Member +IF_KW Default 0 3 Member +LPAREN Default 0 4 Member +OP_GREATER Default 0 4 Member +SYMBOL "ctr" Default 0 4 Member +INT32 (0, false) Default 0 4 Member +RPAREN Default 0 3 Member +LPAREN Default 0 4 Member +DOT_BRACKET Default 0 4 Member +SYMBOL "ctr" Default 0 4 Member +RBRACKET Default 0 4 Member +SYMBOL "&nums" Default 0 4 Member +RPAREN Default 0 3 Member +LPAREN Default 0 4 Member +DOT_BRACKET Default 0 4 Member +INT32 (0, false) Default 0 4 Member +RBRACKET Default 0 4 Member +SYMBOL "&nums" Default 0 4 Member +RPAREN Default 0 3 Member +RPAREN Default 0 2 Member +RPAREN Default 0 1 Type +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "C1Test" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +LET Default 0 2 LParen +SYMBOL "c1" Default 0 2 LParen +LPAREN Default 0 3 LParen +SYMBOL "C1" Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("Original sequence: %O{c1}", Interpolated 1, Token []) Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +LET Default 0 2 LParen +SYMBOL "v" Default 0 2 LParen +LPAREN Default 0 3 LParen +DOT_METHOD ".FindLargestSmallerThan" Default 0 3 LParen +SYMBOL "&c1" Default 0 3 LParen +INT32 (16, false) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SET Default 0 2 LParen +SYMBOL "v" Default 0 2 LParen +LPAREN Default 0 3 LParen +OP_MULT Default 0 3 LParen +SYMBOL "v" Default 0 3 LParen +INT32 (2, false) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("New sequence: %O{c1}", Interpolated 1, Token []) Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +SYMBOL "C1Test" Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "f_inref" Default 0 1 LParen +LPAREN Default 0 2 LParen +LBRACKET Default 0 2 LParen +SYMBOL "dt" Default 0 2 LParen +COLON Default 0 2 LParen +SYMBOL "inref" Default 0 2 LParen +OP_LESS Default 0 2 LParen +SYMBOL "DateTime" Default 0 2 LParen +OP_GREATER Default 0 2 LParen +RBRACKET Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("Now: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "f_byref" Default 0 1 LParen +LPAREN Default 0 2 LParen +LBRACKET Default 0 2 LParen +SYMBOL "dt" Default 0 2 LParen +COLON Default 0 2 LParen +SYMBOL "byref" Default 0 2 LParen +OP_LESS Default 0 2 LParen +SYMBOL "DateTime" Default 0 2 LParen +OP_GREATER Default 0 2 LParen +RBRACKET Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "printfn" Default 0 2 LParen +STRING ("Now: {dt:``yyyy-MM-dd``}", Interpolated 1, Token []) Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SET Default 0 2 LParen +SYMBOL "dt" Default 0 2 LParen +LPAREN Default 0 3 LParen +DOT_METHOD ".AddDays" Default 0 3 LParen +SYMBOL "dt" Default 0 3 LParen +INT32 (1, false) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +FN Default 0 1 LParen +SYMBOL "UsingByrefs" Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +LET Default 0 2 LParen +SYMBOL "dt" Default 0 2 LParen +LPAREN Default 0 3 LParen +NEW Default 0 3 LParen +SYMBOL "DateTime" Default 0 3 LParen +INT32 (2023, false) Default 0 3 LParen +INT32 (12, false) Default 0 3 LParen +INT32 (26, false) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "f_inref" Default 0 2 LParen +SYMBOL "&dt" Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +MUT Default 0 2 LParen +SYMBOL "dt" Default 0 2 LParen +LPAREN Default 0 3 LParen +NEW Default 0 3 LParen +SYMBOL "DateTime" Default 0 3 LParen +INT32 (2023, false) Default 0 3 LParen +INT32 (12, false) Default 0 3 LParen +INT32 (26, false) Default 0 3 LParen +RPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "f_byref" Default 0 2 LParen +SYMBOL "&dt" Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +SYMBOL "f_inref" Default 0 2 LParen +SYMBOL "&dt" Default 0 2 LParen +RPAREN Default 0 1 LParen +LPAREN Default 0 2 LParen +RPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +SYMBOL "UsingByrefs" Default 0 1 LParen +RPAREN Default 0 0 Default +LPAREN Default 0 1 LParen +RPAREN Default 0 0 Default +EOF Default 0 0 Default \ No newline at end of file diff --git a/tests/Visp.ExecutionTests/ExecutionTests.generated.fs b/tests/Visp.ExecutionTests/ExecutionTests.generated.fs index 996cf08..d04c643 100644 --- a/tests/Visp.ExecutionTests/ExecutionTests.generated.fs +++ b/tests/Visp.ExecutionTests/ExecutionTests.generated.fs @@ -65,6 +65,11 @@ module ``tests_type_custom-comparison-0`` = [] let ``can execute`` () = TestUtils.runTest "tests/type/custom-comparison-0.visp" +[] +module ``tests_type_byrefs-0`` = + [] + let ``can execute`` () = TestUtils.runTest "tests/type/byrefs-0.visp" + [] module ``tests_type_static-members-0`` = [] @@ -155,6 +160,11 @@ module ``tests_parsing_match-0`` = [] let ``can execute`` () = TestUtils.runTest "tests/parsing/match-0.visp" +[] +module ``tests_parsing_strings-interpolation-3`` = + [] + let ``can execute`` () = TestUtils.runTest "tests/parsing/strings-interpolation-3.visp" + [] module ``tests_parsing_sym-with-arrow-in-macro-0`` = [] @@ -230,6 +240,11 @@ module ``tests_parsing_tupled-special-forms-0`` = [] let ``can execute`` () = TestUtils.runTest "tests/parsing/tupled-special-forms-0.visp" +[] +module ``tests_parsing_strings-interpolation-2`` = + [] + let ``can execute`` () = TestUtils.runTest "tests/parsing/strings-interpolation-2.visp" + [] module ``tests_parsing_operators-1`` = [] diff --git a/tests/Visp.ExecutionTests/snapshots/tests_parsing_strings-interpolation-2.can execute.verified.txt b/tests/Visp.ExecutionTests/snapshots/tests_parsing_strings-interpolation-2.can execute.verified.txt new file mode 100644 index 0000000..c033250 --- /dev/null +++ b/tests/Visp.ExecutionTests/snapshots/tests_parsing_strings-interpolation-2.can execute.verified.txt @@ -0,0 +1,4 @@ +string is 'Date is: 2023-12-26' +() + +ExitCode: 0 diff --git a/tests/Visp.ExecutionTests/snapshots/tests_parsing_strings-interpolation-3.can execute.verified.txt b/tests/Visp.ExecutionTests/snapshots/tests_parsing_strings-interpolation-3.can execute.verified.txt new file mode 100644 index 0000000..769c481 --- /dev/null +++ b/tests/Visp.ExecutionTests/snapshots/tests_parsing_strings-interpolation-3.can execute.verified.txt @@ -0,0 +1,18 @@ +printfn_test: Date is: 2023-12-26 + + printfn_multiline_test: start + Date is: 2023-12-26 + printfn_multiline_test: end + +fprintfn_test: + fprintfn_test: start + Date is: 2023-12-26 + fprintfn_test: end + +bprintf_test: Date is: 2023-12-26 +kbprintf_test: Date is: 2023-12-26 +kfprintf_test: Date is: 2023-12-26 +sprintf_test: Date is: 2023-12-26 +() + +ExitCode: 0 diff --git a/tests/Visp.ExecutionTests/snapshots/tests_type_byrefs-0.can execute.verified.txt b/tests/Visp.ExecutionTests/snapshots/tests_type_byrefs-0.can execute.verified.txt new file mode 100644 index 0000000..c335a3f --- /dev/null +++ b/tests/Visp.ExecutionTests/snapshots/tests_type_byrefs-0.can execute.verified.txt @@ -0,0 +1,8 @@ +Original sequence: 1 3 7 15 31 63 127 255 511 1023 +New sequence: 1 3 7 30 31 63 127 255 511 1023 +Now: 2023-12-26 +Now: 2023-12-26 +Now: 2023-12-27 +() + +ExitCode: 0 diff --git a/visp/tests/parsing/strings-interpolation-2.visp b/visp/tests/parsing/strings-interpolation-2.visp new file mode 100644 index 0000000..034d5ef --- /dev/null +++ b/visp/tests/parsing/strings-interpolation-2.visp @@ -0,0 +1,11 @@ +;; Copyright 2023 Ville Penttinen +;; Distributed under the MIT License. +;; https://github.com/vipentti/visp-fs/blob/main/LICENSE.md +;; +;; for basic syntax highlighting +;; vim: set syntax=clojure: +(open System) + +(let dt (new DateTime 2023 12 26)) + +(printfn "string is '%s'" $"Date is: {dt:``yyyy-MM-dd``}") diff --git a/visp/tests/parsing/strings-interpolation-3.visp b/visp/tests/parsing/strings-interpolation-3.visp new file mode 100644 index 0000000..dba8cda --- /dev/null +++ b/visp/tests/parsing/strings-interpolation-3.visp @@ -0,0 +1,69 @@ +;; Copyright 2023 Ville Penttinen +;; Distributed under the MIT License. +;; https://github.com/vipentti/visp-fs/blob/main/LICENSE.md +;; +;; for basic syntax highlighting +;; vim: set syntax=clojure: +(open System) +(open System.Text) +(open System.IO) + +(let dt (new DateTime 2023 12 26)) + +(fn FailwithButDoNotCall () + (failwithf $"Date is: {dt:``yyyy-MM-dd``}")) + +(fn printfn_test () + (printfn $"printfn_test: Date is: {dt:``yyyy-MM-dd``}")) + +(fn printfn_multiline_test () + (fn SomeFunction () + (printfn $""" + printfn_multiline_test: start + Date is: {dt:``yyyy-MM-dd``} + printfn_multiline_test: end + """)) + + (SomeFunction)) + +(fn bprintf_test () + (let buf (new StringBuilder)) + (Printf.bprintf buf $"Date is: {dt:``yyyy-MM-dd``}") + (printfn "bprintf_test: %s" (.ToString buf))) + +(fn kbprintf_test () + (let buf (new StringBuilder)) + (printfn "kbprintf_test: %s" (Printf.kbprintf (fn () (.ToString buf)) buf $"Date is: {dt:``yyyy-MM-dd``}"))) + +(fn kfprintf_test () + (let sw (new StringWriter)) + (printfn "kfprintf_test: %s" (Printf.kfprintf (fn () (.ToString sw)) sw $"Date is: {dt:``yyyy-MM-dd``}"))) + +(fn fprintfn_test () + (let sw (new StringWriter)) + (fprintfn sw $""" + fprintfn_test: start + Date is: {dt:``yyyy-MM-dd``} + fprintfn_test: end + """) + (printf "fprintfn_test: %s" (.ToString sw))) + +(fn sprintf_test () + (printfn "sprintf_test: %s" (sprintf $"Date is: {dt:``yyyy-MM-dd``}"))) + +(let tests [| + printfn_test + printfn_multiline_test + fprintfn_test + bprintf_test + kbprintf_test + kfprintf_test + sprintf_test|]) + +(|> tests (Array.iter #(%1))) + +() +;; (bprintf_test) +;; (kbprintf_test) +;; (kfprintf_test) + diff --git a/visp/tests/type/byrefs-0.visp b/visp/tests/type/byrefs-0.visp new file mode 100644 index 0000000..0e7703d --- /dev/null +++ b/visp/tests/type/byrefs-0.visp @@ -0,0 +1,54 @@ +;; Copyright 2023 Ville Penttinen +;; Distributed under the MIT License. +;; https://github.com/vipentti/visp-fs/blob/main/LICENSE.md +;; +;; for basic syntax highlighting +;; vim: set syntax=clojure: + +;; https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/byrefs +(open System) + +(type C1 () + (mut nums [| 1 3 7 15 31 63 127 255 511 1023 |]) + (override fn _.ToString () (.Join System.String #\space nums)) + + (member fn _.FindLargestSmallerThan (target) + (mut ctr (dec (+Length nums))) + + (while (&& (> ctr 0) (>= (.[ctr] nums) target)) + (up! ctr dec)) + + (if (> ctr 0) + (.[ctr] &nums) + (.[0] &nums) + ))) + +(fn C1Test () + (let c1 (C1)) + (printfn $"Original sequence: %O{c1}") + (let v (.FindLargestSmallerThan &c1 16)) + (set! v (* v 2)) + (printfn $"New sequence: %O{c1}")) + +(C1Test) + +(fn f_inref ([dt: inref]) + (printfn $"Now: {dt:``yyyy-MM-dd``}")) + +(fn f_byref ([dt: byref]) + (printfn $"Now: {dt:``yyyy-MM-dd``}") + (set! dt (.AddDays dt 1))) + +(fn UsingByrefs () + (let dt (new DateTime 2023 12 26)) + (f_inref &dt) + + (mut dt (new DateTime 2023 12 26)) + (f_byref &dt) + (f_inref &dt) + + ()) + +(UsingByrefs) + +()