Antlr 词法分析器规则标记浮点/双精度
我正在尝试使用 这个正则表达式 来标记 Antlr 中的双精度值,但显然这个正则表达式没有被 Antlr 理解。
Number: (-?)(0|([1-9][0-9]*))(\\.[0-9]+)?;
错误:
syntax error: '-' came as a complete surprise to me
syntax error: '?' came as a complete surprise to me
syntax error: '0' came as a complete surprise to me
syntax error: '\' came as a complete surprise to me
syntax error: '\' came as a complete surprise to me
syntax error: '-' came as a complete surprise to me
syntax error: '?' came as a complete surprise to me
syntax error: '0' came as a complete surprise to me
syntax error: '\' came as a complete surprise to me
syntax error: '\' came as a complete surprise to me
I am trying to use this regex to tokenize a double in Antlr but apparently this regex is not getting understood by Antlr.
Number: (-?)(0|([1-9][0-9]*))(\\.[0-9]+)?;
Error:
syntax error: '-' came as a complete surprise to me
syntax error: '?' came as a complete surprise to me
syntax error: '0' came as a complete surprise to me
syntax error: '\' came as a complete surprise to me
syntax error: '\' came as a complete surprise to me
syntax error: '-' came as a complete surprise to me
syntax error: '?' came as a complete surprise to me
syntax error: '0' came as a complete surprise to me
syntax error: '\' came as a complete surprise to me
syntax error: '\' came as a complete surprise to me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Antlr Lexer统治在某种程度上类似于Regex,但绝对不是正则。
尝试:
字符需要包含在
'
标记中(除了集符号([
and ]之间的字符,] )ANTLR Lexer rules somewhat resemble REGEX, but definitely are not REGEXs.
Try:
Characters need to be enclosed in
'
marks (with the exception of set notation (characters between[
and]
)