2013-02-21 2 views
2

Мой вопрос об использовании ANT с ANTLR3.Как использовать муравей с antlr3

Я скачал муравейник antlr3 и поместить его в каталог

eclipse-jee-helios-SR2-win32-x86_64\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\lib 

В моем build.xml сайте:

`<path id="classpath"> 
    <pathelement location="${lib}/antlr-3.4-complete.jar"/> 
    <pathelement location="${lib}/ant-antlr3.jar"/> 
</ path>` 

    `<target name="antlr" depends="init"> 
    <antlr: ant-antlr3 xmlns: antlr = "antlib: org/apache/tools/ant/antlr" 
    target = "$ {Analyzers}/AnalizadorLexer.g" 
    outputdirectory = "$ {AnalizadoresBuild}" 
    verbose = "true"> 
    <classpath refid="classpath"/> 
    </ antlr: ant-antlr3> 
</ target>` 

Запуск цели Antlr получает эту ошибку:

BUILD FAILED 
C: \ Users \ melmar \ Documents \ workspace \ PL \ Prac12 \ build_pol.xml: 68: Problem: failed to create task or type antlib: org/apache/tools/ant/antlr: ant-antlr3 
Cause: The name is undefined. 
Action: Check the spelling. 
Action: Check That any custom tasks/types Have Been declared. 
Action: Check That any <presetdef>/declarations have taken place <macrodef>. 
No types or tasks Have Been In This namespace defined yet 
This appears to be an antlib declaration. 
Action: Check That the Implementing library exists in one of: 

     -C: \ Users \ melmar \. Ant \ lib (don´t exist) 
     -a directory added on the command line argument With The-lib 

Не стесняйтесь, кто-нибудь знает, что делать ?, Не нашел ant-antlr3 в classpath

ответ

1

Я не использую antlr задачу, а просто поставить ANTLR JAR в libs, а затем сделать что-то вроде этого:

<path id="classpath"> 

    <!-- more entries here --> 

    <fileset dir="lib"> 
     <include name="*.jar" /> 
    </fileset> 
</path> 

<target name="generate"> 
    <echo>generating the parser and lexer</echo> 
    <java classname="org.antlr.Tool" fork="true" failonerror="true"> 
     <arg value="-fo" /> 
     <arg value="path/to/output/generated/files" /> 
     <arg value="path/to/Grammar.g" /> 
     <classpath refid="classpath" /> 
    </java> 
</target> 
+1

я делаю то же самое, но я и он установлен автоматически загрузить инструмент ANTLR в папку lib во время сборки, если она еще не существует (или устарела), поэтому мне не нужно сохранять библиотеку в исходном элементе управления. –

+1

Пример 'build.xml', включая автоматическую загрузку и полную проверку: https://github.com/antlr/stringtemplate4/blob/master/build.xml –

+0

@ 280Z28, это опрятная идея. «Ant-a-la-Maven», так сказать :) –

Смежные вопросы