Insert picture description here

Antlr missing XXX at and mismatched input ” analysis of several error conditions_mismatched input expecting antlr_FserSuN’s blog

class=”markdown_views prism-atom-one-dark”> The Antlr version used in this article is 4.7.2 1 lexical rules are ambiguous 1.1 Problem Background The demo comes from the first section of Chapter 7, an example of a property file. I modified the original grammar as follows. grammar Demo; file : prop+; prop : ID ‘=’ STRING; ID : [a-z]+; STRING : [a-z0-9]+; Validation of input text in the Grammar Console resulted in an error. Enter: abc=abc Error message: line 1:4 missing STRING at ‘abc’ line 1:7 mismatched input ” expecting ‘=’ The syntax analysis tree at this time is as follows: 1.2 Analysis After entering the character stream abc=abc, due to long-term lack of use of relevant tools and theoretical review. According to the Chinese grammar of the grammar file, it is wrong to think that the generated word stream is id,=,string. and match in that order. I thought it met ID, matched to abc, = matched to the character =, and finally encountered STRING to match the lexical definition of STRING. After flipping through the book, I thought about it, this must be a problem of data word recognition error. Recall that the whole process is symbol flow -> word flow -> syntax…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索