tags:

views:

37

answers:

1

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 user changes the value of S3 or S4?

Thanks in advance for any help...

+1  A: 

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

Bart Kiers
Mawg
Mawg