开发者

How to specify unicode characters in patterns for fslex

开发者 https://www.devze.com 2023-02-14 21:20 出处:网络
What is the correct way to specify Unicode characters in pattern for FSharp Lexer. Following code is not compiled with th开发者_如何学Goe FsLex.exe utility:

What is the correct way to specify Unicode characters in pattern for FSharp Lexer. Following code is not compiled with th开发者_如何学Goe FsLex.exe utility:

let lexeme lexbuf = LexBuffer<char>.LexemeString lexbuf
...
rule tokenize = parse   

| ['a'-'z' 'A'-'Z'] { TOKEN1 }  
| [\u0100\u0101]    { TOKEN2 } 
| [\u0102-\u01FF]   { TOKEN3 }  
...
| [eof]             { EOF }

What I'm doing wrong?

P.S: I'm using fslex.exe with --unicode option

Thanks, Vitaliy


I think you have to put the unicode characters in single quotes, just like in normal F# code.

At least that seems to work for a small example that I tested.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号