Rebuilding Lexer/Parser

3 views
Skip to first unread message

Tom Davies

unread,
Oct 8, 2007, 6:46:09 AM10/8/07
to CAL Language Discussion
Is there a target in the ant files for rebuilding CALLexer.java and
CALParser.java from the .g files? I couldn't find one...

Thanks,
Tom

Bo Ilic

unread,
Oct 8, 2007, 2:43:59 PM10/8/07
to CAL Language Discussion
Hi Tom,

I think you're correct that there isn't one. For various reasons, the
build scripts don't generate all artifacts from original sources, just
those whose original sources are Java or CAL. For example, we use a
variety of document formats (MS Word, DocBook, LaTex) and these are
not converted to PDFs by the build.

To re-build the grammar files you need to run the antlr JAR on the 3
grammar files in order: CALDoc.g, CAL.g and CALTreeParser.g
redirecting output to the appropriate location (i.e. where
CALParser.java etc are currently located). I can send you the script I
use for this tomorrow when I'm back at work (it is a holiday here
today).

Cheers,
Bo

Tom Davies

unread,
Oct 8, 2007, 7:10:27 PM10/8/07
to CAL Language Discussion

On Oct 9, 4:43 am, Bo Ilic <bo.i...@businessobjects.com> wrote:
> I can send you the script I
> use for this tomorrow when I'm back at work (it is a holiday here
> today).

That would be handy, thanks!

Tom

Bo Ilic

unread,
Oct 9, 2007, 3:59:29 PM10/9/07
to CAL Language Discussion
Here is the text of the .bat file I use on my machine to build the
antlr grammars. This should give the general idea, but need
modification depending on platform, jvm etc.

Bo

echo on

rem change to the antlr grammar directory so that
CALCommonTokenTypes.txt can be found
d:
cd /D "D:\dev\quark2\IW_AddOn\PI\Quark_Platform\CAL_Platform\antlr
grammar"
c:\j2sdk1.4.2_06\bin\java -cp d:\dev\quark2\IW_AddOn\PI\Quark_Platform
\export\import\IW_AddOn_Stable\win32_x86\release\bin\External\java
\antlr\antlr-2.7.6\antlr.jar antlr.Tool -o "D:\dev\quark2\IW_AddOn\PI
\Quark_Platform\CAL_Platform\src\org\openquark\cal\compiler" "D:\dev
\quark2\IW_AddOn\PI\Quark_Platform\CAL_Platform\antlr grammar\CAL.g"
c:\j2sdk1.4.2_06\bin\java -cp d:\dev\quark2\IW_AddOn\PI\Quark_Platform
\export\import\IW_AddOn_Stable\win32_x86\release\bin\External\java
\antlr\antlr-2.7.6\antlr.jar antlr.Tool -o "D:\dev\quark2\IW_AddOn\PI
\Quark_Platform\CAL_Platform\src\org\openquark\cal\compiler" "D:\dev
\quark2\IW_AddOn\PI\Quark_Platform\CAL_Platform\antlr grammar
\CALDoc.g"
c:\j2sdk1.4.2_06\bin\java -cp d:\dev\quark2\IW_AddOn\PI\Quark_Platform
\export\import\IW_AddOn_Stable\win32_x86\release\bin\External\java
\antlr\antlr-2.7.6\antlr.jar antlr.Tool -o "D:\dev\quark2\IW_AddOn\PI
\Quark_Platform\CAL_Platform\src\org\openquark\cal\compiler" "D:\dev
\quark2\IW_AddOn\PI\Quark_Platform\CAL_Platform\antlr grammar
\CALTreeParser.g"

pause

Tom Davies

unread,
Oct 15, 2007, 1:15:26 AM10/15/07
to CAL Language Discussion
Thanks for that -- here's one which works for me on OS X:

#!/bin/sh
# assume this is being run from ..../Quark/src/export/OpenQuark_Build/
Build_Scripts
if [ -z QUARK_SRC ]
then
QUARK_SRC=../../../..
fi
GRAMMAR_DIR="$QUARK_SRC/src/CAL_Platform/antlr grammar"
if [ ! -d "$GRAMMAR_DIR" ]
then
echo "Expected to find grammars at $GRAMMAR_DIR";
exit 1;
fi

ANTLRJAR=$QUARK_SRC/src/import/Titan_Research/win32_x86/release/bin/
External/java/antlr.jar

OUTPUT_DIR=$QUARK_SRC/src/CAL_Platform/src/org/openquark/cal/compiler

# change to the antlr grammar directory so that
CALCommonTokenTypes.txt can be found
cd "$GRAMMAR_DIR"

java -cp $ANTLRJAR antlr.Tool -o $OUTPUT_DIR "$GRAMMAR_DIR/CAL.g"

java -cp $ANTLRJAR antlr.Tool -o $OUTPUT_DIR "$GRAMMAR_DIR/CALDoc.g"

java -cp $ANTLRJAR antlr.Tool -o $OUTPUT_DIR "$GRAMMAR_DIR/
CALTreeParser.g"

Reply all
Reply to author
Forward
0 new messages