javalex.g
上传用户:afrynkmhm
上传日期:2007-01-06
资源大小:1262k
文件大小:1k
- header {
- #include "antlr/TokenStreamSelector.hpp"
- }
- options {
- language="Cpp";
- }
- class DemoJavaLexer extends Lexer;
- options {
- k=2;
- importVocab = Common;
- exportVocab = Java;
- }
- tokens {
- INT="int";
- }
- {
- private:
- ANTLR_USE_NAMESPACE(antlr)TokenStreamSelector* selector;
- public:
- void setSelector(ANTLR_USE_NAMESPACE(antlr)TokenStreamSelector* selector_) {
- selector=selector_;
- }
- }
- JAVADOC_OPEN
- : "/**" {selector->push("doclexer");}
- ;
- ID : ('a'..'z')+ ;
- SEMI: ';' ;
- WS_ : ( ' '
- | 't'
- | 'f'
- // handle newlines
- | ( "rn" // Evil DOS
- | 'r' // Macintosh
- | 'n' // Unix (the right way)
- )
- { newline(); }
- )
- { $setType(ANTLR_USE_NAMESPACE(antlr)Token::SKIP); }
- ;