简体   繁体   English

F#整数文件指令

[英]F# integer file directive

I've been using fslex and fsyacc, and the F# source files ( .fs they generate from the lexer ( .fsl ) and parser ( .fsp ) rules refer to the original .fsl (and sometimes to the same .fs source file) all over the place with statement such as this (numbers are line numbers): 我一直在使用fslex和fsyacc,与F#源文件( .fs他们从词法分析器(产生.fsl )和解析器( .fsp )规则,是指原.fsl (有时在同一.fs源文件)所有地方都有这样的陈述(数字是行号):

lex.fs
1      # 1 "/[PROJECT-PATH-HERE]/lex.fsp
...
16     # 16 "/PROJECT-PATH-HERE]/lex.fs
17     // This is the type of tokens accepted by the parser
18     type token =
19       | EOF
...

Also, the .fs files generated by pars.fsp do the same kind of thing, but additionaly reference to the F# signature file ( .fsi ) generated alongside it. 此外, .fs通过生成的文件pars.fsp做同样的事情,但additionaly参考F#签名文件( .fsi沿着它产生的)。 What does any of this do/mean? 这有什么意义/意思?

The annotations you see in the generated code are F# Compiler Directives (specifically, the 'line' directive). 您在生成的代码中看到的注释是F#Compiler Directives (特别是'line'指令)。

The 'line' directive makes it so that when the F# compiler needs to emit a warning/error message for some part of the generated code, it has a way to determine which part of the original file corresponds to that part of the generated code. 'line'指令使得当F#编译器需要为生成的代码的某些部分发出警告/错误消息时,它有一种方法来确定原始文件的哪个部分对应于生成的代码的那部分。 In other words, the F# compiler can generate a warning/error message referencing the original code which is the basis of the generated code causing the error. 换句话说,F#编译器可以生成引用原始代码的警告/错误消息,该原始代码是导致错误的生成代码的基础。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM