代码拉取完成,页面将自动刷新
{
open FSharp.Text.Lexing
open FunPar
let lexemeAsString lexbuf =
LexBuffer<char>.LexemeString lexbuf
(* Start of outermost comment currently being scanned *)
let commentStart = ref Position.Empty;
let commentDepth = ref 0; (* Current comment nesting *)
(* Distinguish keywords from identifiers: *)
let keyword s =
match s with
| "else" -> ELSE
| "end" -> END
| "false" -> CSTBOOL false
| "if" -> IF
| "in" -> IN
| "let" -> LET
| "not" -> NOT
| "then" -> THEN
| "true" -> CSTBOOL true
| _ -> NAME s
}
rule Token = parse
| [' ' '\t' '\r'] { Token lexbuf }
| '\n' { lexbuf.EndPos <- lexbuf.EndPos.NextLine; Token lexbuf }
| ['0'-'9']+ { CSTINT (System.Int32.Parse (lexemeAsString lexbuf)) }
| ['a'-'z''A'-'Z']['a'-'z''A'-'Z''0'-'9']*
{ keyword (lexemeAsString lexbuf) }
| "(*" { commentStart.contents <- lexbuf.StartPos;
commentDepth .contents<- 1;
SkipComment lexbuf; Token lexbuf }
| '=' { EQ }
| "<>" { NE }
| '>' { GT }
| '<' { LT }
| ">=" { GE }
| "<=" { LE }
| '+' { PLUS }
| '-' { MINUS }
| '*' { TIMES }
| '/' { DIV }
| '%' { MOD }
| '(' { LPAR }
| ')' { RPAR }
| eof { EOF }
| _ { failwith "Lexer error: illegal symbol" }
and SkipComment = parse
"*)" { commentDepth.contents <- commentDepth.contents - 1;
if commentDepth.contents = 0 then ()
else SkipComment lexbuf
}
| "(*" { commentDepth.contents <- commentDepth.contents + 1;
SkipComment lexbuf }
| eof { failwith "Lexer error: unterminated comment" }
| _ { SkipComment lexbuf }
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。