Skip to content

Commit f7e00f7

Browse files
committed
Merge pull request #405 from dsyme/vf-align-5
Alignment and make internal lexer/parser properly internal
2 parents 8f4f286 + 33d34dc commit f7e00f7

25 files changed

+190
-150
lines changed

docs/content/editor.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ identifier (the other option lets you get tooltip with full assembly location wh
125125
*)
126126
// Get tag of the IDENT token to be used as the last argument
127127
open Microsoft.FSharp.Compiler
128-
let identToken = Parser.tagOfToken(Parser.token.IDENT(""))
128+
let identToken = FSharpTokenTag.Identifier
129129

130130
// Get tool tip at the specified location
131131
let tip = checkFileResults.GetToolTipTextAlternate(4, 7, inputLines.[1], ["foo"], identToken)

samples/EditorService/Program.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ let input =
2828
let inputLines = input.Split('\n')
2929
let file = "/home/user/Test.fsx"
3030

31-
let identToken = Parser.tagOfToken (Parser.token.IDENT(""))
31+
let identTokenTag = FSharpTokenTag.Identifier
3232
let untyped, parsed = parseWithTypeInfo (file, input)
3333
// Get tool tip at the specified location
34-
let tip = parsed.GetToolTipTextAlternate(2, 7, inputLines.[1], [ "foo" ], identToken)
34+
let tip = parsed.GetToolTipTextAlternate(2, 7, inputLines.[1], [ "foo" ], identTokenTag)
3535

3636
printfn "%A" tip
3737

src/absil/ilreflect.fs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let logRefEmitCalls = false
4646

4747
type System.AppDomain with
4848
member x.DefineDynamicAssemblyAndLog(asmName,flags,asmDir:string) =
49-
let asmB = x.DefineDynamicAssembly(asmName,flags,asmDir)
49+
let asmB = x.DefineDynamicAssembly(asmName,flags,asmDir)
5050
if logRefEmitCalls then
5151
printfn "open System"
5252
printfn "open System.Reflection"
@@ -56,7 +56,7 @@ type System.AppDomain with
5656

5757

5858
type System.Reflection.Emit.AssemblyBuilder with
59-
member asmB.DefineDynamicModuleAndLog(a,b,c) =
59+
member asmB.DefineDynamicModuleAndLog(a,b,c) =
6060
let modB = asmB.DefineDynamicModule(a,b,c)
6161
if logRefEmitCalls then printfn "let moduleBuilder%d = assemblyBuilder%d.DefineDynamicModule(%A,%A,%A)" (abs <| hash modB) (abs <| hash asmB) a b c
6262
modB
@@ -199,7 +199,7 @@ type System.Reflection.Emit.TypeBuilder with
199199
#if FX_NO_INVOKE_MEMBER
200200
#else
201201
member typB.InvokeMemberAndLog(nm,flags,args) =
202-
if logRefEmitCalls then printfn "typeBuilder%d.InvokeMember(\"%s\",enum %d,null,null,%A,Globalization.CultureInfo.InvariantCulture)" (abs <| hash typB) nm (LanguagePrimitives.EnumToValue flags) args
202+
if logRefEmitCalls then printfn "typeBuilder%d.InvokeMember(\"%s\",enum %d,null,null,%A,Globalization.CultureInfo.InvariantCulture)" (abs <| hash typB) nm (LanguagePrimitives.EnumToValue flags) args
203203
typB.InvokeMember(nm,flags,null,null,args,Globalization.CultureInfo.InvariantCulture)
204204
#endif
205205

@@ -339,9 +339,9 @@ let convTypeRefAux (cenv:cenv) (tref:ILTypeRef) =
339339
match tref.Scope with
340340
| ILScopeRef.Assembly asmref ->
341341
let assembly =
342-
match cenv.resolvePath asmref with
342+
match cenv.resolvePath asmref with
343343
| Some (Choice1Of2 path) ->
344-
FileSystem.AssemblyLoadFrom(path)
344+
FileSystem.AssemblyLoadFrom(path)
345345
| Some (Choice2Of2 assembly) ->
346346
assembly
347347
| None ->
@@ -1068,7 +1068,7 @@ let rec emitInstr cenv (modB : ModuleBuilder) emEnv (ilG:ILGenerator) instr =
10681068
| I_callvirt (tail,mspec,varargs) -> emitSilverlightCheck ilG
10691069
emitInstrCall cenv emEnv ilG OpCodes.Callvirt tail mspec varargs
10701070
| I_callconstraint (tail,typ,mspec,varargs) -> ilG.Emit(OpCodes.Constrained,convType cenv emEnv typ);
1071-
emitInstrCall cenv emEnv ilG OpCodes.Callvirt tail mspec varargs
1071+
emitInstrCall cenv emEnv ilG OpCodes.Callvirt tail mspec varargs
10721072
#if FX_NO_REFLECTION_EMIT_CALLI
10731073
| I_calli (tail,_callsig,None) -> emitInstrTail ilG tail (fun () -> ())
10741074
| I_calli (tail,_callsig,Some _vartyps) -> emitInstrTail ilG tail (fun () -> ())
@@ -1085,7 +1085,7 @@ let rec emitInstr cenv (modB : ModuleBuilder) emEnv (ilG:ILGenerator) instr =
10851085
convCallConv callsig.CallingConv,
10861086
convType cenv emEnv callsig.ReturnType,
10871087
convTypesToArray cenv emEnv callsig.ArgTypes,
1088-
convTypesToArray cenv emEnv vartyps))
1088+
convTypesToArray cenv emEnv vartyps))
10891089
#endif
10901090
| I_ldftn mspec -> ilG.EmitAndLog(OpCodes.Ldftn,convMethodSpec cenv emEnv mspec)
10911091
| I_newobj (mspec,varargs) -> emitInstrNewobj cenv emEnv ilG mspec varargs
@@ -1954,7 +1954,7 @@ let createTypeRef (visited : Dictionary<_,_>, created : Dictionary<_,_>) emEnv t
19541954
if not (visited.ContainsKey(tref)) || visited.[tref] > priority then
19551955
visited.[tref] <- priority;
19561956
let tdef = envGetTypeDef emEnv tref
1957-
if verbose2 then dprintf "- traversing type %s\n" typB.FullName;
1957+
if verbose2 then dprintf "- traversing type %s\n" typB.FullName;
19581958
#if FX_NO_TYPE_RESOLVE_EVENT
19591959
traverseTypeDef priority tref tdef;
19601960
#else
@@ -1975,7 +1975,7 @@ let createTypeRef (visited : Dictionary<_,_>, created : Dictionary<_,_>) emEnv t
19751975
try
19761976
traverseTypeDef priority tref tdef;
19771977
finally
1978-
System.AppDomain.CurrentDomain.remove_TypeResolve typeCreationHandler
1978+
System.AppDomain.CurrentDomain.remove_TypeResolve typeCreationHandler
19791979
#endif
19801980
if not (created.ContainsKey(tref)) then
19811981
created.[tref] <- true;
@@ -2049,7 +2049,7 @@ let buildModuleFragment cenv emEnv (asmB : AssemblyBuilder) (modB : ModuleBuilde
20492049

20502050
let mkDynamicAssemblyAndModule (assemblyName, optimize, debugInfo, collectible) =
20512051
let filename = assemblyName ^ ".dll"
2052-
let currentDom = System.AppDomain.CurrentDomain
2052+
let currentDom = System.AppDomain.CurrentDomain
20532053
let asmName = new AssemblyName()
20542054
asmName.Name <- assemblyName
20552055
#if FX_NO_REFLECTION_EMIT_SAVE_ASSEMBLY
@@ -2085,7 +2085,7 @@ let emitModuleFragment (ilg, emEnv, asmB : AssemblyBuilder, modB : ModuleBuilder
20852085
emitCustomAttrs cenv emEnv asmB.SetCustomAttributeAndLog mani.CustomAttrs;
20862086
// invoke entry point methods
20872087
let execEntryPtFun ((typB : TypeBuilder),methodName) () =
2088-
try
2088+
try
20892089
#if FX_NO_INVOKE_MEMBER
20902090
let mi = typB.GetMethod(methodName, BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.Static)
20912091
System.Diagnostics.Debug.WriteLine("mi: {0}", string(mi.ToString()))
@@ -2096,7 +2096,7 @@ let emitModuleFragment (ilg, emEnv, asmB : AssemblyBuilder, modB : ModuleBuilder
20962096
let invokedm = dm.CreateDelegate(typeof<EntryDelegate>)
20972097
invokedm.DynamicInvoke(null) |> ignore
20982098
#else
2099-
ignore (typB.InvokeMemberAndLog(methodName,BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.Static,[| |]));
2099+
ignore (typB.InvokeMemberAndLog(methodName,BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.Static,[| |]));
21002100
#endif
21012101
None
21022102
with

src/absil/ilsupp.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,8 +1195,8 @@ let pdbReadOpen (moduleName:string) (path:string) : PdbReader =
11951195
with _ ->
11961196
{ symReader = null }
11971197
#else
1198-
let symbolBinder = new System.Diagnostics.SymbolStore.SymBinder()
1199-
{ symReader = symbolBinder.GetReader(importerPtr, moduleName, path) }
1198+
let symbolBinder = new System.Diagnostics.SymbolStore.SymBinder()
1199+
{ symReader = symbolBinder.GetReader(importerPtr, moduleName, path) }
12001200
#endif
12011201
finally
12021202
// Marshal.GetComInterfaceForObject adds an extra ref for importerPtr

src/fsharp/CompileOps.fs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4008,19 +4008,22 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
40084008
let name = System.Reflection.AssemblyName.GetAssemblyName(resolution.resolvedPath)
40094009
name.Version
40104010

4011-
// The callback captured by the TypeProviderConfig. Disconnect when things are disposed
4012-
let systemRuntimeContainsType =
4013-
let systemRuntimeContainsTypeRef = ref tcImports.SystemRuntimeContainsType
4014-
tcImports.AttachDisposeAction(fun () -> systemRuntimeContainsTypeRef := (fun _ -> raise (System.ObjectDisposedException("The type provider has been disposed"))))
4015-
fun arg -> systemRuntimeContainsTypeRef.Value arg
4016-
40174011
let typeProviderEnvironment =
40184012
{ resolutionFolder = tcConfig.implicitIncludeDir
40194013
outputFile = tcConfig.outputFile
40204014
showResolutionMessages = tcConfig.showExtensionTypeMessages
40214015
referencedAssemblies = [| for r in resolutions.GetAssemblyResolutions() -> r.resolvedPath |]
40224016
temporaryFolder = FileSystem.GetTempPathShim() }
40234017

4018+
// The type provider should not hold strong references to disposed
4019+
// TcImport objects. So the callbacks provided in the type provider config
4020+
// dispatch via a thunk which gets set to a non-resource-capturing
4021+
// failing function when the object is disposed.
4022+
let systemRuntimeContainsType =
4023+
let systemRuntimeContainsTypeRef = ref tcImports.SystemRuntimeContainsType
4024+
tcImports.AttachDisposeAction(fun () -> systemRuntimeContainsTypeRef := (fun _ -> raise (System.ObjectDisposedException("The type provider has been disposed"))))
4025+
fun arg -> systemRuntimeContainsTypeRef.Value arg
4026+
40244027
let providers =
40254028
[ for assemblyName in providerAssemblies do
40264029
yield ExtensionTyping.GetTypeProvidersOfAssembly(displayPSTypeProviderSecurityDialogBlockingUI, tcConfig.validateTypeProviders,
@@ -5280,3 +5283,5 @@ let TypeCheckClosedInputSet (checkForErrors, tcConfig, tcImports, tcGlobals, pre
52805283
tcState, topAttrs, tassembly, tcEnvAtEndOfLastFile
52815284

52825285

5286+
5287+

src/fsharp/CompileOps.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,4 +764,4 @@ type LoadClosure =
764764
static member ComputeClosureOfSourceText : filename: string * source: string * implicitDefines:CodeContext * useMonoResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) -> LoadClosure
765765

766766
/// Used from fsi.fs and fsc.fs, for #load and command line. The resulting references are then added to a TcConfig.
767-
static member ComputeClosureOfSourceFiles : tcConfig:TcConfig * (string * range) list * implicitDefines:CodeContext * useDefaultScriptingReferences: bool * lexResourceManager: Lexhelp.LexResourceManager -> LoadClosure
767+
static member ComputeClosureOfSourceFiles : tcConfig:TcConfig * (string * range) list * implicitDefines:CodeContext * useDefaultScriptingReferences : bool * lexResourceManager : Lexhelp.LexResourceManager -> LoadClosure

src/fsharp/ErrorLogger.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ type Exiter =
108108

109109
let QuitProcessExiter =
110110
{ new Exiter with
111-
member x.Exit(n) =
111+
member x.Exit(n) =
112112
#if FX_NO_SYSTEM_ENVIRONMENT_EXIT
113113
#else
114114
try
115115
System.Environment.Exit(n)
116116
with _ ->
117-
()
117+
()
118118
#endif
119119
failwithf "%s" <| FSComp.SR.elSysEnvExitDidntExit() }
120120

src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<FsYacc Include="..\pars.fsy">
9999
<Module>Microsoft.FSharp.Compiler.Parser</Module>
100100
<Open>Microsoft.FSharp.Compiler</Open>
101-
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
101+
<OtherFlags>--internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
102102
<Link>pars.fsy</Link>
103103
</FsYacc>
104104
<Compile Include="..\..\utils\sformat.fsi">
@@ -219,12 +219,6 @@
219219
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing</OtherFlags>
220220
<Link>AbsIL/illex.fsl</Link>
221221
</FsLex>
222-
<FsYacc Include="..\..\absil\ilpars.fsy">
223-
<Module>Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser</Module>
224-
<Open>Microsoft.FSharp.Compiler.AbstractIL</Open>
225-
<OtherFlags>--internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
226-
<Link>AbsIL/ilpars.fsy</Link>
227-
</FsYacc>
228222
<Compile Include="..\..\absil\il.fsi">
229223
<Link>AbsIL/il.fsi</Link>
230224
</Compile>
@@ -317,16 +311,10 @@
317311
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing</OtherFlags>
318312
<Link>ParserAndUntypedAST/pplex.fsl</Link>
319313
</FsLex>
320-
<FsYacc Include="..\pars.fsy">
321-
<Module>Microsoft.FSharp.Compiler.Parser</Module>
322-
<Open>Microsoft.FSharp.Compiler</Open>
323-
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
324-
<Link>ParserAndUntypedAST/pars.fsy</Link>
325-
</FsYacc>
326314
<FsYacc Include="..\pppars.fsy">
327315
<Module>Microsoft.FSharp.Compiler.PPParser</Module>
328316
<Open>Microsoft.FSharp.Compiler</Open>
329-
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
317+
<OtherFlags>--internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing</OtherFlags>
330318
<Link>ParserAndUntypedAST/pppars.fsy</Link>
331319
</FsYacc>
332320
<Compile Include="..\UnicodeLexing.fsi">

src/fsharp/LexFilter.fs

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

33
/// LexFilter - process the token stream prior to parsing.
44
/// Implements the offside rule and a copule of other lexical transformations.
5-
module (*internal*) Microsoft.FSharp.Compiler.LexFilter
5+
module internal Microsoft.FSharp.Compiler.LexFilter
66

77
open Internal.Utilities
88
open Internal.Utilities.Text.Lexing

src/fsharp/UnicodeLexing.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

3-
module (*internal*) Microsoft.FSharp.Compiler.UnicodeLexing
3+
module internal Microsoft.FSharp.Compiler.UnicodeLexing
44

55
//------------------------------------------------------------------
66
// Functions for Unicode char-based lexing (new code).

src/fsharp/UnicodeLexing.fsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

3-
module (*internal*) Microsoft.FSharp.Compiler.UnicodeLexing
3+
module internal Microsoft.FSharp.Compiler.UnicodeLexing
44

55
open Microsoft.FSharp.Text
66
open Internal.Utilities.Text.Lexing

src/fsharp/ast.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ type XmlDoc =
9494
let lineAT = lineA.TrimStart([|' '|])
9595
if lineAT = "" then processLines rest
9696
else if String.hasPrefix lineAT "<" then lines
97-
else ["<summary>"] @
97+
else ["<summary>"] @
9898
#if FX_NO_SECURITY_ELEMENT_ESCAPE
9999
lines @
100100
#else
@@ -2084,15 +2084,15 @@ and LexCont = LexerWhitespaceContinuation
20842084
exception SyntaxError of obj (* ParseErrorContext<_> *) * range
20852085

20862086
/// Get an F# compiler position from a lexer position
2087-
let posOfLexPosition (p:Position) =
2087+
let internal posOfLexPosition (p:Position) =
20882088
mkPos p.Line p.Column
20892089

20902090
/// Get an F# compiler range from a lexer range
2091-
let mkSynRange (p1:Position) (p2: Position) =
2091+
let internal mkSynRange (p1:Position) (p2: Position) =
20922092
mkFileIndexRange p1.FileIndex (posOfLexPosition p1) (posOfLexPosition p2)
20932093

20942094
type LexBuffer<'Char> with
2095-
member lexbuf.LexemeRange = mkSynRange lexbuf.StartPos lexbuf.EndPos
2095+
member internal lexbuf.LexemeRange = mkSynRange lexbuf.StartPos lexbuf.EndPos
20962096

20972097
/// Get the range corresponding to the result of a grammar rule while it is being reduced
20982098
let internal lhs (parseState: IParseState) =
@@ -2129,19 +2129,19 @@ module LexbufLocalXmlDocStore =
21292129
// The key into the BufferLocalStore used to hold the current accumulated XmlDoc lines
21302130
let private xmlDocKey = "XmlDoc"
21312131

2132-
let ClearXmlDoc (lexbuf:Lexbuf) =
2132+
let internal ClearXmlDoc (lexbuf:Lexbuf) =
21332133
lexbuf.BufferLocalStore.[xmlDocKey] <- box (XmlDocCollector())
21342134

21352135
/// Called from the lexer to save a single line of XML doc comment.
2136-
let SaveXmlDocLine (lexbuf:Lexbuf, lineText, pos) =
2136+
let internal SaveXmlDocLine (lexbuf:Lexbuf, lineText, pos) =
21372137
if not (lexbuf.BufferLocalStore.ContainsKey(xmlDocKey)) then
21382138
lexbuf.BufferLocalStore.[xmlDocKey] <- box (XmlDocCollector())
21392139
let collector = unbox<XmlDocCollector>(lexbuf.BufferLocalStore.[xmlDocKey])
21402140
collector.AddXmlDocLine (lineText, pos)
21412141

21422142
/// Called from the parser each time we parse a construct that marks the end of an XML doc comment range,
21432143
/// e.g. a 'type' declaration. The markerRange is the range of the keyword that delimits the construct.
2144-
let GrabXmlDocBeforeMarker (lexbuf:Lexbuf, markerRange:range) =
2144+
let internal GrabXmlDocBeforeMarker (lexbuf:Lexbuf, markerRange:range) =
21452145
if lexbuf.BufferLocalStore.ContainsKey(xmlDocKey) then
21462146
PreXmlDoc.CreateFromGrabPoint(unbox<XmlDocCollector>(lexbuf.BufferLocalStore.[xmlDocKey]),markerRange.End)
21472147
else

0 commit comments

Comments
 (0)