antlr4_compile.sh 4.56 KB
Newer Older
1
2
#!/bin/bash
###############################################################################
Adam Knapp's avatar
Adam Knapp committed
3
# Copyright (c) 2000-2021 Ericsson Telecom AB
4
# All rights reserved. This program and the accompanying materials
5
# are made available under the terms of the Eclipse Public License v2.0
6
# which accompanies this distribution, and is available at
7
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
# Contributors:
#   Lovassy, Arpad
#
###############################################################################

###############################################################################
# Script to compile all the .g4 files in the Titan EclipsePlug-ins repo.
#
# Example usage:
#   cd <titan.EclipsePlug-ins project root>
#   Tools/antlr4_compile.sh
###############################################################################
set -e
set -o pipefail

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
ANTLR_VERSION=4.3

while :
do
        case $1 in
            -av)
                ANTLR_VERSION=$2
                shift
                ;;
            *)
                break;
        esac
        shift
    done

ANTLR4="java -classpath $HOME/lib/antlr-${ANTLR_VERSION}-complete.jar org.antlr.v4.Tool"

echo Using antlr version $ANTLR_VERSION
42
43
44
45
46
47
48

# script directory
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-which-directory-it-is-stored-in
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

WORKSPACE_PATH=$DIR/..

49
50
51
52
# Titan Runtime
cd $WORKSPACE_PATH/org.eclipse.titan.runtime/src/org/eclipse/titan/runtime/core/cfgparser/
$ANTLR4 RuntimeCfgLexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.runtime.core.cfgparser
$ANTLR4 RuntimeCfgParser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.runtime.core.cfgparser
53
$ANTLR4 RuntimeCfgPreParser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.runtime.core.cfgparser
54
55

# Titan Common
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
cd $WORKSPACE_PATH/org.eclipse.titan.common/src/org/eclipse/titan/common/parsers/cfg/
$ANTLR4 CfgLexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.common.parsers.cfg
$ANTLR4 CfgParser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.common.parsers.cfg

# Titan Designer
# ASN1
cd $WORKSPACE_PATH/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/asn1parser/
$ANTLR4 Asn1Lexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.asn1parser
$ANTLR4 Asn1Parser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.asn1parser

# TTCN3
cd $WORKSPACE_PATH/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/ttcn3parser/
$ANTLR4 PreprocessorDirectiveLexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.ttcn3parser
$ANTLR4 PreprocessorDirectiveParser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.ttcn3parser
$ANTLR4 Ttcn3Lexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.ttcn3parser
$ANTLR4 Ttcn3KeywordlessLexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.ttcn3parser
$ANTLR4 Ttcn3CharstringLexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.ttcn3parser
$ANTLR4 Ttcn3Parser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.ttcn3parser
$ANTLR4 Ttcn3Reparser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.ttcn3parser
Gergo Ujhelyi's avatar
Gergo Ujhelyi committed
75
76
$ANTLR4 PatternStringLexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.ttcn3parser

77
78
79
80
81
# Extension attribute
cd $WORKSPACE_PATH/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/extensionattributeparser/
$ANTLR4 ExtensionAttributeLexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.extensionattributeparser
$ANTLR4 ExtensionAttributeParser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.extensionattributeparser

82
83
84
85
86
# Variant attribute
cd $WORKSPACE_PATH/org.eclipse.titan.designer/src/org/eclipse/titan/designer/parsers/variantattributeparser/
$ANTLR4 VariantAttributeLexer.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.variantattributeparser
$ANTLR4 VariantAttributeParser.g4 -no-listener -no-visitor -encoding UTF-8 -package org.eclipse.titan.designer.parsers.variantattributeparser

earplov's avatar
typo    
earplov committed
87
# Generating ...LexerLogUtil.java files from ...Lexer.java files for resolving token names (OPTIONAL)
88
89
90
cd $WORKSPACE_PATH
$DIR/antlr4_generate_lexerlogutil.pl