Update Fantomas version to 4.7.9 (#1466)

This commit is contained in:
Sarah Marshall 2022-06-16 13:58:21 -07:00 коммит произвёл GitHub
Родитель 5990f08451
Коммит 0e0497e142
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
62 изменённых файлов: 724 добавлений и 649 удалений

Просмотреть файл

@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fantomas-tool": {
"version": "4.6.5",
"version": "4.7.9",
"commands": [
"fantomas"
]

Просмотреть файл

@ -39,7 +39,7 @@ dotnet_diagnostic.SA1629.severity = none # Documentation text should end
dotnet_diagnostic.SA1642.severity = none # Constructor summary documentation should begin with standard text
dotnet_diagnostic.SA1649.severity = none # File name should match first type name
[*.fs]
[*.{fs,fsi}]
indent_size = 4
fsharp_max_array_or_list_width = 80

Просмотреть файл

@ -1112,6 +1112,7 @@ module SimulationCode =
/// eg:
/// protected opType opName { get; }
let signature = roslynCallableTypeName context qualifiedName
let name = getOpName context qualifiedName
let modifiers = getPropertyModifiers qualifiedName
prop signature name modifiers :> MemberDeclarationSyntax

Просмотреть файл

@ -247,7 +247,7 @@ module SymbolResolution =
let getRedirect (att: AttributeAnnotation) =
if att |> IndicatesDeprecation checkQualification then Some att.Argument else None
StringArgument(getRedirect, (fun ex -> ex.Expression)) attributes
StringArgument (getRedirect, (fun ex -> ex.Expression)) attributes
|> Seq.tryHead
|> QsNullable.ofOption
@ -259,7 +259,7 @@ module SymbolResolution =
let getRedirect (att: QsDeclarationAttribute) =
if att |> BuiltIn.MarksDeprecation then Some att.Argument else None
StringArgument(getRedirect, (fun ex -> ex.Expression)) attributes
StringArgument (getRedirect, (fun ex -> ex.Expression)) attributes
|> Seq.tryHead
|> QsNullable.ofOption
@ -281,7 +281,7 @@ module SymbolResolution =
let getTestName (att: QsDeclarationAttribute) =
if att |> BuiltIn.DefinesNameForTesting then Some att.Argument else None
StringArgument(getTestName, (fun ex -> ex.Expression)) attributes
StringArgument (getTestName, (fun ex -> ex.Expression)) attributes
|> Seq.tryHead
|> Option.bind TryAsQualifiedName
|> QsNullable.ofOption
@ -293,7 +293,7 @@ module SymbolResolution =
let loadedViaTestName (att: QsDeclarationAttribute) =
if att |> BuiltIn.DefinesLoadedViaTestNameInsteadOf then Some att.Argument else None
StringArgument(loadedViaTestName, (fun ex -> ex.Expression)) attributes
StringArgument (loadedViaTestName, (fun ex -> ex.Expression)) attributes
|> Seq.tryHead
|> Option.bind TryAsQualifiedName
|> QsNullable.ofOption
@ -318,7 +318,7 @@ module SymbolResolution =
| true, valid -> valid
| false, _ -> null
StringArgument(getTarget, (fun ex -> ex.Expression)) attributes
StringArgument (getTarget, (fun ex -> ex.Expression)) attributes
|> Seq.map targetName
|> ImmutableHashSet.CreateRange
@ -363,7 +363,7 @@ module SymbolResolution =
let loadedViaTestName (att: QsDeclarationAttribute) =
if att |> BuiltIn.DefinesTargetInstruction then Some att.Argument else None
StringArgument(loadedViaTestName, (fun ex -> ex.Expression)) attributes
StringArgument (loadedViaTestName, (fun ex -> ex.Expression)) attributes
|> Seq.tryHead
|> QsNullable.ofOption
@ -400,7 +400,7 @@ module SymbolResolution =
[
if argType.Exists isNamedParam |> not && returnType.Exists isNamedParam |> not then
QsCompilerDiagnostic.Warning(WarningCode.UnusedTypeParam, [ "'" + name ]) range
QsCompilerDiagnostic.Warning (WarningCode.UnusedTypeParam, [ "'" + name ]) range
]
| InvalidName -> []
@ -719,7 +719,7 @@ module SymbolResolution =
let onTypeParam (_, tpRange) =
InvalidType, [| tpRange |> diagnostic ErrorCode.TypeParameterizedArgumentInAttribute |]
let resBaseType, typeErrs = ResolveType(onUdt, onTypeParam) bt
let resBaseType, typeErrs = ResolveType (onUdt, onTypeParam) bt
let resIdx, idxErrs = argExpression idx
(NewArray(resBaseType, resIdx), ArrayType resBaseType) |> asTypedExpression ex.Range,

Просмотреть файл

@ -36,6 +36,7 @@ type Namespace
/// dictionary containing a PartialNamespaces for each source file which implements a part of this namespace -
/// the key is the source file where each part of the namespace is defined
let Parts = parts.ToDictionary((fun item -> item.Key), (fun item -> item.Value))
let mutable TypesDefinedInAllSourcesCache = null
let mutable CallablesDefinedInAllSourcesCache = null
@ -57,10 +58,12 @@ type Namespace
/// name of the namespace
member this.Name = name
/// Immutable array with the names of all source files that contain (a part of) the namespace.
/// Note that files contained in referenced assemblies that implement part of the namespace
/// are *not* considered to be source files within the context of this Namespace instance!
member internal this.Sources = Parts.Keys.ToImmutableHashSet()
/// contains all types declared within one of the referenced assemblies as part of this namespace
member this.TypesInReferencedAssemblies = TypesInReferences // access should be fine, since this is immutable
/// contains all callables declared within one of the referenced assemblies as part of this namespace

Просмотреть файл

@ -187,7 +187,7 @@ type NamespaceManager
Array.append errs warnings
let error code args =
None, [| QsCompilerDiagnostic.Error(code, args) (symRange.ValueOr Range.Zero) |]
None, [| QsCompilerDiagnostic.Error (code, args) (symRange.ValueOr Range.Zero) |]
let findUnqualified () =
match
@ -264,7 +264,7 @@ type NamespaceManager
syncRoot.EnterReadLock()
try
SymbolResolution.ResolveType(processUDT, processTP) qsType
SymbolResolution.ResolveType (processUDT, processTP) qsType
finally
syncRoot.ExitReadLock()
@ -276,7 +276,7 @@ type NamespaceManager
[|
if udtAccess < parentAccess then
yield QsCompilerDiagnostic.Error(code, [ udt.Name; parent ]) udtRange
yield QsCompilerDiagnostic.Error (code, [ udt.Name; parent ]) udtRange
|]
/// <summary>
@ -700,7 +700,7 @@ type NamespaceManager
let res, errs = resolveType (parentName, tpNames, source) qsType checkAccess
if parentKind <> TypeConstructor then res, errs else res.WithoutRangeInfo, errs // strip positional info for auto-generated type constructors
SymbolResolution.ResolveCallableSignature(resolveType, specBundleCharacteristics) signature
SymbolResolution.ResolveCallableSignature (resolveType, specBundleCharacteristics) signature
/// Sets the Resolved property for all type and callable declarations to Null, and the ResolvedAttributes to an empty array.
@ -711,7 +711,7 @@ type NamespaceManager
if this.ContainsResolutions || force then
for ns in Namespaces.Values do
for kvPair in ns.TypesDefinedInAllSources() do
ns.SetTypeResolution(fst kvPair.Value) (kvPair.Key, Null, ImmutableArray.Empty)
ns.SetTypeResolution (fst kvPair.Value) (kvPair.Key, Null, ImmutableArray.Empty)
for kvPair in ns.CallablesDefinedInAllSources() do
ns.SetSpecializationResolutions(
@ -721,7 +721,7 @@ type NamespaceManager
)
|> ignore
ns.SetCallableResolution(fst kvPair.Value) (kvPair.Key, Null, ImmutableArray.Empty)
ns.SetCallableResolution (fst kvPair.Value) (kvPair.Key, Null, ImmutableArray.Empty)
this.ContainsResolutions <- false
@ -763,7 +763,7 @@ type NamespaceManager
|> Seq.collect (fun kvPair ->
let tName, (source, qsType) = kvPair.Key, kvPair.Value
let parentName = { Namespace = ns.Name; Name = tName }
let resolvedAttributes, msgs = this.ResolveAttributes(parentName, source) qsType
let resolvedAttributes, msgs = this.ResolveAttributes (parentName, source) qsType
ns.SetTypeResolution source (tName, qsType.Resolved, resolvedAttributes)
msgs |> Array.map (fun msg -> source, msg)))
@ -805,7 +805,7 @@ type NamespaceManager
let definedSpecs = ns.SpecializationsDefinedInAllSources parent.Name
let insertSpecialization typeArgs kind =
ns.InsertSpecialization(kind, typeArgs) (parent.Name, source)
ns.InsertSpecialization (kind, typeArgs) (parent.Name, source)
let props, bundleErrs =
SymbolResolution.GetBundleProperties insertSpecialization (signature, source) definedSpecs
@ -820,7 +820,7 @@ type NamespaceManager
| Warning _ -> ()
| Error errCode ->
let removed =
ns.RemoveSpecialization(specSource, { Offset = errPos; Range = d.Range }) parent.Name
ns.RemoveSpecialization (specSource, { Offset = errPos; Range = d.Range }) parent.Name
QsCompilerError.Verify(
(removed <= 1),
@ -835,7 +835,7 @@ type NamespaceManager
)
// only then can we resolve the generators themselves, as well as the callable and specialization attributes
let callableAttributes, attrErrs = this.ResolveAttributes(parent, source) signature
let callableAttributes, attrErrs = this.ResolveAttributes (parent, source) signature
let resolution _ = SymbolResolution.ResolveGenerator props
let specErrs =
@ -906,7 +906,7 @@ type NamespaceManager
for opened in nsToAutoOpen do
for ns in Namespaces.Values do
for source in ns.Sources do
this.AddOpenDirective(opened, Range.Zero) (null, Value Range.Zero) (ns.Name, source) |> ignore
this.AddOpenDirective (opened, Range.Zero) (null, Value Range.Zero) (ns.Name, source) |> ignore
// We need to resolve types before we resolve callables,
// since the attribute resolution for callables relies on the corresponding types having been resolved.
let typeDiagnostics = this.CacheTypeResolution nsNames
@ -1344,7 +1344,7 @@ type NamespaceManager
/// contain the parent namespace.
/// </exception>
member this.TryGetCallable (callableName: QsQualifiedName) (nsName, source) =
this.TryGetCallableHeader(callableName, None) (nsName, source)
this.TryGetCallableHeader (callableName, None) (nsName, source)
/// Given an unqualified callable name, returns the corresponding CallableDeclarationHeader in a ResolutionResult if
/// the qualifier can be uniquely resolved within the given parent namespace and source file, and the callable is
@ -1453,7 +1453,7 @@ type NamespaceManager
/// contain the parent namespace.
/// </exception>
member this.TryGetType (typeName: QsQualifiedName) (nsName, source) =
this.TryGetTypeHeader(typeName, None) (nsName, source)
this.TryGetTypeHeader (typeName, None) (nsName, source)
/// Given an unqualified type name, returns the corresponding TypeDeclarationHeader in a ResolutionResult if the
/// qualifier can be uniquely resolved within the given parent namespace and source file, and the type is
@ -1463,7 +1463,7 @@ type NamespaceManager
/// uniquely resolved.
member this.TryResolveAndGetType tName (nsName, source) =
let toHeader (declaredNs, (declaredSource, _, _)) =
match this.TryGetTypeHeader({ Namespace = declaredNs; Name = tName }, Some declaredSource) (nsName, source)
match this.TryGetTypeHeader ({ Namespace = declaredNs; Name = tName }, Some declaredSource) (nsName, source)
with
| Found value -> value
| _ ->

Просмотреть файл

@ -47,15 +47,19 @@ type private PartialNamespace
/// list containing all documentation for this namespace within this source file
/// -> a list since the namespace can in principle occur several times in the same file each time with documentation
let AssociatedDocumentation = documentation.ToList()
/// list of namespaces open or aliased within this namespace and file
let OpenNamespaces = openNS.ToDictionary(keySelector, valueSelector)
/// dictionary of types declared within this namespace and file
/// the key is the name of the type
let TypeDeclarations = typeDecl.ToDictionary(keySelector, valueSelector)
/// dictionary of callables declared within this namespace and file
/// includes functions, operations, *and* (auto-generated) type constructors
/// the key is the name of the callable
let CallableDeclarations = callableDecl.ToDictionary(keySelector, valueSelector)
/// dictionary of callable specializations declared within this namespace and file
/// -> note that all specializations that are declared in a namespace *have* to extend a declarations in the same namespace,
/// -> however, they may be declared in a source file (or even compilation unit) that is different from the one of the original declaration
@ -91,6 +95,7 @@ type private PartialNamespace
/// types defined within this (part of) the namespace
/// -> NOTE: the returned enumerable is *not* immutable and may change over time!
member internal this.DefinedTypes = TypeDeclarations.Select(fun item -> item.Key, item.Value)
/// callables defined within this (part of) the namespace (includes auto-generated type constructors)
/// -> NOTE: the returned enumerable is *not* immutable and may change over time!
member internal this.DefinedCallables = CallableDeclarations.Select(fun item -> item.Key, item.Value)

Просмотреть файл

@ -85,33 +85,33 @@ module SyntaxGenerator =
/// Creates a typed expression that corresponds to a Bool literal with the given value.
/// Sets the range information for the built expression to Null.
let BoolLiteral value =
AutoGeneratedExpression(BoolLiteral value) QsTypeKind.Bool false
AutoGeneratedExpression (BoolLiteral value) QsTypeKind.Bool false
/// Creates a typed expression that corresponds to an Int literal with the given value.
/// Sets the range information for the built expression to Null.
let IntLiteral v =
AutoGeneratedExpression(IntLiteral v) QsTypeKind.Int false
AutoGeneratedExpression (IntLiteral v) QsTypeKind.Int false
/// Creates a typed expression that corresponds to a BigInt literal with the given value.
/// Sets the range information for the built expression to Null.
let BigIntLiteral (v: int) =
AutoGeneratedExpression(BigIntLiteral(bigint v)) QsTypeKind.BigInt false
AutoGeneratedExpression (BigIntLiteral(bigint v)) QsTypeKind.BigInt false
/// Creates a typed expression that corresponds to a Double literal with the given value.
/// Sets the range information for the built expression to Null.
let DoubleLiteral v =
AutoGeneratedExpression(DoubleLiteral v) QsTypeKind.Double false
AutoGeneratedExpression (DoubleLiteral v) QsTypeKind.Double false
/// Creates a typed expression that corresponds to a String literal with the given value and interpolation arguments.
/// Sets the range information for the built expression to Null.
let StringLiteral (s, interpolArgs) =
AutoGeneratedExpression(StringLiteral(s, interpolArgs)) QsTypeKind.String false
AutoGeneratedExpression (StringLiteral(s, interpolArgs)) QsTypeKind.String false
/// Creates a typed expression that corresponds to a Range literal with the given left hand side and right hand side.
/// Sets the range information for the built expression to Null.
/// Does *not* verify the given left and right hand side.
let RangeLiteral (lhs, rhs) =
AutoGeneratedExpression(RangeLiteral(lhs, rhs)) QsTypeKind.Range false
AutoGeneratedExpression (RangeLiteral(lhs, rhs)) QsTypeKind.Range false
/// Creates a typed expression that corresponds to a value tuple with the given items.
/// Sets the range information for the built expression to Null.
@ -122,7 +122,7 @@ module SyntaxGenerator =
let tupleType =
items |> Seq.map (fun item -> item.ResolvedType) |> ImmutableArray.CreateRange |> TupleType
AutoGeneratedExpression(ValueTuple(items.ToImmutableArray())) tupleType qdep
AutoGeneratedExpression (ValueTuple(items.ToImmutableArray())) tupleType qdep
// utils for assignments
@ -187,7 +187,7 @@ module SyntaxGenerator =
and buildTuple elements =
let items = elements |> Seq.map resolveArgTupleItem |> ImmutableArray.CreateRange
let exType = items |> Seq.map (fun ex -> ex.ResolvedType) |> ImmutableArray.CreateRange |> TupleType
AutoGeneratedExpression(ValueTuple items) exType false
AutoGeneratedExpression (ValueTuple items) exType false
match argTuple with
| QsTuple elements when elements.Length = 0 -> UnitValue
@ -227,7 +227,7 @@ module SyntaxGenerator =
let exTypeKind =
QsTypeKind.Function(QsTypeKind.Range |> ResolvedType.New, QsTypeKind.Range |> ResolvedType.New)
let reverse = AutoGeneratedExpression(QsExpressionKind.Identifier(kind, Null)) exTypeKind false
let reverse = AutoGeneratedExpression (QsExpressionKind.Identifier(kind, Null)) exTypeKind false
CallNonGeneric(reverse, ex)
match ex.ResolvedType.Resolution with
@ -266,7 +266,7 @@ module SyntaxGenerator =
QsTypeKind.ArrayType(QsTypeKind.TypeParameter typeParameter |> ResolvedType.New) |> ResolvedType.New
let exTypeKind = QsTypeKind.Function(genArrayType, QsTypeKind.Int |> ResolvedType.New)
let length = AutoGeneratedExpression(QsExpressionKind.Identifier(kind, Null)) exTypeKind false
let length = AutoGeneratedExpression (QsExpressionKind.Identifier(kind, Null)) exTypeKind false
let callToLength tpRes =
let resolutions = ImmutableArray.Create((typeParameter.Origin, typeParameter.TypeName, tpRes))

Просмотреть файл

@ -28,7 +28,7 @@ type QsInitializer with
// utils for tuple matching
static member private OnTupleItems =
OnTupleItems(fun (single: QsInitializer) -> single.TupleItems) "QsInitializer"
OnTupleItems (fun (single: QsInitializer) -> single.TupleItems) "QsInitializer"
member internal this.TupleItems =
match this.Initializer with
@ -42,7 +42,7 @@ type ResolvedInitializer with
// utils for tuple matching
static member private OnTupleItems =
OnTupleItems(fun (single: ResolvedInitializer) -> single.TupleItems) "ResolvedInitializer"
OnTupleItems (fun (single: ResolvedInitializer) -> single.TupleItems) "ResolvedInitializer"
member internal this.TupleItems =
match this.Resolution with
@ -55,7 +55,7 @@ type QsSymbol with
// utils for tuple matching
static member private OnTupleItems = OnTupleItems(fun (single: QsSymbol) -> single.TupleItems) "QsSymbol"
static member private OnTupleItems = OnTupleItems (fun (single: QsSymbol) -> single.TupleItems) "QsSymbol"
member internal this.TupleItems =
match this.Symbol with
@ -69,7 +69,7 @@ type SymbolTuple with
// utils for tuple matching
static member private OnTupleItems = OnTupleItems(fun (single: SymbolTuple) -> single.TupleItems) "SymbolTuple"
static member private OnTupleItems = OnTupleItems (fun (single: SymbolTuple) -> single.TupleItems) "SymbolTuple"
member internal this.TupleItems =
match this with
@ -98,7 +98,7 @@ type ResolvedType with
// utils for tuple matching
static member private OnTupleItems = OnTupleItems(fun (single: ResolvedType) -> single.TupleItems) "ResolvedType"
static member private OnTupleItems = OnTupleItems (fun (single: ResolvedType) -> single.TupleItems) "ResolvedType"
member internal this.TupleItems =
match this.Resolution with
@ -148,14 +148,14 @@ type ResolvedType with
/// Returns an enumerable of all extracted return values.
member this.ExtractAll(extract: _ -> IEnumerable<_>) : IEnumerable<_> =
let inner (t: ResolvedType) = t.Resolution
ResolvedType.ExtractAll(inner, extract) this
ResolvedType.ExtractAll (inner, extract) this
type QsType with
// utils for tuple matching
static member private OnTupleItems = OnTupleItems(fun (single: QsType) -> single.TupleItems) "QsType"
static member private OnTupleItems = OnTupleItems (fun (single: QsType) -> single.TupleItems) "QsType"
member internal this.TupleItems =
match this.Type with
@ -171,7 +171,7 @@ type QsType with
/// Returns an enumerable of all extracted types.
member public this.ExtractAll(extract: _ -> IEnumerable<_>) =
let inner (t: QsType) = t.Type
ResolvedType.ExtractAll(inner, extract) this
ResolvedType.ExtractAll (inner, extract) this
type TypedExpression with
@ -179,7 +179,7 @@ type TypedExpression with
// utils for tuple matching
static member private OnTupleItems =
OnTupleItems(fun (single: TypedExpression) -> single.TupleItems) "TypedExpression"
OnTupleItems (fun (single: TypedExpression) -> single.TupleItems) "TypedExpression"
member internal this.TupleItems =
match this.Expression with
@ -303,7 +303,7 @@ type QsExpression with
// utils for tuple matching
static member private OnTupleItems = OnTupleItems(fun (single: QsExpression) -> single.TupleItems) "QsExpression"
static member private OnTupleItems = OnTupleItems (fun (single: QsExpression) -> single.TupleItems) "QsExpression"
member internal this.TupleItems =
match this.Expression with

Просмотреть файл

@ -83,7 +83,7 @@ type StatementKindTransformationBase(statementTransformation: _ -> StatementTran
let PositionedBlock (expr, body, location, comments) =
expr, QsPositionedBlock.New comments location body
PositionedBlock |> node.BuildOr(intro, block) (expr, body, location, comments)
PositionedBlock |> node.BuildOr (intro, block) (expr, body, location, comments)
// statements containing subconstructs or expressions

Просмотреть файл

@ -289,15 +289,15 @@ type QsCompilerDiagnostic =
/// builds a new diagnostics error with the give code and range
static member Error (code, args) range =
QsCompilerDiagnostic.New(Error code, args) range
QsCompilerDiagnostic.New (Error code, args) range
/// builds a new diagnostics warning with the give code and range
static member Warning (code, args) range =
QsCompilerDiagnostic.New(Warning code, args) range
QsCompilerDiagnostic.New (Warning code, args) range
/// builds a new diagnostics information with the give code and range
static member Info (code, args) range =
QsCompilerDiagnostic.New(Information code, args) range
QsCompilerDiagnostic.New (Information code, args) range
member this.Code =
match this.Diagnostic with

Просмотреть файл

@ -44,8 +44,8 @@ type RangeConverter() =
let start, end' = serializer.Deserialize<RangePosition * RangePosition> reader
// For backwards compatibility, convert the serialized one-based positions to zero-based positions.
Range.Create
(Position.Create(start.Line - 1) (start.Column - 1))
(Position.Create(end'.Line - 1) (end'.Column - 1))
(Position.Create (start.Line - 1) (start.Column - 1))
(Position.Create (end'.Line - 1) (end'.Column - 1))
override this.WriteJson(writer: JsonWriter, range: Range, serializer: JsonSerializer) =
// For backwards compatibility, convert the zero-based positions to one-based serialized positions.

Просмотреть файл

@ -357,7 +357,7 @@ type ResolvedCharacteristics =
/// The properties cannot be determined either because the characteristics expression contains unresolved parameters or is invalid.
/// </exception>
member this.GetProperties() =
match ResolvedCharacteristics.ExtractProperties(fun ex -> ex._Characteristics) this with
match ResolvedCharacteristics.ExtractProperties (fun ex -> ex._Characteristics) this with
| Some props -> props.ToImmutableHashSet()
| None -> InvalidOperationException "properties cannot be determined" |> raise
@ -369,7 +369,7 @@ type ResolvedCharacteristics =
| Adjointable -> Some Adjoint
| Controllable -> Some Controlled
match ResolvedCharacteristics.ExtractProperties(fun ex -> ex._Characteristics) this with
match ResolvedCharacteristics.ExtractProperties (fun ex -> ex._Characteristics) this with
| Some props -> (props |> Seq.choose getFunctor).ToImmutableHashSet() |> Value
| None -> Null

Просмотреть файл

@ -60,4 +60,4 @@ type PreEvaluation =
/// Attempts to pre-evaluate the given sequence of namespaces
/// as much as possible with a default optimization script
static member All(arg: QsCompilation) =
PreEvaluation.WithScript(PreEvaluation.DefaultScript false 40) arg
PreEvaluation.WithScript (PreEvaluation.DefaultScript false 40) arg

Просмотреть файл

@ -109,7 +109,7 @@ type internal ImperativeBuilder() =
member this.While(guard: Unit -> Imperative<'a, bool, 'c>, f: Imperative<'a, Unit, 'c>) =
fun s1 ->
match guard () s1 with
| Normal (true, s2) -> this.CombineLoopIters(f, this.While(guard, f)) s2
| Normal (true, s2) -> this.CombineLoopIters (f, this.While(guard, f)) s2
| Normal (false, s2) -> Normal((), s2)
| Break _ -> Exception "Cannot break in condition of while loop" |> raise
| Interrupt x -> Interrupt x
@ -120,7 +120,7 @@ type internal ImperativeBuilder() =
fun s1 ->
match sequence with
| [] -> Normal((), s1)
| head :: tail -> this.CombineLoopIters(body head, this.For(tail, body)) s1
| head :: tail -> this.CombineLoopIters (body head, this.For(tail, body)) s1
member this.For(sequence: seq<'d>, body: 'd -> Imperative<'a, Unit, 'c>) = this.For(List.ofSeq sequence, body)

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for a <code>class or interface property</code>
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module PropertyDeclaration =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for a <code>class</code>
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module ClassDeclaration =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for a <code>class constructor</code>
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module ConstructorDeclaration =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for <code>explicit</code> and <code>implicit</code> conversion operators
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module Conversion =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Generate foreach statements
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module ForeachStatement =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for a <code>generic type</code> name
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module GenericName =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Generate if statements
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module IfStatement =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for an <code>interface</code>
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module InterfaceDeclaration =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for a <code>method invocations</code>
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module Invocation =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -2,11 +2,11 @@
open Microsoft.CodeAnalysis
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for a <code>class or interface method</code>
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module MethodDeclaration =
open Microsoft.CodeAnalysis.CSharp

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for a <code>namespace</code>
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module NamespaceDeclaration =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Use this module to specify the syntax for a <code>object instantiation</code>
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module ObjectCreation =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Generate while statements
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module TryStatement =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -1,10 +1,10 @@
namespace Microsoft.Quantum.RoslynWrapper
#nowarn "1182" // Unused parameters
/// <summary>
/// Generate while statements
/// </summary>
#nowarn "1182" // Unused parameters
[<AutoOpen>]
module WhileStatement =
open Microsoft.CodeAnalysis

Просмотреть файл

@ -21,10 +21,12 @@ module Target =
val create: name: string -> capability: TargetCapability -> Target
type internal 'props Pattern =
{ Capability: TargetCapability
Diagnose: Target -> QsCompilerDiagnostic option
// TODO: Remove the additional properties as part of https://github.com/microsoft/qsharp-compiler/issues/1448.
Properties: 'props }
{
Capability: TargetCapability
Diagnose: Target -> QsCompilerDiagnostic option
// TODO: Remove the additional properties as part of https://github.com/microsoft/qsharp-compiler/issues/1448.
Properties: 'props
}
module internal Pattern =
val discard: 'props Pattern -> unit Pattern

Просмотреть файл

@ -117,12 +117,12 @@ module CallAnalyzer =
string capability.ClassicalCompute
]
QsCompilerDiagnostic.Error(ErrorCode.UnsupportedCallableCapability, args) range |> Some
QsCompilerDiagnostic.Error (ErrorCode.UnsupportedCallableCapability, args) range |> Some
| Recursive ->
// TODO: The capability description string should be defined with the rest of the diagnostic message
// instead of here, but this is easier after https://github.com/microsoft/qsharp-compiler/issues/1025.
let args = [ target.Name; "recursion" ]
QsCompilerDiagnostic.Error(ErrorCode.UnsupportedClassicalCapability, args) range |> Some
QsCompilerDiagnostic.Error (ErrorCode.UnsupportedClassicalCapability, args) range |> Some
{
Capability = capability
@ -139,7 +139,7 @@ module CallAnalyzer =
override this.OnTypedExpression expression =
match expression.Expression with
| Identifier (GlobalCallable name, _) ->
let range = QsNullable.Map2(+) transformation.Offset expression.Range
let range = QsNullable.Map2 (+) transformation.Offset expression.Range
references.Add(name, range)
| _ -> ()

Просмотреть файл

@ -9,9 +9,7 @@ open Microsoft.Quantum.QsCompiler.DependencyAnalysis
open Microsoft.Quantum.QsCompiler.SymbolManagement
open Microsoft.Quantum.QsCompiler.SyntaxTree
type internal Call =
{ Name: QsQualifiedName
Range: Range QsNullable }
type internal Call = { Name: QsQualifiedName; Range: Range QsNullable }
module internal CallAnalyzer =
val shallow: nsManager: NamespaceManager -> graph: CallGraph -> Analyzer<CallGraphNode, Call>

Просмотреть файл

@ -38,7 +38,7 @@ let referenceReasons (name: string) (range: _ QsNullable) (codeFile: string) dia
yield! diagnostic.Arguments
}
Option.map (fun code -> QsCompilerDiagnostic.Warning(code, args) (range.ValueOr Range.Zero)) warningCode
Option.map (fun code -> QsCompilerDiagnostic.Warning (code, args) (range.ValueOr Range.Zero)) warningCode
// TODO: Remove this function as part of https://github.com/microsoft/qsharp-compiler/issues/1448.
let explainCall (nsManager: NamespaceManager) graph target (call: Call) =

Просмотреть файл

@ -27,7 +27,7 @@ let createPattern range =
// instead of here, but this is easier after https://github.com/microsoft/qsharp-compiler/issues/1025.
let description = "conditional expression or mutable variable in a constant context"
let args = [ target.Name; description ]
QsCompilerDiagnostic.Error(ErrorCode.UnsupportedClassicalCapability, args) range |> Some
QsCompilerDiagnostic.Error (ErrorCode.UnsupportedClassicalCapability, args) range |> Some
{
Capability = capability
@ -140,7 +140,7 @@ let analyzer (action: SyntaxTreeTransformation -> _) : _ seq =
transformation.Expressions <-
{ new ExpressionTransformation(transformation, TransformationOptions.NoRebuild) with
override _.OnTypedExpression expression =
let range = QsNullable.Map2(+) transformation.Offset expression.Range
let range = QsNullable.Map2 (+) transformation.Offset expression.Range
match expression.Expression with
| CONDITIONAL _ -> if context.Value.ConstOnly then createPattern range |> patterns.Add

Просмотреть файл

@ -38,7 +38,7 @@ let createPattern range feature =
| DefaultArray -> "default-initialized array constructor"
let args = [ target.Name; description ]
QsCompilerDiagnostic.Error(ErrorCode.UnsupportedClassicalCapability, args) range |> Some
QsCompilerDiagnostic.Error (ErrorCode.UnsupportedClassicalCapability, args) range |> Some
{
Capability = capability
@ -72,7 +72,7 @@ let analyzer (action: SyntaxTreeTransformation -> _) : _ seq =
transformation.Expressions <-
{ new ExpressionTransformation(transformation, TransformationOptions.NoRebuild) with
override _.OnTypedExpression expression =
let range = QsNullable.Map2(+) transformation.Offset expression.Range
let range = QsNullable.Map2 (+) transformation.Offset expression.Range
match expression.Expression with
| CallLikeExpression (callee, _) ->

Просмотреть файл

@ -65,7 +65,7 @@ let createPattern kind range =
None
else
Some(ErrorCode.SetInResultConditionedBlock, [ name; target.Name ])
|> Option.map (fun (code, args) -> QsCompilerDiagnostic.Error(code, args) range)
|> Option.map (fun (code, args) -> QsCompilerDiagnostic.Error (code, args) range)
{
Capability = capability
@ -129,7 +129,7 @@ let analyzer callableKind (action: SyntaxTreeTransformation -> _) : _ seq =
update.Lhs.ExtractAll (fun e ->
match e.Expression with
| Identifier (LocalVariable name, _) when Set.contains name context.Value.FrozenVars ->
let range = QsNullable.Map2(+) transformation.Offset e.Range
let range = QsNullable.Map2 (+) transformation.Offset e.Range
[ createPattern (SetInDependentBranch name) range ]
| _ -> [])
|> patterns.AddRange
@ -175,7 +175,7 @@ let analyzer callableKind (action: SyntaxTreeTransformation -> _) : _ seq =
else
UnrestrictedEquality
let range = QsNullable.Map2(+) transformation.Offset expression.Range
let range = QsNullable.Map2 (+) transformation.Offset expression.Range
createPattern dependency range |> patterns.Add
base.OnTypedExpression expression

Просмотреть файл

@ -112,7 +112,7 @@ let createPattern context construct range (ty: ResolvedType) =
let description = Seq.map describeScenario unsupported |> String.concat ", "
let args = [ target.Name; description ]
let range = QsNullable.defaultValue Range.Zero range
QsCompilerDiagnostic.Error(ErrorCode.UnsupportedClassicalCapability, args) range |> Some
QsCompilerDiagnostic.Error (ErrorCode.UnsupportedClassicalCapability, args) range |> Some
Some
{
@ -185,7 +185,7 @@ let analyzer (action: SyntaxTreeTransformation -> _) : _ seq =
| RangeLiteral _ -> Some Literal
| _ -> None
let range = QsNullable.Map2(+) transformation.Offset expression.Range
let range = QsNullable.Map2 (+) transformation.Offset expression.Range
Option.bind (fun c -> createPattern context.Value c range expression.ResolvedType) construct
|> Option.iter patterns.Add

Просмотреть файл

@ -132,7 +132,7 @@ let private verifySpecialization (context: SyntaxTokenContext) =
false, [| (ErrorCode.ControlledAdjointDeclInFunction |> Error, context.Range) |]
| decl -> checkGenerator decl
let NullOr = ApplyOrDefaultTo(false, [||]) context.Self // empty fragments can be excluded from the compilation
let NullOr = ApplyOrDefaultTo (false, [||]) context.Self // empty fragments can be excluded from the compilation
let errMsg = false, [| (ErrorCode.NotWithinCallable |> Error, context.Range) |]
@ -180,7 +180,7 @@ let private verifyStatement (context: SyntaxTokenContext) =
| ReturnStatement _ -> false, [| (ErrorCode.ReturnFromWithinApplyBlock |> Error, context.Range) |]
| _ -> true, [||]
let NullOr = ApplyOrDefaultTo(false, [||]) context.Self // empty fragments can be excluded from the compilation
let NullOr = ApplyOrDefaultTo (false, [||]) context.Self // empty fragments can be excluded from the compilation
let notWithinSpecialization = false, [| (ErrorCode.NotWithinSpecialization |> Error, context.Range) |]
@ -298,7 +298,7 @@ let VerifySyntaxTokenContext =
| DeclarationAttribute _ -> verifyDeclarationAttribute context
| NamespaceDeclaration _ -> verifyNamespace context
| InvalidFragment _ -> false, [||]
|> fun (kind, tuple) -> kind, tuple |> Array.map (fun (x, y) -> QsCompilerDiagnostic.New(x, []) y))
|> fun (kind, tuple) -> kind, tuple |> Array.map (fun (x, y) -> QsCompilerDiagnostic.New (x, []) y))
let private mergeMaps onDuplicateKey =
fun map key value ->

Просмотреть файл

@ -101,7 +101,7 @@ let private verifyConditionalExecution (expr: TypedExpression) =
[
if expr.Exists isOperationCall then
QsCompilerDiagnostic.Warning(WarningCode.ConditionalEvaluationOfOperationCall, []) (rangeOrDefault expr)
QsCompilerDiagnostic.Warning (WarningCode.ConditionalEvaluationOfOperationCall, []) (rangeOrDefault expr)
]
/// <summary>
@ -254,7 +254,7 @@ let private verifyIdentifier (inference: InferenceContext) (symbols: SymbolTrack
| LocalVariable _, Null -> (identifier, resId.Type) |> exprWithoutTypeArgs symbol.Range info, Seq.toList diagnostics
| LocalVariable _, Value _ ->
invalidWithoutTargs false,
QsCompilerDiagnostic.Error(ErrorCode.IdentifierCannotHaveTypeArguments, []) symbol.RangeOrDefault
QsCompilerDiagnostic.Error (ErrorCode.IdentifierCannotHaveTypeArguments, []) symbol.RangeOrDefault
:: Seq.toList diagnostics
| GlobalCallable _, Value res when res.Length <> typeParams.Length ->
invalidWithoutTargs false,
@ -307,13 +307,13 @@ let rec internal verifyBinding (inference: InferenceContext) tryBuildDeclaration
| InvalidSymbol -> InvalidItem, [||], [||]
| MissingSymbol when warnOnDiscard ->
let warning =
QsCompilerDiagnostic.Warning(WarningCode.DiscardingItemInAssignment, []) symbol.RangeOrDefault
QsCompilerDiagnostic.Warning (WarningCode.DiscardingItemInAssignment, []) symbol.RangeOrDefault
DiscardedItem, [||], [| warning |]
| MissingSymbol -> DiscardedItem, [||], [||]
| OmittedSymbols
| QualifiedSymbol _ ->
let error = QsCompilerDiagnostic.Error(ErrorCode.ExpectingUnqualifiedSymbol, []) symbol.RangeOrDefault
let error = QsCompilerDiagnostic.Error (ErrorCode.ExpectingUnqualifiedSymbol, []) symbol.RangeOrDefault
InvalidItem, [||], [| error |]
| Symbol name ->
match tryBuildDeclaration (name, symbol.RangeOrDefault) rhsType with
@ -549,7 +549,7 @@ type QsExpression with
| InvalidSymbol -> InvalidIdentifier
| Symbol name -> LocalVariable name
| _ ->
QsCompilerDiagnostic.Error(ErrorCode.ExpectingItemName, []) sym.RangeOrDefault |> diagnose
QsCompilerDiagnostic.Error (ErrorCode.ExpectingItemName, []) sym.RangeOrDefault |> diagnose
InvalidIdentifier
/// Resolves and verifies the given expression and item name of a named item access expression,
@ -759,7 +759,7 @@ type QsExpression with
inference.Constrain(callable.ResolvedType <. ResolvedType.New(QsTypeKind.Function(argType, output)))
if inference.Resolve callable.ResolvedType |> isOperation then
QsCompilerDiagnostic.Error(ErrorCode.OperationCallOutsideOfOperation, []) this.RangeOrDefault
QsCompilerDiagnostic.Error (ErrorCode.OperationCallOutsideOfOperation, []) this.RangeOrDefault
|> diagnose
else
List.iter diagnose diagnostics

Просмотреть файл

@ -32,7 +32,7 @@ let private onAutoInvertCheckQuantumDependency (symbols: SymbolTracker) (expr: T
[|
if symbols.RequiredFunctorSupport.Contains Adjoint
&& expr.InferredInformation.HasLocalQuantumDependency then
QsCompilerDiagnostic.Error(ErrorCode.QuantumDependencyOutsideExprStatement, []) (rangeOrDefault expr)
QsCompilerDiagnostic.Error (ErrorCode.QuantumDependencyOutsideExprStatement, []) (rangeOrDefault expr)
|]
/// If the given SymbolTracker specifies that an auto-inversion of the routine is requested,
@ -60,7 +60,7 @@ let NewExpressionStatement comments location context expr =
if context.Inference.Constrain(ResolvedType.New UnitType .> expr.ResolvedType) |> List.isEmpty |> not then
let type_ = context.Inference.Resolve expr.ResolvedType |> SyntaxTreeToQsharp.Default.ToCode
let range = QsNullable.defaultValue Range.Zero expr.Range
QsCompilerDiagnostic.Error(ErrorCode.ValueImplicitlyIgnored, [ type_ ]) range |> diagnostics.Add
QsCompilerDiagnostic.Error (ErrorCode.ValueImplicitlyIgnored, [ type_ ]) range |> diagnostics.Add
QsExpressionStatement expr |> asStatement comments location LocalDeclarations.Empty, diagnostics.ToArray()
@ -112,7 +112,7 @@ let NewValueUpdate comments (location: QsLocation) context (lhs, rhs) =
| Identifier (LocalVariable id, Null) -> context.Symbols.UpdateQuantumDependency id localQdep
| _ -> ()
| Item ex ->
QsCompilerDiagnostic.Error(ErrorCode.UpdateOfImmutableIdentifier, []) (ex.Range.ValueOr Range.Zero)
QsCompilerDiagnostic.Error (ErrorCode.UpdateOfImmutableIdentifier, []) (ex.Range.ValueOr Range.Zero)
|> diagnostics.Add
| _ -> () // both missing and invalid expressions on the lhs are fine

Просмотреть файл

@ -118,7 +118,7 @@ type SymbolTracker(globals: NamespaceManager, sourceFile, parent: QsQualifiedNam
let globalTypeWithName (ns, name) =
match ns with
| None -> GlobalSymbols().TryResolveAndGetType name (parent.Namespace, sourceFile)
| Some nsName -> GlobalSymbols().TryGetType(QsQualifiedName.New(nsName, name)) (parent.Namespace, sourceFile)
| Some nsName -> GlobalSymbols().TryGetType (QsQualifiedName.New(nsName, name)) (parent.Namespace, sourceFile)
/// If a callable declaration (including type constructors!) for a callable with the given name exists in GlobalSymbols,
/// returns a its header information as Value. Returns Null otherwise.
@ -128,7 +128,7 @@ type SymbolTracker(globals: NamespaceManager, sourceFile, parent: QsQualifiedNam
match ns with
| None -> GlobalSymbols().TryResolveAndGetCallable name (parent.Namespace, sourceFile)
| Some nsName ->
GlobalSymbols().TryGetCallable(QsQualifiedName.New(nsName, name)) (parent.Namespace, sourceFile)
GlobalSymbols().TryGetCallable (QsQualifiedName.New(nsName, name)) (parent.Namespace, sourceFile)
/// the namespace and callable declaration within which the symbols tracked by this SymbolTracker instance are used
member this.Parent = parent
@ -341,7 +341,7 @@ type SymbolTracker(globals: NamespaceManager, sourceFile, parent: QsQualifiedNam
/// For each diagnostic generated during the resolution, calls the given addDiagnostics function on it.
/// Returns the resolved type, *including* its range information if applicable.
member internal this.ResolveType addDiagnostic (qsType: QsType) =
let resolved, errs = GlobalSymbols().ResolveType(parent, typeParameters, sourceFile) qsType
let resolved, errs = GlobalSymbols().ResolveType (parent, typeParameters, sourceFile) qsType
for err in errs do
addDiagnostic err

Просмотреть файл

@ -82,7 +82,7 @@ module Diagnostic =
function
| TypeMismatch context ->
let range = TypeRange.tryRange context.Actual.Range |> QsNullable.defaultValue Range.Zero
QsCompilerDiagnostic.Error(ErrorCode.TypeMismatch, typeContextArgs context) range
QsCompilerDiagnostic.Error (ErrorCode.TypeMismatch, typeContextArgs context) range
| TypeIntersectionMismatch (ordering, context) ->
let orderingString =
match ordering with
@ -96,8 +96,8 @@ module Diagnostic =
|> QsNullable.defaultValue Range.Zero
let args = orderingString :: typeContextArgs context
QsCompilerDiagnostic.Error(ErrorCode.TypeIntersectionMismatch, args) range
QsCompilerDiagnostic.Error (ErrorCode.TypeIntersectionMismatch, args) range
| InfiniteType context ->
let range = TypeRange.tryRange context.Actual.Range |> QsNullable.defaultValue Range.Zero
QsCompilerDiagnostic.Error(ErrorCode.InfiniteType, typeContextArgs context) range
QsCompilerDiagnostic.Error (ErrorCode.InfiniteType, typeContextArgs context) range
| CompilerDiagnostic diagnostic -> diagnostic

Просмотреть файл

@ -19,10 +19,12 @@ open Microsoft.Quantum.QsCompiler.SyntaxTree
/// </para>
/// </example>
type internal TypeContext =
{ Expected: ResolvedType
ExpectedParent: ResolvedType option
Actual: ResolvedType
ActualParent: ResolvedType option }
{
Expected: ResolvedType
ExpectedParent: ResolvedType option
Actual: ResolvedType
ActualParent: ResolvedType option
}
module internal TypeContext =
val createOrphan: expected: ResolvedType -> actual: ResolvedType -> TypeContext

Просмотреть файл

@ -361,7 +361,7 @@ type InferenceContext(symbolTracker: SymbolTracker) =
member private context.ApplyClassConstraint cls =
let error code args range =
let range = TypeRange.tryRange range |> QsNullable.defaultValue Range.Zero
QsCompilerDiagnostic.Error(code, args) range |> CompilerDiagnostic
QsCompilerDiagnostic.Error (code, args) range |> CompilerDiagnostic
let isInvalidType ty =
context.Resolve(ty).Resolution = InvalidType
@ -517,7 +517,7 @@ type InferenceContext(symbolTracker: SymbolTracker) =
match container.Resolution with
| UserDefinedType udt ->
let actualItem = symbolTracker.GetUnderlyingType(fun _ -> ()) udt
let actualItem = symbolTracker.GetUnderlyingType (fun _ -> ()) udt
context.ConstrainImpl(item .> actualItem)
| _ ->
[

Просмотреть файл

@ -247,7 +247,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraphWithExe 1 |> BuildTrimmedGraph
[ "Main", [ "Foo"; "Bar" ]; "Foo", []; "Bar", [ "Baz" ]; "Baz", [] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
[<Fact>]
@ -256,7 +256,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraphWithExe 2 |> BuildTrimmedGraph
[ "Main", [ "Foo" ]; "Foo", [] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
[ "Bar"; "Baz" ] |> List.map (AssertNotInGraph graph) |> ignore
@ -267,7 +267,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraphWithExe 3 |> BuildTrimmedGraph
[ "Main", [ "Foo" ]; "Foo", [] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
AssertNotInGraph graph "NotCalled"
@ -278,7 +278,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraph 4 |> CallGraph
[ "Main", [ "Foo" ]; "Foo", [] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
AssertInGraph graph "NotCalled"
@ -289,7 +289,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraph 5 |> CallGraph
[ "Main", [ "Foo" ]; "Foo", []; "Bar", [ "Baz" ]; "Baz", [] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
[<Fact>]
@ -304,7 +304,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraphWithExe 7 |> BuildTrimmedGraph
[ "Main", [ "Foo" ]; "Foo", [ "Main" ] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
[<Fact>]
@ -313,7 +313,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraphWithExe 8 |> BuildTrimmedGraph
[ "Main", [ "Foo" ]; "Foo", [] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
AssertNotInGraph graph "Bar"
@ -324,7 +324,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraphWithExe 9 |> BuildTrimmedGraph
[ "Main1", [ "Foo" ]; "Main2", [ "Bar" ]; "Foo", []; "Bar", [] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
[<Fact>]
@ -333,7 +333,7 @@ type CallGraphTests(output: ITestOutputHelper) =
let graph = PopulateCallGraphWithExe 10 |> BuildTrimmedGraph
[ "Test", [ "Foo" ]; "Foo", [] ]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
AssertNotInGraph graph "Bar"
@ -349,7 +349,7 @@ type CallGraphTests(output: ITestOutputHelper) =
"Test1", [ "Zip" ]
"Test2", [ "Zap" ]
]
|> List.map (fun x -> AssertExpectedDirectDependencies(fst x) (snd x) graph)
|> List.map (fun x -> AssertExpectedDirectDependencies (fst x) (snd x) graph)
|> ignore
AssertNotInGraph graph "Unused"

Просмотреть файл

@ -379,8 +379,8 @@ type ClassicalControlTests() =
|> Seq.filter (fun x -> x.Name = Signatures.ClassicalControlNS)
|> GlobalCallableResolutions
let original = callables |> Seq.find (fun x -> x.Key.Name = "Foo") |> fun x -> x.Value
let generated = callables |> Seq.find (fun x -> x.Key.Name.EndsWith "_Foo") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "Foo") |> (fun x -> x.Value)
let generated = callables |> Seq.find (fun x -> x.Key.Name.EndsWith "_Foo") |> (fun x -> x.Value)
let GetTypeParams call =
call.Signature.TypeParameters
@ -425,9 +425,9 @@ type ClassicalControlTests() =
|> Seq.filter (fun x -> x.Name = Signatures.ClassicalControlNS)
|> GlobalCallableResolutions
let selfOp = callables |> Seq.find (fun x -> x.Key.Name = "Self") |> fun x -> x.Value
let invertOp = callables |> Seq.find (fun x -> x.Key.Name = "Invert") |> fun x -> x.Value
let providedOp = callables |> Seq.find (fun x -> x.Key.Name = "Provided") |> fun x -> x.Value
let selfOp = callables |> Seq.find (fun x -> x.Key.Name = "Self") |> (fun x -> x.Value)
let invertOp = callables |> Seq.find (fun x -> x.Key.Name = "Invert") |> (fun x -> x.Value)
let providedOp = callables |> Seq.find (fun x -> x.Key.Name = "Provided") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZero.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable selfOp)
@ -438,8 +438,8 @@ type ClassicalControlTests() =
[ (1, BuiltIn.ApplyIfZero.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable providedOp)
let _selfOp = callables |> Seq.find (fun x -> x.Key.Name.EndsWith "_Self") |> fun x -> x.Value
let _invertOp = callables |> Seq.find (fun x -> x.Key.Name.EndsWith "_Invert") |> fun x -> x.Value
let _selfOp = callables |> Seq.find (fun x -> x.Key.Name.EndsWith "_Self") |> (fun x -> x.Value)
let _invertOp = callables |> Seq.find (fun x -> x.Key.Name.EndsWith "_Invert") |> (fun x -> x.Value)
let _providedOps =
callables |> Seq.filter (fun x -> x.Key.Name.EndsWith "_Provided") |> Seq.map (fun x -> x.Value)
@ -465,8 +465,8 @@ type ClassicalControlTests() =
|> Seq.filter (fun x -> x.Name = Signatures.ClassicalControlNS)
|> GlobalCallableResolutions
let distributeOp = callables |> Seq.find (fun x -> x.Key.Name = "Distribute") |> fun x -> x.Value
let providedOp = callables |> Seq.find (fun x -> x.Key.Name = "Provided") |> fun x -> x.Value
let distributeOp = callables |> Seq.find (fun x -> x.Key.Name = "Distribute") |> (fun x -> x.Value)
let providedOp = callables |> Seq.find (fun x -> x.Key.Name = "Provided") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroC.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable distributeOp)
@ -475,7 +475,7 @@ type ClassicalControlTests() =
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable providedOp)
let _distributeOp =
callables |> Seq.find (fun x -> x.Key.Name.EndsWith "_Distribute") |> fun x -> x.Value
callables |> Seq.find (fun x -> x.Key.Name.EndsWith "_Distribute") |> (fun x -> x.Value)
let _providedOps =
callables |> Seq.filter (fun x -> x.Key.Name.EndsWith "_Provided") |> Seq.map (fun x -> x.Value)
@ -503,7 +503,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let bodyCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "ProvidedBody") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "ProvidedBody") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroCA.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -529,7 +529,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let controlledCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "ProvidedControlled") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "ProvidedControlled") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroA.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -565,7 +565,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let adjointCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "ProvidedAdjoint") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "ProvidedAdjoint") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroC.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -601,7 +601,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let allCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "ProvidedAll") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "ProvidedAll") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZero.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -652,7 +652,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let bodyCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "DistributeBody") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "DistributeBody") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroCA.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -675,7 +675,8 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let controlledCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "DistributeControlled") |> fun x -> x.Value
let original =
callables |> Seq.find (fun x -> x.Key.Name = "DistributeControlled") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroCA.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -703,7 +704,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let adjointCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "DistributeAdjoint") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "DistributeAdjoint") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroC.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -731,7 +732,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let allCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "DistributeAll") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "DistributeAll") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZero.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -774,7 +775,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let bodyCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "InvertBody") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "InvertBody") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroCA.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -795,7 +796,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let controlledCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "InvertControlled") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "InvertControlled") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroA.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -823,7 +824,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let adjointCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "InvertAdjoint") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "InvertAdjoint") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroCA.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -851,7 +852,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let allCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "InvertAll") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "InvertAll") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZero.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -892,7 +893,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let bodyCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "SelfBody") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "SelfBody") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZeroC.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)
@ -913,7 +914,7 @@ type ClassicalControlTests() =
(*-----------------------------------------*)
let controlledCheck () =
let original = callables |> Seq.find (fun x -> x.Key.Name = "SelfControlled") |> fun x -> x.Value
let original = callables |> Seq.find (fun x -> x.Key.Name = "SelfControlled") |> (fun x -> x.Value)
[ (1, BuiltIn.ApplyIfZero.FullName) ]
|> assertSpecializationHasCalls (TestUtils.getBodyFromCallable original)

Просмотреть файл

@ -69,7 +69,7 @@ module SerializationTests =
Type = t |> ResolvedType.New
InferredInformation = InferredExpressionInformation.New(false, false)
Position = Null
Range = Range.Create(Position.Create 0 s) (Position.Create 0 e)
Range = Range.Create (Position.Create 0 s) (Position.Create 0 e)
}
let tupleIntIntType = TupleType([ Int |> ResolvedType.New; Int |> ResolvedType.New ].ToImmutableArray())
@ -105,7 +105,7 @@ module SerializationTests =
Attributes = ImmutableArray.Empty
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 4 43 |> DeclarationHeader.Offset.Defined
HeaderRange = Range.Create(Position.Create 0 0) (Position.Create 0 4) |> DeclarationHeader.Range.Defined
HeaderRange = Range.Create (Position.Create 0 0) (Position.Create 0 4) |> DeclarationHeader.Range.Defined
Documentation = ImmutableArray.Empty
}
|> testOne
@ -123,7 +123,7 @@ module SerializationTests =
Attributes = ImmutableArray.Empty
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 5 39 |> DeclarationHeader.Offset.Defined
HeaderRange = Range.Create(Position.Create 0 0) (Position.Create 0 4) |> DeclarationHeader.Range.Defined
HeaderRange = Range.Create (Position.Create 0 0) (Position.Create 0 4) |> DeclarationHeader.Range.Defined
Documentation = [ "Line one"; "Line two" ] |> ImmutableArray.CreateRange
}
|> testOne
@ -140,7 +140,7 @@ module SerializationTests =
Attributes = ImmutableArray.Empty
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 5 4 |> DeclarationHeader.Offset.Defined
HeaderRange = Range.Create(Position.Create 0 8) (Position.Create 0 12) |> DeclarationHeader.Range.Defined
HeaderRange = Range.Create (Position.Create 0 8) (Position.Create 0 12) |> DeclarationHeader.Range.Defined
Documentation = ImmutableArray.Empty
}
|> testOne
@ -157,7 +157,7 @@ module SerializationTests =
Attributes = ImmutableArray.Empty
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 6 4 |> DeclarationHeader.Offset.Defined
HeaderRange = Range.Create(Position.Create 0 8) (Position.Create 0 14) |> DeclarationHeader.Range.Defined
HeaderRange = Range.Create (Position.Create 0 8) (Position.Create 0 14) |> DeclarationHeader.Range.Defined
Documentation = ImmutableArray.Empty
}
|> testOne
@ -178,7 +178,7 @@ module SerializationTests =
Access = Public
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 2 4 |> DeclarationHeader.Offset.Defined
SymbolRange = Range.Create(Position.Create 0 8) (Position.Create 0 12) |> DeclarationHeader.Range.Defined
SymbolRange = Range.Create (Position.Create 0 8) (Position.Create 0 12) |> DeclarationHeader.Range.Defined
ArgumentTuple =
[
varDecl "__Item1__" Int (1, 1) |> QsTupleItem
@ -198,7 +198,7 @@ module SerializationTests =
Access = Public
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 4 4 |> DeclarationHeader.Offset.Defined
SymbolRange = Range.Create(Position.Create 0 9) (Position.Create 0 22) |> DeclarationHeader.Range.Defined
SymbolRange = Range.Create (Position.Create 0 9) (Position.Create 0 22) |> DeclarationHeader.Range.Defined
ArgumentTuple = [ varDecl "p" udtPair (25, 26) |> QsTupleItem ].ToImmutableArray() |> QsTuple
Signature = simpleSignature udtPair UnitType []
Documentation = ImmutableArray.Empty
@ -212,7 +212,7 @@ module SerializationTests =
Access = Public
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 5 4 |> DeclarationHeader.Offset.Defined
SymbolRange = Range.Create(Position.Create 0 10) (Position.Create 0 24) |> DeclarationHeader.Range.Defined
SymbolRange = Range.Create (Position.Create 0 10) (Position.Create 0 24) |> DeclarationHeader.Range.Defined
ArgumentTuple = [].ToImmutableArray() |> QsTuple
Signature = simpleSignature UnitType UnitType [ Adjointable; Controllable ]
Documentation = ImmutableArray.Empty
@ -226,7 +226,7 @@ module SerializationTests =
Access = Public
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 3 4 |> DeclarationHeader.Offset.Defined
SymbolRange = Range.Create(Position.Create 0 8) (Position.Create 0 14) |> DeclarationHeader.Range.Defined
SymbolRange = Range.Create (Position.Create 0 8) (Position.Create 0 14) |> DeclarationHeader.Range.Defined
ArgumentTuple =
[
varDecl "__Item1__" Int (1, 1) |> QsTupleItem
@ -254,7 +254,7 @@ module SerializationTests =
Access = Public
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 2 4 |> DeclarationHeader.Offset.Defined
SymbolRange = Range.Create(Position.Create 0 8) (Position.Create 0 12) |> DeclarationHeader.Range.Defined
SymbolRange = Range.Create (Position.Create 0 8) (Position.Create 0 12) |> DeclarationHeader.Range.Defined
Type = tupleIntIntType |> ResolvedType.New
TypeItems = intIntTypeItems
Documentation = ImmutableArray.Empty
@ -267,7 +267,7 @@ module SerializationTests =
Access = Public
Source = { CodeFile = "Test.qs"; AssemblyFile = Null }
Position = Position.Create 3 4 |> DeclarationHeader.Offset.Defined
SymbolRange = Range.Create(Position.Create 0 8) (Position.Create 0 14) |> DeclarationHeader.Range.Defined
SymbolRange = Range.Create (Position.Create 0 8) (Position.Create 0 14) |> DeclarationHeader.Range.Defined
Type = tupleIntIntType |> ResolvedType.New
TypeItems = intIntTypeItems
Documentation = ImmutableArray.Empty

Просмотреть файл

@ -15,11 +15,11 @@ open Xunit
let private random = System.Random 1
let private randomPosition () =
Position.Create(random.Next()) (random.Next())
Position.Create (random.Next()) (random.Next())
let private randomRange () =
let a, b = randomPosition (), randomPosition ()
Range.Create(min a b) (max a b)
Range.Create (min a b) (max a b)
let toQualName (ns: string, name: string) = { Namespace = ns; Name = name }

Просмотреть файл

@ -99,15 +99,15 @@ type CompilerTests(compilation: CompilationUnitManager.Compilation) =
member this.Verify(name, expected: IEnumerable<ErrorCode>) =
let expected = expected.Select(fun code -> int code)
VerifyDiagnosticsOfSeverity(Nullable DiagnosticSeverity.Error) name expected
VerifyDiagnosticsOfSeverity (Nullable DiagnosticSeverity.Error) name expected
member this.Verify(name, expected: IEnumerable<WarningCode>) =
let expected = expected.Select(fun code -> int code)
VerifyDiagnosticsOfSeverity(Nullable DiagnosticSeverity.Warning) name expected
VerifyDiagnosticsOfSeverity (Nullable DiagnosticSeverity.Warning) name expected
member this.Verify(name, expected: IEnumerable<InformationCode>) =
let expected = expected.Select(fun code -> int code)
VerifyDiagnosticsOfSeverity(Nullable DiagnosticSeverity.Information) name expected
VerifyDiagnosticsOfSeverity (Nullable DiagnosticSeverity.Information) name expected
member this.VerifyDiagnostics(name, expected: IEnumerable<DiagnosticItem>) =
let errs =

Просмотреть файл

@ -33,7 +33,7 @@ let private _MakeTupleType tupleItems =
names
|> String.concat ", "
|> fun x -> "(" + x + ")", types |> List.map ResolvedType.New |> fun x -> x.ToImmutableArray() |> TupleType
|> fun x -> "(" + x + ")", types |> List.map ResolvedType.New |> (fun x -> x.ToImmutableArray() |> TupleType)
let private _MakeTypeMap extraTypes =
Array.concat [ _BaseTypes; extraTypes ] |> Seq.map (fun (k, v) -> k, ResolvedType.New v) |> dict

Просмотреть файл

@ -56,7 +56,7 @@ let internal isSymbolContinuation c =
/// Returns the current position in the input stream.
let internal getPosition =
CharParsers.getPosition |>> fun p -> Position.Create(int p.Line - 1) (int p.Column - 1)
CharParsers.getPosition |>> fun p -> Position.Create (int p.Line - 1) (int p.Column - 1)
/// Returns the result of 'p' and the character range that 'p' consumed.
let internal getRange p =

Просмотреть файл

@ -34,6 +34,7 @@ let private buildCombinedExpr kind (lRange, rRange) =
/// operator precedence parser for Q# expressions
let private qsExpression = new OperatorPrecedenceParser<QsExpression, _, _>()
/// operator precedence parser for Q# call arguments
/// processing all expressions handled by the Q# expression parser as well as omitted arguments
let private qsArgument = new OperatorPrecedenceParser<QsExpression, _, _>()
@ -538,7 +539,7 @@ let private newArray =
let withWarning (expr: QsExpression) =
let range = expr.Range |> QsNullable.defaultValue Range.Zero
QsCompilerDiagnostic.Warning(WarningCode.DeprecatedNewArray, []) range |> pushDiagnostic >>% expr
QsCompilerDiagnostic.Warning (WarningCode.DeprecatedNewArray, []) range |> pushDiagnostic >>% expr
arrayDecl.parse
>>= fun headRange -> term body |>> toExpr headRange <|> (term invalid |>> fst)

Просмотреть файл

@ -179,8 +179,8 @@ let internal validateTypeSyntax isArrayItem { Type = kind; Range = range } =
// To avoid confusing syntax like "new Int -> Int[3]" or "Qubit => Unit is Adj[]", require that function and
// operation types are tupled when used as an array item type.
[
QsCompilerDiagnostic.Error(ErrorCode.MissingLTupleBracket, []) (Range.Create start start)
QsCompilerDiagnostic.Error(ErrorCode.MissingRTupleBracket, []) (Range.Create end' end')
QsCompilerDiagnostic.Error (ErrorCode.MissingLTupleBracket, []) (Range.Create start start)
QsCompilerDiagnostic.Error (ErrorCode.MissingRTupleBracket, []) (Range.Create end' end')
]
|> pushDiagnostics
| _ -> preturn ()

Просмотреть файл

@ -20,6 +20,7 @@ open Microsoft.Quantum.QsCompiler.TextProcessing.SyntaxExtensions
/// returns the current state of the char stream
let getCharStreamState (stream: CharStream<_>) = Reply stream.State
/// given a char stream state, returns the chars between that and the current stream position as string
let getSubstring (start: CharStreamState<_>) =
fun (stream: CharStream<_>) -> Reply(stream.ReadFrom(start, false))
@ -73,9 +74,11 @@ let internal qsReservedKeyword =
/// adds the given diagnostic to the user state
let internal pushDiagnostic newDiagnostic =
updateUserState (fun diagnostics -> newDiagnostic :: diagnostics)
/// adds the given diagnostics to the user state
let internal pushDiagnostics newDiagnostics =
updateUserState (fun diagnostics -> newDiagnostics @ diagnostics)
/// clears all diagnostics from the user state
let private clearDiagnostics = updateUserState (fun _ -> [])
@ -99,24 +102,31 @@ let internal buildWarning body wrnCode =
/// Parses a left tuple bracket "(".
/// IMPORTANT: Does *not* handle whitespace -> use in combination with "bracket" for proper whitespace handling!
let internal lTuple = pstring "("
/// Parses a right tuple bracket ")".
/// IMPORTANT: Does *not* handle whitespace -> use in combination with "bracket" for proper whitespace handling!
let internal rTuple = pstring ")"
/// Parses a left array bracket "[".
/// IMPORTANT: Does *not* handle whitespace -> use in combination with "bracket" for proper whitespace handling!
let internal lArray = pstring "["
/// Parses a right array bracket "]".
/// IMPORTANT: Does *not* handle whitespace -> use in combination with "bracket" for proper whitespace handling!
let internal rArray = pstring "]"
/// Parses a left angle bracket "<".
/// IMPORTANT: Does *not* handle whitespace -> use in combination with "bracket" for proper whitespace handling!
let internal lAngle = pstring "<"
/// Parses a right angle bracket ">".
/// IMPORTANT: Does *not* handle whitespace -> use in combination with "bracket" for proper whitespace handling!
let internal rAngle = pstring ">"
/// Parses a left curly bracket "{".
/// IMPORTANT: Does *not* handle whitespace -> use in combination with "bracket" for proper whitespace handling!
let internal lCurly = pstring "{"
/// Parses a right curly bracket "}".
/// IMPORTANT: Does *not* handle whitespace -> use in combination with "bracket" for proper whitespace handling!
let internal rCurly = pstring "}"
@ -543,7 +553,7 @@ let private filterAndAdapt (diagnostics: QsCompilerDiagnostic list) endPos =
let filteredExcessCont = excessCont |> List.filter (not << hasOverlap)
let rangeWithinFragment (range: Range) =
Range.Create(min endPos range.Start) (min endPos range.End)
Range.Create (min endPos range.Start) (min endPos range.End)
filteredExcessCont @ remainingDiagnostics
|> List.map (fun diagnostic -> { diagnostic with Range = rangeWithinFragment diagnostic.Range })

Просмотреть файл

@ -40,11 +40,11 @@ let private BuildUnknown text =
{
Kind = InvalidFragment
Range = range
Diagnostics = ImmutableArray.Create(QsCompilerDiagnostic.Error(InvalidFragment.ErrorCode, []) range)
Diagnostics = ImmutableArray.Create(QsCompilerDiagnostic.Error (InvalidFragment.ErrorCode, []) range)
Text = text
}
let range = GetDelimiters(getRange remainingText |>> snd) text
let range = GetDelimiters (getRange remainingText |>> snd) text
let unknownStatement = unknownFragment text range
unknownStatement, (unknownStatement.Range.End, "")

Просмотреть файл

@ -41,14 +41,15 @@ type ExitCode =
/// The results from running a command.
type internal RunResult =
{
/// The number of input source files processed.
FilesProcessed: int
/// The number of input source files processed.
FilesProcessed: int
/// The exit code.
ExitCode: ExitCode
/// The exit code.
ExitCode: ExitCode
/// The list of syntax errors encountered during the running of the command.
SyntaxErrors: Errors.SyntaxError list }
/// The list of syntax errors encountered during the running of the command.
SyntaxErrors: Errors.SyntaxError list
}
/// Returns a RunResult record with default field values.
static member Default: RunResult
@ -98,20 +99,21 @@ type internal IArguments =
/// Object for capturing the arguments used with the `format` command.
type FormatArguments =
{
/// Flag to indicate if the `--backup` option was specified.
Backup: bool
/// Flag to indicate if the `--backup` option was specified.
Backup: bool
/// Flag to indicate if the `--recurse` option was specified.
Recurse: bool
/// Flag to indicate if the `--recurse` option was specified.
Recurse: bool
/// Optional argument for the `--qsharp-version` option.
QdkVersion: string
/// Optional argument for the `--qsharp-version` option.
QdkVersion: string
/// The input files specified by the `--input` argument.
InputFiles: seq<string>
/// The input files specified by the `--input` argument.
InputFiles: seq<string>
/// The project file specified by the `--project` argument.
ProjectFile: string }
/// The project file specified by the `--project` argument.
ProjectFile: string
}
interface IArguments
/// Provides example usage.
@ -120,20 +122,21 @@ type FormatArguments =
/// Object for capturing the arguments used with the `update` command.
type UpdateArguments =
{
/// Flag to indicate if the `--backup` option was specified.
Backup: bool
/// Flag to indicate if the `--backup` option was specified.
Backup: bool
/// Flag to indicate if the `--recurse` option was specified.
Recurse: bool
/// Flag to indicate if the `--recurse` option was specified.
Recurse: bool
/// Optional argument for the `--qsharp-version` option.
QdkVersion: string
/// Optional argument for the `--qsharp-version` option.
QdkVersion: string
/// The input files specified by the `--input` argument.
InputFiles: seq<string>
/// The input files specified by the `--input` argument.
InputFiles: seq<string>
/// The project file specified by the `--project` argument.
ProjectFile: string }
/// The project file specified by the `--project` argument.
ProjectFile: string
}
interface IArguments
/// Provides example usage.
@ -142,20 +145,21 @@ type UpdateArguments =
/// Object for capturing the arguments used with the `update-and-format` command.
type UpdateAndFormatArguments =
{
/// Flag to indicate if the `--backup` option was specified.
Backup: bool
/// Flag to indicate if the `--backup` option was specified.
Backup: bool
/// Flag to indicate if the `--recurse` option was specified.
Recurse: bool
/// Flag to indicate if the `--recurse` option was specified.
Recurse: bool
/// Optional argument for the `--qsharp-version` option.
QdkVersion: string
/// Optional argument for the `--qsharp-version` option.
QdkVersion: string
/// The input files specified by the `--input` argument.
InputFiles: seq<string>
/// The input files specified by the `--input` argument.
InputFiles: seq<string>
/// The project file specified by the `--project` argument.
ProjectFile: string }
/// The project file specified by the `--project` argument.
ProjectFile: string
}
interface IArguments
/// Provides example usage.
@ -164,23 +168,24 @@ type UpdateAndFormatArguments =
/// Represents the fully parsed arguments to the tool.
type internal CommandWithOptions =
{
/// Indicates the command specified.
CommandKind: CommandKind
/// Indicates the command specified.
CommandKind: CommandKind
/// The input kind
InputKind: InputKind
/// The input kind
InputKind: InputKind
/// Flag to indicate if the `--recurse` option was specified.
RecurseFlag: bool
/// Flag to indicate if the `--recurse` option was specified.
RecurseFlag: bool
/// Flag to indicate if the `--backup` option was specified.
BackupFlag: bool
/// Flag to indicate if the `--backup` option was specified.
BackupFlag: bool
/// Optional Q# version specified.
QSharpVersion: Version option
/// Optional Q# version specified.
QSharpVersion: Version option
/// The paths to the files to process.
Input: string list }
/// The paths to the files to process.
Input: string list
}
/// Returns a CommandWithOptions record with default field values.
static member Default: CommandWithOptions

Просмотреть файл

@ -14,39 +14,40 @@ open Microsoft.Quantum.Telemetry
/// all of its properties will be made public too.
type ExecutionCompleted =
{
/// When the program execution was started.
StartTime: DateTime
/// When the program execution was started.
StartTime: DateTime
/// Which command was specified on the command-line.
Command: CommandKind option
/// Which command was specified on the command-line.
Command: CommandKind option
/// Which input kind was specified on the command-line.
InputKind: InputKind option
/// Which input kind was specified on the command-line.
InputKind: InputKind option
/// The value of the --recurse option specified on the command-line.
RecurseFlag: bool option
/// The value of the --recurse option specified on the command-line.
RecurseFlag: bool option
/// The value of the --backup option specified on the command-line.
BackupFlag: bool option
/// The value of the --backup option specified on the command-line.
BackupFlag: bool option
/// The value of the optional QDK version used.
QSharpVersion: string option
/// The value of the optional QDK version used.
QSharpVersion: string option
/// The unhandled exception, if one was thrown during the execution.
UnhandledException: Exception option
/// The unhandled exception, if one was thrown during the execution.
UnhandledException: Exception option
/// Any syntax errors encountered during the execution.
[<SerializeJson>]
SyntaxErrors: Errors.SyntaxError list option
/// Any syntax errors encountered during the execution.
[<SerializeJson>]
SyntaxErrors: Errors.SyntaxError list option
/// The total execution time of the program, not including sending the telemetry event.
ExecutionTime: TimeSpan
/// The total execution time of the program, not including sending the telemetry event.
ExecutionTime: TimeSpan
/// The number of Q# source files processed during execution.
FilesProcessed: int
/// The number of Q# source files processed during execution.
FilesProcessed: int
/// The final exit code of the program.
ExitCode: ExitCode }
/// The final exit code of the program.
ExitCode: ExitCode
}
/// Initializes the telemetry manager. This is required before logging telemetry.
val internal initializeTelemetry: string [] -> IDisposable

Просмотреть файл

@ -8,11 +8,12 @@ namespace Microsoft.Quantum.QsFmt.Formatter.SyntaxTree
/// to call the callable.
type internal Identifier =
{
/// The name of the identifier
Name: Terminal
/// The name of the identifier
Name: Terminal
/// Optional type arguments
TypeArgs: Type Tuple Option }
/// Optional type arguments
TypeArgs: Type Tuple Option
}
/// A binding for one or more new symbols.
type internal SymbolBinding =
@ -31,18 +32,19 @@ module internal SymbolBinding =
/// An escaped expression in an interpolated string
type internal InterpStringExpression =
{
/// <summary>
/// The <c>{</c> symbol.
/// </summary>
OpenBrace: Terminal
/// <summary>
/// The <c>{</c> symbol.
/// </summary>
OpenBrace: Terminal
/// The escaped expression
Expression: Expression
/// The escaped expression
Expression: Expression
/// <summary>
/// The <c>}</c> symbol.
/// </summary>
CloseBrace: Terminal }
/// <summary>
/// The <c>}</c> symbol.
/// </summary>
CloseBrace: Terminal
}
and internal InterpStringContent =
/// A literal.
@ -54,172 +56,181 @@ and internal InterpStringContent =
/// An interpolated string
and internal InterpString =
{
/// <summary>
/// The <c>"</c> symbol.
/// </summary>
OpenQuote: Terminal
/// <summary>
/// The <c>"</c> symbol.
/// </summary>
OpenQuote: Terminal
/// The content of the interpolated string
Content: InterpStringContent list
/// The content of the interpolated string
Content: InterpStringContent list
/// <summary>
/// The <c>"</c> symbol.
/// </summary>
CloseQuote: Terminal }
/// <summary>
/// The <c>"</c> symbol.
/// </summary>
CloseQuote: Terminal
}
/// A new array expression.
and internal NewArray =
{
/// The `new` keyword.
New: Terminal
/// The `new` keyword.
New: Terminal
/// The type of the created array.
ItemType: Type
/// The type of the created array.
ItemType: Type
/// <summary>
/// The <c>[</c> symbol.
/// </summary>
OpenBracket: Terminal
/// <summary>
/// The <c>[</c> symbol.
/// </summary>
OpenBracket: Terminal
/// The length of the created array.
Length: Expression
/// The length of the created array.
Length: Expression
/// <summary>
/// The <c>]</c> symbol.
/// </summary>
CloseBracket: Terminal }
/// <summary>
/// The <c>]</c> symbol.
/// </summary>
CloseBracket: Terminal
}
/// A new array expression with a size.
and internal NewSizedArray =
{
/// <summary>
/// The <c>[</c> symbol.
/// </summary>
OpenBracket: Terminal
/// <summary>
/// The <c>[</c> symbol.
/// </summary>
OpenBracket: Terminal
// The value at each index of the array.
Value: Expression
// The value at each index of the array.
Value: Expression
/// <summary>
/// The <c>,</c> symbol.
/// </summary>
Comma: Terminal
/// <summary>
/// The <c>,</c> symbol.
/// </summary>
Comma: Terminal
/// <summary>
/// The <c>size</c> keyword.
/// </summary>
Size: Terminal
/// <summary>
/// The <c>size</c> keyword.
/// </summary>
Size: Terminal
/// <summary>
/// The <c>=</c> symbol.
/// </summary>
Equals: Terminal
/// <summary>
/// The <c>=</c> symbol.
/// </summary>
Equals: Terminal
/// The length of the created array.
Length: Expression
/// The length of the created array.
Length: Expression
/// <summary>
/// The <c>]</c> symbol.
/// </summary>
CloseBracket: Terminal }
/// <summary>
/// The <c>]</c> symbol.
/// </summary>
CloseBracket: Terminal
}
/// A named-item-access expression.
and internal NamedItemAccess =
{
/// The accessing object
Record: Expression
/// The accessing object
Record: Expression
/// <summary>
/// The <c>::</c> symbol.
/// </summary>
DoubleColon: Terminal
/// <summary>
/// The <c>::</c> symbol.
/// </summary>
DoubleColon: Terminal
/// The accessed item name
Name: Terminal }
/// The accessed item name
Name: Terminal
}
/// An array-item-access expression.
and internal ArrayAccess =
{
/// The array
Array: Expression
/// The array
Array: Expression
/// <summary>
/// The <c>[</c> symbol.
/// </summary>
OpenBracket: Terminal
/// <summary>
/// The <c>[</c> symbol.
/// </summary>
OpenBracket: Terminal
/// The index of the accessed item.
Index: Expression
/// The index of the accessed item.
Index: Expression
/// <summary>
/// The <c>]</c> symbol.
/// </summary>
CloseBracket: Terminal }
/// <summary>
/// The <c>]</c> symbol.
/// </summary>
CloseBracket: Terminal
}
/// A callable-call expression.
and internal Call =
{
/// The callable being called.
Callable: Expression
/// The callable being called.
Callable: Expression
/// The argument list of the callable call.
Arguments: Expression Tuple }
/// The argument list of the callable call.
Arguments: Expression Tuple
}
/// A conditional expression.
and internal Conditional =
{
/// The condition.
Condition: Expression
/// The condition.
Condition: Expression
/// <summary>
/// The <c>?</c> symbol.
/// </summary>
Question: Terminal
/// <summary>
/// The <c>?</c> symbol.
/// </summary>
Question: Terminal
/// The expression value if the condition is true.
IfTrue: Expression
/// The expression value if the condition is true.
IfTrue: Expression
/// <summary>
/// The <c>|</c> symbol.
/// </summary>
Pipe: Terminal
/// <summary>
/// The <c>|</c> symbol.
/// </summary>
Pipe: Terminal
/// The expression value if the condition is false.
IfFalse: Expression }
/// The expression value if the condition is false.
IfFalse: Expression
}
/// A copy-and-update expression.
and internal Update =
{
/// The record to update.
Record: Expression
/// The record to update.
Record: Expression
/// <summary>
/// The <c>w/</c> symbol.
/// </summary>
With: Terminal
/// <summary>
/// The <c>w/</c> symbol.
/// </summary>
With: Terminal
/// The item to update.
Item: Expression
/// The item to update.
Item: Expression
/// The left arrow symbol.
Arrow: Terminal
/// The left arrow symbol.
Arrow: Terminal
/// The value to assign to the item.
Value: Expression }
/// The value to assign to the item.
Value: Expression
}
/// A lambda expression.
and internal Lambda =
{
/// The binding for the lambda's parameter.
Binding: SymbolBinding
/// The binding for the lambda's parameter.
Binding: SymbolBinding
/// <summary>
/// The right arrow symbol (either <c>-&gt;</c> or <c>=&gt;</c>).
/// </summary>
Arrow: Terminal
/// <summary>
/// The right arrow symbol (either <c>-&gt;</c> or <c>=&gt;</c>).
/// </summary>
Arrow: Terminal
/// The lambda body.
Body: Expression }
/// The lambda body.
Body: Expression
}
/// An expression.
and internal Expression =

Просмотреть файл

@ -6,23 +6,25 @@ namespace Microsoft.Quantum.QsFmt.Formatter.SyntaxTree
/// An attribute.
type internal Attribute =
{
/// The at symbol prefix.
At: Terminal
/// The at symbol prefix.
At: Terminal
/// The attribute expression.
Expression: Expression }
/// The attribute expression.
Expression: Expression
}
/// A type parameter binding sequence.
type internal TypeParameterBinding =
{
/// The opening angle bracket.
OpenBracket: Terminal
/// The opening angle bracket.
OpenBracket: Terminal
/// The type parameters.
Parameters: Terminal SequenceItem list
/// The type parameters.
Parameters: Terminal SequenceItem list
/// The closing angle bracket.
CloseBracket: Terminal }
/// The closing angle bracket.
CloseBracket: Terminal
}
/// A specialization generator.
type internal SpecializationGenerator =
@ -35,33 +37,35 @@ type internal SpecializationGenerator =
/// A specialization.
type internal Specialization =
{
/// The names of the specialization.
Names: Terminal list
/// The names of the specialization.
Names: Terminal list
/// The specialization generator.
Generator: SpecializationGenerator }
/// The specialization generator.
Generator: SpecializationGenerator
}
/// An open directive
type internal OpenDirective =
{
/// <summary>
/// The <c>open</c> keyword.
/// </summary>
OpenKeyword: Terminal
/// <summary>
/// The <c>open</c> keyword.
/// </summary>
OpenKeyword: Terminal
/// The name of the opened namespace.
OpenName: Terminal
/// The name of the opened namespace.
OpenName: Terminal
/// <summary>
/// The optional <c>as</c> keyword.
/// </summary>
AsKeyword: Terminal option
/// <summary>
/// The optional <c>as</c> keyword.
/// </summary>
AsKeyword: Terminal option
/// The alias name of the opened namespace.
AsName: Terminal option
/// The alias name of the opened namespace.
AsName: Terminal option
/// The semicolon.
Semicolon: Terminal }
/// The semicolon.
Semicolon: Terminal
}
/// The underlying type of a newly defined type.
type internal UnderlyingType =
@ -82,30 +86,31 @@ and internal TypeTupleItem =
/// A type declaration
type internal TypeDeclaration =
{
/// The attributes attached to the type declaration.
Attributes: Attribute list
/// The attributes attached to the type declaration.
Attributes: Attribute list
/// The access modifier for the callable.
Access: Terminal option
/// The access modifier for the callable.
Access: Terminal option
/// <summary>
/// The <c>newtype</c> keyword.
/// </summary>
NewtypeKeyword: Terminal
/// <summary>
/// The <c>newtype</c> keyword.
/// </summary>
NewtypeKeyword: Terminal
/// The name of the declared type.
DeclaredType: Terminal
/// The name of the declared type.
DeclaredType: Terminal
/// <summary>
/// The <c>=</c> symbol.
/// </summary>
Equals: Terminal
/// <summary>
/// The <c>=</c> symbol.
/// </summary>
Equals: Terminal
/// The underlying type.
UnderlyingType: UnderlyingType
/// The underlying type.
UnderlyingType: UnderlyingType
/// The semicolon.
Semicolon: Terminal }
/// The semicolon.
Semicolon: Terminal
}
/// The body of a callable declaration.
type internal CallableBody =
@ -115,38 +120,39 @@ type internal CallableBody =
/// A block of specializations.
| Specializations of Specialization Block
/// A callable declaration.
// TODO: Add specialization generators.
/// A callable declaration.
type internal CallableDeclaration =
{
/// The attributes attached to the callable.
Attributes: Attribute list
/// The attributes attached to the callable.
Attributes: Attribute list
/// The access modifier for the callable.
Access: Terminal option
/// The access modifier for the callable.
Access: Terminal option
/// <summary>
/// The declaration keyword (either <c>function</c> or <c>operation</c>).
/// </summary>
CallableKeyword: Terminal
/// <summary>
/// The declaration keyword (either <c>function</c> or <c>operation</c>).
/// </summary>
CallableKeyword: Terminal
/// The name of the callable.
Name: Terminal
/// The name of the callable.
Name: Terminal
/// The type parameters of the callable.
TypeParameters: TypeParameterBinding option
/// The type parameters of the callable.
TypeParameters: TypeParameterBinding option
/// The parameters of the callable.
Parameters: ParameterBinding
/// The parameters of the callable.
Parameters: ParameterBinding
/// The return type of the callable.
ReturnType: TypeAnnotation
/// The return type of the callable.
ReturnType: TypeAnnotation
/// The characteristic section of the callable.
CharacteristicSection: CharacteristicSection option
/// The characteristic section of the callable.
CharacteristicSection: CharacteristicSection option
/// The body of the callable.
Body: CallableBody }
/// The body of the callable.
Body: CallableBody
}
/// An item in a namespace.
type internal NamespaceItem =
@ -171,22 +177,24 @@ module internal NamespaceItem =
/// A namespace.
type internal Namespace =
{
/// <summary>
/// The <c>namespace</c> keyword.
/// </summary>
NamespaceKeyword: Terminal
/// <summary>
/// The <c>namespace</c> keyword.
/// </summary>
NamespaceKeyword: Terminal
/// The name of the namespace.
Name: Terminal
/// The name of the namespace.
Name: Terminal
/// The body of the namespace.
Block: NamespaceItem Block }
/// The body of the namespace.
Block: NamespaceItem Block
}
/// A document representing a Q# file.
type internal Document =
{
/// The namespaces in the document.
Namespaces: Namespace list
/// The namespaces in the document.
Namespaces: Namespace list
/// The end-of-file symbol.
Eof: Terminal }
/// The end-of-file symbol.
Eof: Terminal
}

Просмотреть файл

@ -52,11 +52,12 @@ module internal Trivia =
/// A terminal symbol has no child nodes and represents a token in the source code.
type internal Terminal =
{
/// The trivia preceding the terminal.
Prefix: Trivia list
/// The trivia preceding the terminal.
Prefix: Trivia list
/// The text content of the terminal.
Text: string }
/// The text content of the terminal.
Text: string
}
module internal Terminal =
/// <summary>
@ -67,23 +68,25 @@ module internal Terminal =
/// An item in a comma-separated sequence.
type internal 'a SequenceItem =
{
/// The item.
Item: 'a option
/// The item.
Item: 'a option
/// The comma following the item.
Comma: Terminal option }
/// The comma following the item.
Comma: Terminal option
}
/// A tuple.
type internal 'a Tuple =
{
/// The opening parenthesis.
OpenParen: Terminal
/// The opening parenthesis.
OpenParen: Terminal
/// The items in the tuple.
Items: 'a SequenceItem list
/// The items in the tuple.
Items: 'a SequenceItem list
/// The closing parenthesis.
CloseParen: Terminal }
/// The closing parenthesis.
CloseParen: Terminal
}
module internal Tuple =
/// <summary>
@ -94,44 +97,48 @@ module internal Tuple =
/// A prefix operator. The operator is in the front of the operand.
type internal 'a PrefixOperator =
{
/// The operator.
PrefixOperator: Terminal
/// The operator.
PrefixOperator: Terminal
/// The operand.
Operand: 'a }
/// The operand.
Operand: 'a
}
/// A prefix operator. The operator is after the operand.
type internal 'a PostfixOperator =
{
/// The operand.
Operand: 'a
/// The operand.
Operand: 'a
/// The operator.
PostfixOperator: Terminal }
/// The operator.
PostfixOperator: Terminal
}
/// An infix operator.
type internal 'a InfixOperator =
{
/// The left-hand side.
Left: 'a
/// The left-hand side.
Left: 'a
/// The operator.
InfixOperator: Terminal
/// The operator.
InfixOperator: Terminal
/// The right-hand side.
Right: 'a }
/// The right-hand side.
Right: 'a
}
/// A block.
type internal 'a Block =
{
/// The opening brace.
OpenBrace: Terminal
/// The opening brace.
OpenBrace: Terminal
/// The items in the block.
Items: 'a list
/// The items in the block.
Items: 'a list
/// The closing brace.
CloseBrace: Terminal }
/// The closing brace.
CloseBrace: Terminal
}
module internal Block =
/// <summary>

Просмотреть файл

@ -6,11 +6,12 @@ namespace Microsoft.Quantum.QsFmt.Formatter.SyntaxTree
/// A declaration for a new parameter.
type internal ParameterDeclaration =
{
/// The name of the parameter.
Name: Terminal
/// The name of the parameter.
Name: Terminal
/// The type of the parameter.
Type: TypeAnnotation }
/// The type of the parameter.
Type: TypeAnnotation
}
/// A binding for one or more new parameters.
type internal ParameterBinding =
@ -23,33 +24,35 @@ type internal ParameterBinding =
/// Initializer for a single qubit.
type internal SingleQubit =
{
/// <summary>
/// The <c>Qubit</c> type.
/// </summary>
Qubit: Terminal
/// <summary>
/// The <c>Qubit</c> type.
/// </summary>
Qubit: Terminal
/// The opening parenthesis.
OpenParen: Terminal
/// The opening parenthesis.
OpenParen: Terminal
/// The closing parenthesis.
CloseParen: Terminal }
/// The closing parenthesis.
CloseParen: Terminal
}
/// Initializer for an array of qubits.
type internal QubitArray =
{
/// <summary>
/// The <c>Qubit</c> type.
/// </summary>
Qubit: Terminal
/// <summary>
/// The <c>Qubit</c> type.
/// </summary>
Qubit: Terminal
/// The opening bracket.
OpenBracket: Terminal
/// The opening bracket.
OpenBracket: Terminal
/// The length of the created array.
Length: Expression
/// The length of the created array.
Length: Expression
/// The closing bracket.
CloseBracket: Terminal }
/// The closing bracket.
CloseBracket: Terminal
}
/// An initializer for one or more qubits.
type internal QubitInitializer =
@ -65,14 +68,15 @@ type internal QubitInitializer =
/// A qubit binding statement.
type internal QubitBinding =
{
/// The symbol binding.
Name: SymbolBinding
/// The symbol binding.
Name: SymbolBinding
/// The equals symbol.
Equals: Terminal
/// The equals symbol.
Equals: Terminal
/// The qubit initializer.
Initializer: QubitInitializer }
/// The qubit initializer.
Initializer: QubitInitializer
}
module internal QubitBinding =
/// <summary>
@ -96,14 +100,15 @@ type internal QubitDeclarationKind =
/// The binding for a for-loop variable.
type internal ForBinding =
{
/// The symbol binding.
Name: SymbolBinding
/// The symbol binding.
Name: SymbolBinding
/// The <c>in</c> keyword.
In: Terminal
/// The <c>in</c> keyword.
In: Terminal
/// The value of the symbol binding.
Value: Expression }
/// The value of the symbol binding.
Value: Expression
}
module internal ForBinding =
/// <summary>
@ -116,41 +121,44 @@ module internal ForBinding =
/// </summary>
type internal ExpressionStatement =
{
/// The inner expression of the statement.
Expression: Expression
/// The inner expression of the statement.
Expression: Expression
/// The semicolon.
Semicolon: Terminal }
/// The semicolon.
Semicolon: Terminal
}
/// A simple statement consisting of just a keyword, an expression, and a semicolon.
type internal SimpleStatement =
{
/// The keyword for the statement.
Keyword: Terminal
/// The keyword for the statement.
Keyword: Terminal
/// The returned expression.
Expression: Expression
/// The returned expression.
Expression: Expression
/// The semicolon.
Semicolon: Terminal }
/// The semicolon.
Semicolon: Terminal
}
/// A statement used to bind a value to a symbol.
type internal BindingStatement =
{
/// The keyword for the statement.
Keyword: Terminal
/// The keyword for the statement.
Keyword: Terminal
/// The symbol binding.
Binding: SymbolBinding
/// The symbol binding.
Binding: SymbolBinding
/// The equals symbol.
Equals: Terminal
/// The equals symbol.
Equals: Terminal
/// The value of the symbol binding.
Value: Expression
/// The value of the symbol binding.
Value: Expression
/// The semicolon.
Semicolon: Terminal }
/// The semicolon.
Semicolon: Terminal
}
/// <summary>
/// An <c>update</c> statement, also known as an evaluate-and-reassign statement.
@ -158,96 +166,101 @@ type internal BindingStatement =
/// </summary>
type internal UpdateStatement =
{
/// <summary>
/// The <c>set</c> keyword.
/// </summary>
SetKeyword: Terminal
/// <summary>
/// The <c>set</c> keyword.
/// </summary>
SetKeyword: Terminal
/// The identifier being updated.
Name: Terminal
/// The identifier being updated.
Name: Terminal
/// The update operator, e.g. <c>+=</c>.
Operator: Terminal
/// The update operator, e.g. <c>+=</c>.
Operator: Terminal
/// The value used as the left-hand side of the update operator.
Value: Expression
/// The value used as the left-hand side of the update operator.
Value: Expression
/// The semicolon.
Semicolon: Terminal }
/// The semicolon.
Semicolon: Terminal
}
/// <summary>
/// A <c>set w/=</c> statement, also known as an evaluate-and-reassign statement.
/// </summary>
type internal UpdateWithStatement =
{
/// <summary>
/// The <c>set</c> keyword.
/// </summary>
SetKeyword: Terminal
/// <summary>
/// The <c>set</c> keyword.
/// </summary>
SetKeyword: Terminal
/// The identifier being updated.
Name: Terminal
/// The identifier being updated.
Name: Terminal
/// <summary>
/// The <c>w/=</c> operator.
/// </summary>
With: Terminal
/// <summary>
/// The <c>w/=</c> operator.
/// </summary>
With: Terminal
/// The expression for the index that is updated.
Item: Expression
/// The expression for the index that is updated.
Item: Expression
/// The left arrow symbol.
Arrow: Terminal
/// The left arrow symbol.
Arrow: Terminal
/// The value used as the left-hand side of the update operator.
Value: Expression
/// The value used as the left-hand side of the update operator.
Value: Expression
/// The semicolon.
Semicolon: Terminal }
/// The semicolon.
Semicolon: Terminal
}
/// A statement consisting of a keyword, a condition, and a block.
type internal ConditionalBlockStatement =
{
/// The keyword for the statement.
Keyword: Terminal
/// The keyword for the statement.
Keyword: Terminal
/// The condition under which to execute the block.
Condition: Expression
/// The condition under which to execute the block.
Condition: Expression
/// The conditional block.
Block: Statement Block }
/// The conditional block.
Block: Statement Block
}
/// A statement consisting of a keyword and a block.
and internal BlockStatement =
{
/// The keyword for the statement.
Keyword: Terminal
/// The keyword for the statement.
Keyword: Terminal
/// The block.
Block: Statement Block }
/// The block.
Block: Statement Block
}
/// <summary>
/// A <c>for</c> statement.
/// </summary>
and internal ForStatement =
{
/// <summary>
/// The <c>for</c> keyword.
/// </summary>
ForKeyword: Terminal
/// <summary>
/// The <c>for</c> keyword.
/// </summary>
ForKeyword: Terminal
/// The optional open parenthesis.
OpenParen: Terminal option
/// The optional open parenthesis.
OpenParen: Terminal option
/// The binding for loop variable.
Binding: ForBinding
/// The binding for loop variable.
Binding: ForBinding
/// The optional close parenthesis.
CloseParen: Terminal option
/// The optional close parenthesis.
CloseParen: Terminal option
/// The loop body.
Block: Statement Block }
/// The loop body.
Block: Statement Block
}
/// <summary>
/// The concluding section of an <c>until</c> statement.
@ -267,20 +280,21 @@ and internal UntilStatementCoda =
/// </summary>
and internal UntilStatement =
{
/// <summary>
/// The <c>until</c> keyword.
/// </summary>
UntilKeyword: Terminal
/// <summary>
/// The <c>until</c> keyword.
/// </summary>
UntilKeyword: Terminal
/// <summary>
/// The condition under which to exit the preceding <c>repeat</c> block.
/// </summary>
Condition: Expression
/// <summary>
/// The condition under which to exit the preceding <c>repeat</c> block.
/// </summary>
Condition: Expression
/// <summary>
/// The concluding section, possibly containing a <c>fixup</c> block.
/// </summary>
Coda: UntilStatementCoda }
/// <summary>
/// The concluding section, possibly containing a <c>fixup</c> block.
/// </summary>
Coda: UntilStatementCoda
}
/// The concluding section of a qubit declaration.
and internal QubitDeclarationStatementCoda =
@ -294,23 +308,24 @@ and internal QubitDeclarationStatementCoda =
/// A qubit declaration statement.
and internal QubitDeclarationStatement =
{
/// The kind of qubit declaration.
Kind: QubitDeclarationKind
/// The kind of qubit declaration.
Kind: QubitDeclarationKind
/// The keyword used in the declaration.
Keyword: Terminal
/// The keyword used in the declaration.
Keyword: Terminal
/// Optional open parentheses.
OpenParen: Terminal option
/// Optional open parentheses.
OpenParen: Terminal option
/// The qubit binding.
Binding: QubitBinding
/// The qubit binding.
Binding: QubitBinding
/// Optional close parentheses.
CloseParen: Terminal option
/// Optional close parentheses.
CloseParen: Terminal option
/// The concluding section.
Coda: QubitDeclarationStatementCoda }
/// The concluding section.
Coda: QubitDeclarationStatementCoda
}
/// A statement.
and internal Statement =

Просмотреть файл

@ -6,14 +6,15 @@ namespace Microsoft.Quantum.QsFmt.Formatter.SyntaxTree
/// A parenthesized characteristic.
type internal CharacteristicGroup =
{
/// The opening parenthesis.
OpenParen: Terminal
/// The opening parenthesis.
OpenParen: Terminal
/// The characteristic.
Characteristic: Characteristic
/// The characteristic.
Characteristic: Characteristic
/// The closing parenthesis.
CloseParen: Terminal }
/// The closing parenthesis.
CloseParen: Terminal
}
/// A callable characteristic.
and internal Characteristic =
@ -32,40 +33,43 @@ and internal Characteristic =
/// A section attached to a callable type or declaration describing its characteristics.
type internal CharacteristicSection =
{
/// <summary>
/// The <c>is</c> keyword.
/// </summary>
IsKeyword: Terminal
/// <summary>
/// The <c>is</c> keyword.
/// </summary>
IsKeyword: Terminal
/// The characteristic.
Characteristic: Characteristic }
/// The characteristic.
Characteristic: Characteristic
}
/// An array type.
and internal ArrayType =
{
/// The type of items in the array.
ItemType: Type
/// The type of items in the array.
ItemType: Type
/// The opening bracket.
OpenBracket: Terminal
/// The opening bracket.
OpenBracket: Terminal
/// The closing bracket.
CloseBracket: Terminal }
/// The closing bracket.
CloseBracket: Terminal
}
/// A callable type.
and internal CallableType =
{
/// The input type.
FromType: Type
/// The input type.
FromType: Type
/// The arrow separating input and output types.
Arrow: Terminal
/// The arrow separating input and output types.
Arrow: Terminal
/// The output type.
ToType: Type
/// The output type.
ToType: Type
/// The characteristics.
Characteristics: CharacteristicSection option }
/// The characteristics.
Characteristics: CharacteristicSection option
}
/// A type.
and internal Type =
@ -96,8 +100,9 @@ and internal Type =
/// A type annotation attached to a binding.
type internal TypeAnnotation =
{
/// The colon between the binding and the type.
Colon: Terminal
/// The colon between the binding and the type.
Colon: Terminal
/// The type of the binding.
Type: Type }
/// The type of the binding.
Type: Type
}