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

Commit8375316

Browse files
rojeppKevinRansom
authored andcommitted
Implement issuedotnet#25: Treat shebang '#! ...' as a line comment
1 parent3b5c160 commit8375316

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

‎src/fsharp/lex.fsl‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ rule token args skip = parse
574574
| ignored_op_char* ('!' | '~' ) op_char* { checkExprOp lexbuf; PREFIX_OP(lexeme lexbuf) }
575575
| ".[]" | ".[]<-" | ".[,]<-" | ".[,,]<-" | ".[,,,]<-" | ".[,,,]" | ".[,,]" | ".[,]" | ".[..]" | ".[..,..]" | ".[..,..,..]" | ".[..,..,..,..]"
576576
| ".()" | ".()<-" { FUNKY_OPERATOR_NAME(lexeme lexbuf) }
577+
| "#!" op_char*
578+
{ // Treat shebangs like regular comments
579+
let m = lexbuf.LexemeRange
580+
if not skip then (LINE_COMMENT (LexCont.SingleLineComment(!args.ifdefStack,1,m))) else singleLineComment (None,1,m,args) skip lexbuf }
577581

578582
| "#light" anywhite*
579583
| ("#indent" | "#light") anywhite+ "\"on\""

‎tests/fsharp/core/syntax/test.fsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ test "line number test" (__SOURCE_FILE__ = "file.fs")
3232
test"line number test"(__LINE__="29")
3333
test"line number test"(__SOURCE_FILE__="original-test-file.fs")
3434

35+
// This shebang should be treated like a line comment
36+
#!/bin/usr/env fsharpi--exec
37+
3538
#if NetCore
3639
#else
3740
letargv= System.Environment.GetCommandLineArgs()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp