Movatterモバイル変換


[0]ホーム

URL:


Header menu logoF# Compiler Guide

Compiler Services: Processing SyntaxTree

This tutorial demonstrates how to get the SyntaxTree (AST)for F# code and how to walk over the tree. This can be used for creating toolssuch as code formatter, basic refactoring or code navigation tools. The untypedsyntax tree contains information about the code structure, but does not containtypes and there are some ambiguities that are resolved only later by the typechecker. You can also combine the SyntaxTree information with the API availablefromeditor services.

NOTE: The FSharp.Compiler.Service API is subject to change when later versions of the nuget package are published

Getting the SyntaxTree

To access the untyped AST, you need to create an instance ofFSharpChecker.This type represents a context for type checking and parsing and corresponds eitherto a stand-alone F# script file (e.g. opened in Visual Studio) or to a loaded projectfile with multiple files. Once you have an instance ofFSharpChecker, you canuse it to perform "untyped parse" which is the first step of type-checking. Thesecond phase is "typed parse" and is used byeditor services.

To use the interactive checker, referenceFSharp.Compiler.Service.dll and open theSourceCodeServices namespace:

#r"FSharp.Compiler.Service.dll"openSystemopenFSharp.Compiler.CodeAnalysisopenFSharp.Compiler.Text

Performing untyped parse

The untyped parse operation is very fast (compared to type checking, which cantake notable amount of time) and so we can perform it synchronously. First, weneed to createFSharpChecker - the constructor takes an argument thatcan be used to notify the checker about file changes (which we ignore).

// Create an interactive checker instanceletchecker=FSharpChecker.Create()

To get the AST, we define a function that takes file name and the source code(the file is only used for location information and does not have to exist).We first need to get "interactive checker options" which represents the context.For simple tasks, you can useGetProjectOptionsFromScriptRoot which infersthe context for a script file. Then we use theParseFile method andreturn theParseTree property:

/// Get untyped tree for a specified inputletgetUntypedTree(file,input)=// Get compiler options for the 'project' implied by a single script fileletprojOptions,diagnostics=checker.GetProjectOptionsFromScript(file,input,assumeDotNetFramework=false)|>Async.RunSynchronouslyletparsingOptions,_errors=checker.GetParsingOptionsFromProjectOptions(projOptions)// Run the first phase (untyped parsing) of the compilerletparseFileResults=checker.ParseFile(file,input,parsingOptions)|>Async.RunSynchronouslyparseFileResults.ParseTree

Walking over the AST

The abstract syntax tree is defined as a number of discriminated unions that representdifferent syntactical elements (such as expressions, patterns, declarations etc.). The bestway to understand the AST is to look at the definitions inSyntaxTree.fsiin the source code.

The relevant parts are in the following namespace:

openFSharp.Compiler.Syntax

When processing the AST, you will typically write a number of mutually recursive functionsthat pattern match on the different syntactical elements. There is a number of elementsthat need to be supported - the top-level element is module or namespace declaration,containing declarations inside a module (let bindings, types etc.). A let declaration insidea module then contains expressions, which can contain patterns.

Walking over patterns and expressions

We start by looking at functions that walk over expressions and patterns - as we walk,we print information about the visited elements. For patterns, the input is of typeSynPat and has a number of cases includingWild (for_ pattern),Named (for<pat> as name) andLongIdent (for aFoo.Bar name). Note that the parsed patternis occasionally more complex than what is in the source code (in particular,Named isused more often):

/// Walk over a pattern - this is for example used in/// let <pat> = <expr> or in the 'match' expressionletrecvisitPattern=function|SynPat.Wild_->printfn"  .. underscore pattern"|SynPat.Named(ident=SynIdent(ident=name))->printfn"  .. named as '%s'"name.idText|SynPat.LongIdent(longDotId=SynLongIdent(id=ident))->letnames=String.concat"."[foriinident->i.idText]printfn"  .. identifier:%s"names|pat->printfn"  .. other pattern:%A"pat

The function is recursive (for nested patterns such as(foo, _) as bar), but it does notcall any of the functions defined later (because patterns cannot contain other syntacticalelements).

The next function iterates over expressions - this is where most of the work would be andthere are around 20 cases to cover (typeSynExpr. and you'll get completion with otheroptions). In the following, we only show how to handleif .. then .. andlet .. = ...:

/// Walk over an expression - if expression contains two or three/// sub-expressions (two if the 'else' branch is missing), let expression/// contains pattern and two sub-expressionsletrecvisitExpressione=matchewith|SynExpr.IfThenElse(ifExpr=cond;thenExpr=trueBranch;elseExpr=falseBranchOpt)->// Visit all sub-expressionsprintfn"Conditional:"visitExpressioncondvisitExpressiontrueBranchfalseBranchOpt|>Option.itervisitExpression|SynExpr.LetOrUse(_,_,bindings,body,_,_)->// Visit bindings (there may be multiple// for 'let .. = .. and .. = .. in ...'printfn"LetOrUse with the following bindings:"forbindinginbindingsdolet(SynBinding(headPat=headPat;expr=init))=bindingvisitPatternheadPatvisitExpressioninit// Visit the body expressionprintfn"And the following body:"visitExpressionbody|expr->printfn" - not supported expression:%A"expr

ThevisitExpression function will be called from a function that visits all top-leveldeclarations inside a module. In this tutorial, we ignore types and members, but that wouldbe another source of calls tovisitExpression.

Walking over declarations

As mentioned earlier, the AST of a file contains a number of module or namespace declarations(top-level node) that contain declarations inside a module (let bindings or types) or insidea namespace (just types). The following function walks over declarations - we ignore types,nested modules and all other elements and look only at top-levellet bindings (values andfunctions):

/// Walk over a list of declarations in a module. This is anything/// that you can write as a top-level inside module (let bindings,/// nested modules, type declarations etc.)letvisitDeclarationsdecls=fordeclarationindeclsdomatchdeclarationwith|SynModuleDecl.Let(isRec,bindings,range)->// Let binding as a declaration is similar to let binding// as an expression (in visitExpression), but has no bodyforbindinginbindingsdolet(SynBinding(headPat=pat;expr=body))=bindingvisitPatternpatvisitExpressionbody|_->printfn" - not supported declaration:%A"declaration

ThevisitDeclarations function will be called from a function that walks over asequence of module or namespace declarations. This corresponds, for example, to a filewith multiplenamespace Foo declarations:

/// Walk over all module or namespace declarations/// (basically 'module Foo =' or 'namespace Foo.Bar')/// Note that there is one implicitly, even if the file/// does not explicitly define it..letvisitModulesAndNamespacesmodulesOrNss=formoduleOrNsinmodulesOrNssdolet(SynModuleOrNamespace(longId=lid;decls=decls))=moduleOrNsprintfn"Namespace or module:%A"lidvisitDeclarationsdecls

Now that we have functions that walk over the elements of the AST (starting from declaration,down to expressions and patterns), we can get AST of a sample input and run the above function.

Putting things together

As already discussed, thegetUntypedTree function usesFSharpChecker to run the firstphase (parsing) on the AST and get back the tree. The function requires F# source code togetherwith location of the file. The location does not have to exist (it is used only for locationinformation) and it can be in both Unix and Windows formats:

// Sample input for the compiler serviceletinput="""  let foo() =    let msg = "Hello world"    if true then      printfn "%s" msg  """// File name in Unix formatletfile="/home/user/Test.fsx"// Get the AST of sample F# codelettree=getUntypedTree(file,SourceText.ofStringinput)

When you run the code in F# interactive, you can entertree;; in the interactive console andsee a pretty printed representation of the data structure - the tree contains a lot of information,so this is not particularly readable, but it gives you a good idea about how the tree looks.

The returnedtree value is again a discriminated union that can be two different cases - one caseisParsedInput.SigFile which represents F# signature file (*.fsi) and the other one isParsedInput.ImplFile representing regular source code (*.fsx or*.fs). The implementationfile contains a sequence of modules or namespaces that we can pass to the function implementedin the previous step:

// Extract implementation file detailsmatchtreewith|ParsedInput.ImplFile(implFile)->// Extract declarations and walk over themlet(ParsedImplFileInput(contents=modules))=implFilevisitModulesAndNamespacesmodules|_->failwith"F# Interface file (*.fsi) not supported."

Summary

In this tutorial, we looked at the basics of working with the untyped abstract syntax tree. This is acomprehensive topic, so it is not possible to explain everything in a single article. TheFantomas project is a good example of a tool based on the untypedAST that can help you understand more. In practice, it is also useful to combine the information herewith some information you can obtain from theeditor services discussed in the nexttutorial.

namespace System
Multiple items
namespace FSharp

--------------------
namespace Microsoft.FSharp
namespace FSharp.Compiler
namespace FSharp.Compiler.CodeAnalysis
namespace FSharp.Compiler.Text
val checker: FSharpChecker
type FSharpChecker = member CheckFileInProject: parseResults: FSharpParseFileResults * fileName: string * fileVersion: int * sourceText: ISourceText * options: FSharpProjectOptions * ?userOpName: string -> Async<FSharpCheckFileAnswer> member ClearCache: options: FSharpProjectOptions seq * ?userOpName: string -> unit + 1 overload member ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients: unit -> unit member Compile: argv: string array * ?userOpName: string -> Async<FSharpDiagnostic array * exn option> member FindBackgroundReferencesInFile: fileName: string * options: FSharpProjectOptions * symbol: FSharpSymbol * ?canInvalidateProject: bool * [<Experimental ("This FCS API is experimental and subject to change.")>] ?fastCheck: bool * ?userOpName: string -> Async<range seq> + 1 overload member GetBackgroundCheckResultsForFileInProject: fileName: string * options: FSharpProjectOptions * ?userOpName: string -> Async<FSharpParseFileResults * FSharpCheckFileResults> member GetBackgroundParseResultsForFileInProject: fileName: string * options: FSharpProjectOptions * ?userOpName: string -> Async<FSharpParseFileResults> member GetBackgroundSemanticClassificationForFile: fileName: string * options: FSharpProjectOptions * ?userOpName: string -> Async<SemanticClassificationView option> + 1 overload member GetParsingOptionsFromCommandLineArgs: sourceFiles: string list * argv: string list * ?isInteractive: bool * ?isEditing: bool -> FSharpParsingOptions * FSharpDiagnostic list + 1 overload member GetParsingOptionsFromProjectOptions: options: FSharpProjectOptions -> FSharpParsingOptions * FSharpDiagnostic list ...
<summary> Used to parse and check F# source code.</summary>
static member FSharpChecker.Create: ?projectCacheSize: int * ?keepAssemblyContents: bool * ?keepAllBackgroundResolutions: bool * ?legacyReferenceResolver: LegacyReferenceResolver * ?tryGetMetadataSnapshot: FSharp.Compiler.AbstractIL.ILBinaryReader.ILReaderTryGetMetadataSnapshot * ?suggestNamesForErrors: bool * ?keepAllBackgroundSymbolUses: bool * ?enableBackgroundItemKeyStoreAndSemanticClassification: bool * ?enablePartialTypeChecking: bool * ?parallelReferenceResolution: bool * ?captureIdentifiersWhenParsing: bool * [<Experimental ("This parameter is experimental and likely to be removed in the future.")>] ?documentSource: DocumentSource * [<Experimental ("This parameter is experimental and likely to be removed in the future.")>] ?useTransparentCompiler: bool * [<Experimental ("This parameter is experimental and likely to be removed in the future.")>] ?transparentCompilerCacheSizes: TransparentCompiler.CacheSizes -> FSharpChecker
val getUntypedTree: file: string * input: ISourceText -> FSharp.Compiler.Syntax.ParsedInput
 Get untyped tree for a specified input
val file: string
val input: ISourceText
val projOptions: FSharpProjectOptions
val diagnostics: FSharp.Compiler.Diagnostics.FSharpDiagnostic list
member FSharpChecker.GetProjectOptionsFromScript: fileName: string * source: ISourceText * ?caret: Position * ?previewEnabled: bool * ?loadedTimeStamp: DateTime * ?otherFlags: string array * ?useFsiAuxLib: bool * ?useSdkRefs: bool * ?assumeDotNetFramework: bool * ?sdkDirOverride: string * ?optionsStamp: int64 * ?userOpName: string -> Async<FSharpProjectOptions * FSharp.Compiler.Diagnostics.FSharpDiagnostic list>
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * objnull -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * objnull -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...

--------------------
type Async<'T>
static member Async.RunSynchronously: computation: Async<'T> * ?timeout: int * ?cancellationToken: Threading.CancellationToken -> 'T
val parsingOptions: FSharpParsingOptions
val _errors: FSharp.Compiler.Diagnostics.FSharpDiagnostic list
member FSharpChecker.GetParsingOptionsFromProjectOptions: options: FSharpProjectOptions -> FSharpParsingOptions * FSharp.Compiler.Diagnostics.FSharpDiagnostic list
val parseFileResults: FSharpParseFileResults
member FSharpChecker.ParseFile: fileName: string * projectSnapshot: FSharpProjectSnapshot * ?userOpName: string -> Async<FSharpParseFileResults>
member FSharpChecker.ParseFile: fileName: string * sourceText: ISourceText * options: FSharpParsingOptions * ?cache: bool * ?userOpName: string -> Async<FSharpParseFileResults>
property FSharpParseFileResults.ParseTree: FSharp.Compiler.Syntax.ParsedInput with get
<summary> The syntax tree resulting from the parse</summary>
namespace FSharp.Compiler.Syntax
val visitPattern: _arg1: SynPat -> unit
 Walk over a pattern - this is for example used in
 let <pat> = <expr> or in the 'match' expression
Multiple items
module SynPatfrom FSharp.Compiler.Syntax

--------------------
type SynPat = | Const of constant: SynConst * range: range | Wild of range: range | Named of ident: SynIdent * isThisVal: bool * accessibility: SynAccess option * range: range | Typed of pat: SynPat * targetType: SynType * range: range | Attrib of pat: SynPat * attributes: SynAttributes * range: range | Or of lhsPat: SynPat * rhsPat: SynPat * range: range * trivia: SynPatOrTrivia | ListCons of lhsPat: SynPat * rhsPat: SynPat * range: range * trivia: SynPatListConsTrivia | Ands of pats: SynPat list * range: range | As of lhsPat: SynPat * rhsPat: SynPat * range: range | LongIdent of longDotId: SynLongIdent * extraId: Ident option * typarDecls: SynValTyparDecls option * argPats: SynArgPats * accessibility: SynAccess option * range: range ... member Range: range with get
<summary> Represents a syntax tree for an F# pattern</summary>
union case SynPat.Wild: range: range -> SynPat
<summary> A wildcard '_' in a pattern</summary>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
union case SynPat.Named: ident: SynIdent * isThisVal: bool * accessibility: SynAccess option * range: range -> SynPat
<summary> A name pattern 'ident'</summary>
Multiple items
union case SynIdent.SynIdent: ident: Ident * trivia: FSharp.Compiler.SyntaxTrivia.IdentTrivia option -> SynIdent

--------------------
type SynIdent = | SynIdent of ident: Ident * trivia: IdentTrivia option member Range: range with get
<summary> Represents an identifier with potentially additional trivia information.</summary>
val name: Ident
property Ident.idText: string with get
union case SynPat.LongIdent: longDotId: SynLongIdent * extraId: Ident option * typarDecls: SynValTyparDecls option * argPats: SynArgPats * accessibility: SynAccess option * range: range -> SynPat
<summary> A long identifier pattern possibly with argument patterns</summary>
Multiple items
union case SynLongIdent.SynLongIdent: id: LongIdent * dotRanges: range list * trivia: FSharp.Compiler.SyntaxTrivia.IdentTrivia option list -> SynLongIdent

--------------------
type SynLongIdent = | SynLongIdent of id: LongIdent * dotRanges: range list * trivia: IdentTrivia option list member Dots: range list with get member IdentsWithTrivia: SynIdent list with get member LongIdent: LongIdent with get member Range: range with get member RangeWithoutAnyExtraDot: range with get member ThereIsAnExtraDotAtTheEnd: bool with get member Trivia: IdentTrivia list with get
<summary> Represents a long identifier with possible '.' at end. Typically dotRanges.Length = lid.Length-1, but they may be same if (incomplete) code ends in a dot, e.g. "Foo.Bar." The dots mostly matter for parsing, and are typically ignored by the typechecker, but if dotRanges.Length = lid.Length, then the parser must have reported an error, so the typechecker is allowed more freedom about typechecking these expressions. LongIdent can be empty list - it is used to denote that name of some AST element is absent (i.e. empty type name in inherit)</summary>
val id: x: 'T -> 'T
val ident: LongIdent
val names: string
Multiple items
type String = interface IEnumerable<char> interface IEnumerable interface ICloneable interface IComparable interface IComparable<string> interface IConvertible interface IEquatable<string> interface IParsable<string> interface ISpanParsable<string> new: value: nativeptr<char> -> unit + 8 overloads ...
<summary>Represents text as a sequence of UTF-16 code units.</summary>

--------------------
String(value: nativeptr<char>) : String
String(value: char array) : String
String(value: ReadOnlySpan<char>) : String
String(value: nativeptr<sbyte>) : String
String(c: char, count: int) : String
String(value: nativeptr<char>, startIndex: int, length: int) : String
String(value: char array, startIndex: int, length: int) : String
String(value: nativeptr<sbyte>, startIndex: int, length: int) : String
String(value: nativeptr<sbyte>, startIndex: int, length: int, enc: Text.Encoding) : String
val concat: sep: string -> strings: string seq -> string
val i: Ident
val pat: SynPat
val visitExpression: e: SynExpr -> unit
 Walk over an expression - if expression contains two or three
 sub-expressions (two if the 'else' branch is missing), let expression
 contains pattern and two sub-expressions
val e: SynExpr
Multiple items
module SynExprfrom FSharp.Compiler.Syntax

--------------------
type SynExpr = | Paren of expr: SynExpr * leftParenRange: range * rightParenRange: range option * range: range | Quote of operator: SynExpr * isRaw: bool * quotedExpr: SynExpr * isFromQueryExpression: bool * range: range | Const of constant: SynConst * range: range | Typed of expr: SynExpr * targetType: SynType * range: range | Tuple of isStruct: bool * exprs: SynExpr list * commaRanges: range list * range: range | AnonRecd of isStruct: bool * copyInfo: (SynExpr * BlockSeparator) option * recordFields: (SynLongIdent * range option * SynExpr) list * range: range * trivia: SynExprAnonRecdTrivia | ArrayOrList of isArray: bool * exprs: SynExpr list * range: range | Record of baseInfo: (SynType * SynExpr * range * BlockSeparator option * range) option * copyInfo: (SynExpr * BlockSeparator) option * recordFields: SynExprRecordField list * range: range | New of isProtected: bool * targetType: SynType * expr: SynExpr * range: range | ObjExpr of objType: SynType * argOptions: (SynExpr * Ident option) option * withKeyword: range option * bindings: SynBinding list * members: SynMemberDefns * extraImpls: SynInterfaceImpl list * newExprRange: range * range: range ... member IsArbExprAndThusAlreadyReportedError: bool with get member Range: range with get member RangeOfFirstPortion: range with get member RangeWithoutAnyExtraDot: range with get
<summary> Represents a syntax tree for F# expressions</summary>
union case SynExpr.IfThenElse: ifExpr: SynExpr * thenExpr: SynExpr * elseExpr: SynExpr option * spIfToThen: DebugPointAtBinding * isFromErrorRecovery: bool * range: range * trivia: FSharp.Compiler.SyntaxTrivia.SynExprIfThenElseTrivia -> SynExpr
<summary> F# syntax: if expr then expr F# syntax: if expr then expr else expr</summary>
val cond: SynExpr
val trueBranch: SynExpr
val falseBranchOpt: SynExpr option
module Optionfrom Microsoft.FSharp.Core
val iter: action: ('T -> unit) -> option: 'T option -> unit
union case SynExpr.LetOrUse: isRecursive: bool * isUse: bool * bindings: SynBinding list * body: SynExpr * range: range * trivia: FSharp.Compiler.SyntaxTrivia.SynExprLetOrUseTrivia -> SynExpr
<summary> F# syntax: let pat = expr in expr F# syntax: let f pat1 .. patN = expr in expr F# syntax: let rec f pat1 .. patN = expr in expr F# syntax: use pat = expr in expr</summary>
val bindings: SynBinding list
val body: SynExpr
val binding: SynBinding
Multiple items
union case SynBinding.SynBinding: accessibility: SynAccess option * kind: SynBindingKind * isInline: bool * isMutable: bool * attributes: SynAttributes * xmlDoc: FSharp.Compiler.Xml.PreXmlDoc * valData: SynValData * headPat: SynPat * returnInfo: SynBindingReturnInfo option * expr: SynExpr * range: range * debugPoint: DebugPointAtBinding * trivia: FSharp.Compiler.SyntaxTrivia.SynBindingTrivia -> SynBinding

--------------------
type SynBinding = | SynBinding of accessibility: SynAccess option * kind: SynBindingKind * isInline: bool * isMutable: bool * attributes: SynAttributes * xmlDoc: PreXmlDoc * valData: SynValData * headPat: SynPat * returnInfo: SynBindingReturnInfo option * expr: SynExpr * range: range * debugPoint: DebugPointAtBinding * trivia: SynBindingTrivia member RangeOfBindingWithRhs: range with get member RangeOfBindingWithoutRhs: range with get member RangeOfHeadPattern: range with get
<summary> Represents a binding for a 'let' or 'member' declaration</summary>
val headPat: SynPat
val init: SynExpr
val expr: SynExpr
val visitDeclarations: decls: SynModuleDecl seq -> unit
 Walk over a list of declarations in a module. This is anything
 that you can write as a top-level inside module (let bindings,
 nested modules, type declarations etc.)
val decls: SynModuleDecl seq
val declaration: SynModuleDecl
type SynModuleDecl = | ModuleAbbrev of ident: Ident * longId: LongIdent * range: range | NestedModule of moduleInfo: SynComponentInfo * isRecursive: bool * decls: SynModuleDecl list * isContinuing: bool * range: range * trivia: SynModuleDeclNestedModuleTrivia | Let of isRecursive: bool * bindings: SynBinding list * range: range | Expr of expr: SynExpr * range: range | Types of typeDefns: SynTypeDefn list * range: range | Exception of exnDefn: SynExceptionDefn * range: range | Open of target: SynOpenDeclTarget * range: range | Attributes of attributes: SynAttributes * range: range | HashDirective of hashDirective: ParsedHashDirective * range: range | NamespaceFragment of fragment: SynModuleOrNamespace member Range: range with get
<summary> Represents a definition within a module</summary>
union case SynModuleDecl.Let: isRecursive: bool * bindings: SynBinding list * range: range -> SynModuleDecl
<summary> A 'let' definition within a module</summary>
val isRec: bool
Multiple items
val range: range

--------------------
type range = Range
<summary> Represents a range within a file</summary>
val visitModulesAndNamespaces: modulesOrNss: SynModuleOrNamespace seq -> unit
 Walk over all module or namespace declarations
 (basically 'module Foo =' or 'namespace Foo.Bar')
 Note that there is one implicitly, even if the file
 does not explicitly define it..
val modulesOrNss: SynModuleOrNamespace seq
val moduleOrNs: SynModuleOrNamespace
Multiple items
union case SynModuleOrNamespace.SynModuleOrNamespace: longId: LongIdent * isRecursive: bool * kind: SynModuleOrNamespaceKind * decls: SynModuleDecl list * xmlDoc: FSharp.Compiler.Xml.PreXmlDoc * attribs: SynAttributes * accessibility: SynAccess option * range: range * trivia: FSharp.Compiler.SyntaxTrivia.SynModuleOrNamespaceTrivia -> SynModuleOrNamespace

--------------------
type SynModuleOrNamespace = | SynModuleOrNamespace of longId: LongIdent * isRecursive: bool * kind: SynModuleOrNamespaceKind * decls: SynModuleDecl list * xmlDoc: PreXmlDoc * attribs: SynAttributes * accessibility: SynAccess option * range: range * trivia: SynModuleOrNamespaceTrivia member Range: range with get
<summary> Represents the definition of a module or namespace</summary>
val lid: LongIdent
val decls: SynModuleDecl list
val input: string
val tree: ParsedInput
val getUntypedTree: file: string * input: ISourceText -> ParsedInput
 Get untyped tree for a specified input
module SourceTextfrom FSharp.Compiler.Text
<summary> Functions related to ISourceText objects</summary>
val ofString: string -> ISourceText
<summary> Creates an ISourceText object from the given string</summary>
Multiple items
module ParsedInputfrom FSharp.Compiler.Syntax
<summary> Holds operations for working with the untyped abstract syntax tree (<see cref="T:FSharp.Compiler.Syntax.ParsedInput" />). </summary>

--------------------
type ParsedInput = | ImplFile of ParsedImplFileInput | SigFile of ParsedSigFileInput member FileName: string with get member Identifiers: Set<string> with get member QualifiedName: QualifiedNameOfFile with get member Range: range with get
<summary> Represents the syntax tree for a parsed implementation or signature file</summary>
union case ParsedInput.ImplFile: ParsedImplFileInput -> ParsedInput
<summary> A parsed implementation file</summary>
val implFile: ParsedImplFileInput
Multiple items
union case ParsedImplFileInput.ParsedImplFileInput: fileName: string * isScript: bool * qualifiedNameOfFile: QualifiedNameOfFile * hashDirectives: ParsedHashDirective list * contents: SynModuleOrNamespace list * flags: bool * bool * trivia: FSharp.Compiler.SyntaxTrivia.ParsedInputTrivia * identifiers: Set<string> -> ParsedImplFileInput

--------------------
type ParsedImplFileInput = | ParsedImplFileInput of fileName: string * isScript: bool * qualifiedNameOfFile: QualifiedNameOfFile * hashDirectives: ParsedHashDirective list * contents: SynModuleOrNamespace list * flags: bool * bool * trivia: ParsedInputTrivia * identifiers: Set<string> member Contents: SynModuleOrNamespace list with get member FileName: string with get member HashDirectives: ParsedHashDirective list with get member IsExe: bool with get member IsLastCompiland: bool with get member IsScript: bool with get member QualifiedName: QualifiedNameOfFile with get member Trivia: ParsedInputTrivia with get
<summary> Represents the full syntax tree, file name and other parsing information for an implementation file</summary>
val modules: SynModuleOrNamespace list
val failwith: message: string -> 'T

On this page

Type something to start searching.


[8]ページ先頭

©2009-2025 Movatter.jp