[ANTLR] ANTLR을 이용한 T-SQL 분석 자바 프로젝트 환경설정

An ANTLR4 grammar for T-SQL


.g4 파일 저장

  • src/main/antlr에 저장


build.gradle

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id 'java'
    id 'idea'
    id 'antlr'
}

group 'org.antlr.tsql.java-parser'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation group: 'org.slf4j', name:'slf4j-api', version: '1.7.2'
    antlr "org.antlr:antlr4:4.7.1"
    compile "org.antlr:antlr4-runtime:4.7.1"

    compileOnly 'org.projectlombok:lombok:1.18.20'
    annotationProcessor 'org.projectlombok:lombok:1.18.20'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
    testCompileOnly 'org.projectlombok:lombok:1.18.20'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
}

test {
    useJUnitPlatform()
}

generateGrammarSource {
    arguments += ['-package', 'com.antlr.tsql.java-parser']
    outputDirectory = new File(buildDir.toString() + "/generated-src/antlr/main/com/antlr/tsql/java-parser")
}
  • generateGrammarSource task 실행 후 build task

Comments