Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8464bc4

Browse files
authored
Add back suport for (*IF-OCML and (*F# (#3026)
* Remove comment ifdefs* Add Microsoft.NET.Sdk.FSharp.props* Make TargetFrameworks work* restore {BuildSuffix}* rename sdk targets and props, refactor project logic into our repo* wrong name* Add automagic FSharp.Core reference for coreclr* Set <DefaultProjectTypeGuid to F# project system guid* Fix setup* Reverthttps://github.com/Microsoft/visualfsharp/pull/2530/commits ---
1 parent9e80078 commit8464bc4

File tree

9 files changed

+73
-1
lines changed

9 files changed

+73
-1
lines changed

‎src/fsharp/FSComp.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ csSeeAvailableOverloads,"The available overloads are shown below (or in the Erro
366366
516,parsEofInComment,"End of file in comment begun at or before here"
367367
517,parsEofInStringInComment,"End of file in string embedded in comment begun at or before here"
368368
518,parsEofInVerbatimStringInComment,"End of file in verbatim string embedded in comment begun at or before here"
369+
519,parsEofInIfOcaml,"End of file in IF-OCAML section begun at or before here"
369370
520,parsEofInDirective,"End of file in directive begun at or before here"
370371
521,parsNoHashEndIfFound,"No #endif found for #if or #else"
371372
522,parsAttributesIgnored,"Attributes have been ignored in this construct"

‎src/fsharp/ast.fs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,7 @@ type LexerWhitespaceContinuation =
21232123
| StringInCommentofifdef:LexerIfdefStackEntries*int*range:range
21242124
| VerbatimStringInCommentofifdef:LexerIfdefStackEntries*int*range:range
21252125
| TripleQuoteStringInCommentofifdef:LexerIfdefStackEntries*int*range:range
2126+
| MLOnlyofifdef:LexerIfdefStackEntries*range:range
21262127
| EndLineofLexerEndlineContinuation
21272128

21282129
memberx.LexerIfdefStack=
@@ -2136,7 +2137,8 @@ type LexerWhitespaceContinuation =
21362137
| LexCont.TripleQuoteString(ifdef=ifd)
21372138
| LexCont.StringInComment(ifdef=ifd)
21382139
| LexCont.VerbatimStringInComment(ifdef=ifd)
2139-
| LexCont.TripleQuoteStringInComment(ifdef=ifd)-> ifd
2140+
| LexCont.TripleQuoteStringInComment(ifdef=ifd)
2141+
| LexCont.MLOnly(ifdef=ifd)-> ifd
21402142
| LexCont.EndLine endl-> endl.LexerIfdefStack
21412143

21422144
andLexCont= LexerWhitespaceContinuation

‎src/fsharp/lex.fsl‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,14 @@ rule token args skip = parse
416416
{ match unicodeGraphLong (lexemeTrimBoth lexbuf 3 1) with
417417
| SingleChar(c) -> CHAR (char c)
418418
| _ -> fail args lexbuf (FSComp.SR.lexThisUnicodeOnlyInStringLiterals()) (CHAR (char 0)) }
419+
| "(*IF-FSHARP"
420+
{ if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf }
421+
| "(*F#"
422+
{ if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf }
423+
| "ENDIF-FSHARP*)"
424+
{ if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf }
425+
| "F#*)"
426+
{ if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf }
419427

420428
| "(*)"
421429
{ LPAREN_STAR_RPAREN }
@@ -424,6 +432,10 @@ rule token args skip = parse
424432
{ let m = lexbuf.LexemeRange
425433
if not skip then (COMMENT (LexCont.Comment(!args.ifdefStack,1,m))) else comment (1,m,args) skip lexbuf }
426434

435+
| "(*IF-CAML*)" | "(*IF-OCAML*)"
436+
{ let m = lexbuf.LexemeRange
437+
if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf }
438+
427439
| '"'
428440
{ let buf,fin,m = startString args lexbuf
429441
if not skip then (STRING_TEXT (LexCont.String(!args.ifdefStack,m))) else string (buf,fin,m,args) skip lexbuf }
@@ -1038,3 +1050,24 @@ and tripleQuoteStringInComment n m args skip = parse
10381050
| surrogateChar surrogateChar
10391051
| _
10401052
{ if not skip then (COMMENT (LexCont.TripleQuoteStringInComment(!args.ifdefStack,n,m))) else tripleQuoteStringInComment n m args skip lexbuf }
1053+
1054+
1055+
and mlOnly m args skip = parse
1056+
| "\""
1057+
{ let buf = ByteBuffer.Create 100
1058+
let m2 = lexbuf.LexemeRange
1059+
let _ = string (buf,defaultStringFinisher,m2,args) skip lexbuf
1060+
if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf }
1061+
| newline
1062+
{ newline lexbuf; if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf }
1063+
| "(*ENDIF-CAML*)"
1064+
{ if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf }
1065+
| "(*ENDIF-OCAML*)"
1066+
{ if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf }
1067+
| [^ '(' '"' '\n' '\r' ]+
1068+
{ if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf }
1069+
| eof
1070+
{ EOF (LexCont.MLOnly(!args.ifdefStack,m)) }
1071+
| surrogateChar surrogateChar
1072+
| _
1073+
{ if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf }

‎src/fsharp/pars.fsy‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ let checkEndOfFileError t =
9696
| LexCont.StringInComment (_,_,m) -> reportParseErrorAt m (FSComp.SR.parsEofInStringInComment())
9797
| LexCont.VerbatimStringInComment (_,_,m) -> reportParseErrorAt m (FSComp.SR.parsEofInVerbatimStringInComment())
9898
| LexCont.TripleQuoteStringInComment (_,_,m) -> reportParseErrorAt m (FSComp.SR.parsEofInTripleQuoteStringInComment())
99+
| LexCont.MLOnly (_,m) -> reportParseErrorAt m (FSComp.SR.parsEofInIfOcaml())
99100
| LexCont.EndLine(LexerEndlineContinuation.Skip(_,_,m)) -> reportParseErrorAt m (FSComp.SR.parsEofInDirective())
100101
| LexCont.EndLine(LexerEndlineContinuation.Token(stack))
101102
| LexCont.Token(stack) ->

‎src/fsharp/vs/ServiceLexing.fs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ type FSharpTokenizerColorState =
304304
| Comment=5
305305
| StringInComment=6
306306
| VerbatimStringInComment=7
307+
| CamlOnly=8
307308
| VerbatimString=9
308309
| SingleLineComment=10
309310
| EndLineThenSkip=11
@@ -414,6 +415,7 @@ module internal LexerStateEncoding =
414415
| LexCont.StringInComment(ifd,n,m)-> FSharpTokenizerColorState.StringInComment, resize32 n, m.Start, ifd
415416
| LexCont.VerbatimStringInComment(ifd,n,m)-> FSharpTokenizerColorState.VerbatimStringInComment, resize32 n, m.Start, ifd
416417
| LexCont.TripleQuoteStringInComment(ifd,n,m)-> FSharpTokenizerColorState.TripleQuoteStringInComment,resize32 n, m.Start, ifd
418+
| LexCont.MLOnly(ifd,m)-> FSharpTokenizerColorState.CamlOnly,0L, m.Start, ifd
417419
| LexCont.VerbatimString(ifd,m)-> FSharpTokenizerColorState.VerbatimString,0L, m.Start, ifd
418420
| LexCont.TripleQuoteString(ifd,m)-> FSharpTokenizerColorState.TripleQuoteString,0L, m.Start, ifd
419421
encodeLexCont tag n1 p1 ifd lightSyntaxStatus
@@ -431,6 +433,7 @@ module internal LexerStateEncoding =
431433
| FSharpTokenizerColorState.StringInComment-> LexCont.StringInComment(ifd,n1,mkRange"file" p1 p1)
432434
| FSharpTokenizerColorState.VerbatimStringInComment-> LexCont.VerbatimStringInComment(ifd,n1,mkRange"file" p1 p1)
433435
| FSharpTokenizerColorState.TripleQuoteStringInComment-> LexCont.TripleQuoteStringInComment(ifd,n1,mkRange"file" p1 p1)
436+
| FSharpTokenizerColorState.CamlOnly-> LexCont.MLOnly(ifd,mkRange"file" p1 p1)
434437
| FSharpTokenizerColorState.VerbatimString-> LexCont.VerbatimString(ifd,mkRange"file" p1 p1)
435438
| FSharpTokenizerColorState.TripleQuoteString-> LexCont.TripleQuoteString(ifd,mkRange"file" p1 p1)
436439
| FSharpTokenizerColorState.EndLineThenSkip-> LexCont.EndLine(LexerEndlineContinuation.Skip(ifd,n1,mkRange"file" p1 p1))
@@ -456,6 +459,7 @@ module internal LexerStateEncoding =
456459
| LexCont.StringInComment(ifd,n,m)-> Lexer.stringInComment n m(argsWithIfDefs ifd) skip lexbuf
457460
| LexCont.VerbatimStringInComment(ifd,n,m)-> Lexer.verbatimStringInComment n m(argsWithIfDefs ifd) skip lexbuf
458461
| LexCont.TripleQuoteStringInComment(ifd,n,m)-> Lexer.tripleQuoteStringInComment n m(argsWithIfDefs ifd) skip lexbuf
462+
| LexCont.MLOnly(ifd,m)-> Lexer.mlOnly m(argsWithIfDefs ifd) skip lexbuf
459463
| LexCont.VerbatimString(ifd,m)-> Lexer.verbatimString(ByteBuffer.Create100,defaultStringFinisher,m,(argsWithIfDefs ifd)) skip lexbuf
460464
| LexCont.TripleQuoteString(ifd,m)-> Lexer.tripleQuoteString(ByteBuffer.Create100,defaultStringFinisher,m,(argsWithIfDefs ifd)) skip lexbuf
461465

‎src/fsharp/vs/ServiceLexing.fsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type FSharpTokenizerColorState =
2929
| Comment=5
3030
| StringInComment=6
3131
| VerbatimStringInComment=7
32+
| CamlOnly=8
3233
| VerbatimString=9
3334
| SingleLineComment=10
3435
| EndLineThenSkip=11
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// #Conformance #LexicalAnalysis
2+
#light
3+
4+
(*IF-FSHARP
5+
6+
let x = 0
7+
8+
ENDIF-FSHARP*)
9+
10+
// If the 'IF-FSHARP' wasn't honored, x wouldn't be defined
11+
exit x
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// #Conformance #LexicalAnalysis
2+
#light
3+
4+
(*F#
5+
6+
let x = 0
7+
8+
F#*)
9+
10+
if2<>0(*F# + 2 F#*)then exit1
11+
12+
exit x
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// #Conformance #LexicalAnalysis
2+
#light
3+
4+
letx=0(*IF-OCAML*)+1(*ENDIF-OCAML*)
5+
6+
// should be = 0 since IF-OCAML is stripped out
7+
exit x

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp