开发者

Dynamicall updating rules at run-time

开发者 https://www.devze.com 2022-12-12 23:25 出处:网络
When sending an AT command it is normally terminated by \\r\\n, but, in fact,these are really two \'register variables\' S3 and S4.

When sending an AT command it is normally terminated by \r\n, but, in fact, these are really two 'register variables' S3 and S4.

By default S3=='\r' and S4=='\n', but the user can change these at runtime with the command ATSx=

How can I handle this in my Antlr lexer/parser?

Each command has the form AT[parameters]S3S4, how can I handle that if the u开发者_如何学Goser changes the value of S3 or S4?

Thanks in advance for any help...


No, there's no such option to dynamically change lexer- or parser-rules AFAIK. Of course, there are work-arounds possible like re-creating the lexer/parser upon changing register variables', but it won't be pretty, I guess...


Edit

mawg wrote

re-creating the lexr & poarser (well, lexer only, I guess) - could you leaborate on that?

Rewriting the original grammar file (only the lexer rules, as you correctly mention) and recompiling it on the fly. See: http://java.sun.com/javase/6/docs/api/javax/tools/JavaCompiler.html

0

精彩评论

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

关注公众号