티스토리 뷰
@header {
package xxx;
}
@members {
private AppBase appBase;
public void SetAppBase(AppBase appBase) {
this.appBase = appBase;
}
}
@lexer::header {
package xxx;
}
packageDeclaration
: 'package' qualifiedName {
System.out.println("--" + $qualifiedName.result.getLine() + "/" + $qualifiedName.result.getQualifiedName());
}
';'
;
qualifiedName returns [AstQualifiedName result]
scope {
AstQualifiedName current;
}
@init {
$qualifiedName::current = new AstQualifiedName();
}
: IDENTIFIER {
$qualifiedName::current.setLine($IDENTIFIER.getLine());
$qualifiedName::current.addIdentifier($IDENTIFIER.getText());
}
('.' IDENTIFIER {
$qualifiedName::current.addIdentifier($IDENTIFIER.getText());
}
)* {
$result = $qualifiedName::current;
}
;
-----------------------------------------------------------------------------------
package xxx;
import xxx.AppBase;
import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.RuleReturnScope;
import org.antlr.runtime.Token;
import org.antlr.runtime.TokenStream;
import org.antlr.runtime.tree.CommonErrorNode;
import org.antlr.runtime.tree.CommonTreeAdaptor;
import org.antlr.runtime.tree.TreeAdaptor;
public class JavaTestMain {
public static void main(String[] args) throws Exception {
AppBase appBase = new AppBase();
ANTLRFileStream fileStream = new ANTLRFileStream("ASTMain.java");
JavaLexer lexer = new JavaLexer(fileStream);
CommonTokenStream tokens = new CommonTokenStream(lexer);
JavaParser parser = new JavaParser(tokens);
parser.SetAppBase(appBase);
parser.compilationUnit();
}
}
- Total
- Today
- Yesterday
- JavaScript
- Linux
- Mac
- sas2009
- 서울오토살롱
- 레이싱모델 익스트림 포토 페스티벌
- BPI-M4
- 송주경
- oracle
- Spring
- Spring MVC
- Delphi Tip
- android
- NDK
- MySQL
- KOBA
- 일본여행
- 지스타2007
- ubuntu
- koba2010
- SAS
- flex
- 튜닝쇼 2008
- ble
- 동경
- 전예희
- Xcode
- Delphi
- Java
- ffmpeg
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |