Skip to main content
summaryrefslogtreecommitdiffstats
blob: 98ca77680a587765f9948c792716e74e4c119ef6 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!--
 Copyright (c) 2006, 2008 IBM Corporation and others.
 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Eclipse Public License v1.0
 which accompanies this distribution, and is available at
 http://www.eclipse.org/legal/epl-v10.html

 Contributors:
     IBM Corporation - initial API and implementation
-->

<project name="CDT Extensible LR Parser Framework" basedir=".">
    <description>Generates LPG parsers from grammar files</description>
	
	
	<fail unless="lpg_exe">
		Property $${lpg_exe} not set.
		This property must be set to the full path to the LPG generator executable.
	</fail>
	
	<fail unless="lpg_template">
		Property $${lpg_template} not set.
		This property must be set to the full path to the LPG templates folder.
	</fail>
	
	<property name="c99_location" value="../src/org/eclipse/cdt/internal/core/dom/lrparser/c99"/>
	<property name="gcc_location" value="../src/org/eclipse/cdt/internal/core/dom/lrparser/gcc"/>
	<property name="cpp_location" value="../src/org/eclipse/cdt/internal/core/dom/lrparser/cpp"/>
	<property name="gpp_location" value="../src/org/eclipse/cdt/internal/core/dom/lrparser/gpp"/>
		
	<target name="all" depends="c99, gcc, cpp, gpp"/>
	
	<target name="clean_l_files">
		<delete>
			<fileset dir="${c99_location}" includes="**/*.l"/>
			<fileset dir="${gcc_location}" includes="**/*.l"/>
			<fileset dir="${cpp_location}" includes="**/*.l"/>
			<fileset dir="${gpp_location}" includes="**/*.l"/>
		</delete>
	</target>
	
	
	<target name="c99">
		<description>Generate the C99 parser</description>
		<!-- Generate main parser -->
		<antcall target="generate_c99">
            <param name="grammar_name" value="C99Parser"/>
		</antcall>
		<!-- Generate parser for disambiguating declarations vs expression statements -->
		<antcall target="generate_c99">
            <param name="grammar_name" value="C99ExpressionParser"/>
		</antcall>
		<!-- Generate parser for disambiguating cast expressions vs binary expressions-->
		<antcall target="generate_c99">
            <param name="grammar_name" value="C99NoCastExpressionParser"/>
		</antcall>
		<!-- Generate parser for disambiguating sizeof expressions -->
		<antcall target="generate_c99">
            <param name="grammar_name" value="C99SizeofExpressionParser"/>
		</antcall>
	</target>
	
	<target name="generate_c99">
		<antcall target="generate">
			<param name="grammar_dir" value="c99"/>
			<param name="output_dir" value="${c99_location}"/>
			<param name="grammar_name" value="${grammar_name}"/>
		</antcall>
	</target>

	
	<target name="gcc">
		<description>Generate the GCC parser</description>
		<!-- Generate main parser -->
		<antcall target="generate_gcc">
            <param name="grammar_name" value="GCCParser"/>
		</antcall>
	</target>
	
	
	<target name="generate_gcc">
		<antcall target="generate">
			<param name="grammar_dir" value="gcc"/>
			<param name="output_dir" value="${gcc_location}"/>
			<param name="grammar_name" value="${grammar_name}"/>
		</antcall>
	</target>
	

	<target name="cpp">
		<description>Generate the C++ parser</description>
		<antcall target="generate_cpp">
			<param name="grammar_name" value="CPPParser"/>
		</antcall>
		<!-- Generate parser for disambiguating declarations vs expression statements -->
		<antcall target="generate_cpp">
            <param name="grammar_name" value="CPPExpressionParser"/>
		</antcall>
		<!-- Generate parser for disambiguating cast expressions vs binary expressions-->
		<antcall target="generate_cpp">
            <param name="grammar_name" value="CPPNoCastExpressionParser"/>
		</antcall>
		<!-- Generate parser for disambiguating sizeof expressions -->
		<antcall target="generate_cpp">
            <param name="grammar_name" value="CPPSizeofExpressionParser"/>
		</antcall>
		<!-- Generate parser for disambiguating declarators -->
		<antcall target="generate_cpp">
            <param name="grammar_name" value="CPPNoFunctionDeclaratorParser"/>
		</antcall>
		<!-- Generate parser for disambiguating template parameters -->
		<antcall target="generate_cpp">
            <param name="grammar_name" value="CPPTemplateTypeParameterParser"/>
		</antcall>
	</target>
	
	<target name="generate_cpp">
		<antcall target="generate">
			<param name="grammar_dir" value="cpp"/>
			<param name="output_dir" value="${cpp_location}"/>
			<param name="grammar_name" value="${grammar_name}"/>
		</antcall>
	</target>
	
	
	<target name="gpp">
		<description>Generate the GCC parser</description>
		<!-- Generate main parser -->
		<antcall target="generate_gpp">
            <param name="grammar_name" value="GPPParser"/>
		</antcall>
	</target>
	
	
	<target name="generate_gpp">
		<antcall target="generate">
			<param name="grammar_dir" value="gpp"/>
			<param name="output_dir" value="${gpp_location}"/>
			<param name="grammar_name" value="${grammar_name}"/>
		</antcall>
	</target>
	

	
	<target name="generate">
		<property name="grammar_file" value="${grammar_dir}/${grammar_name}.g"/>
		<echo message="lpg_exe=${lpg_exe}"/>
		<echo message="lpg_template=${lpg_template}"/>
		<echo message="grammar_file=${grammar_file}.g"/>
		<echo message="output_dir=${output_dir}"/>

		<exec executable="${lpg_exe}">
			<arg value="${grammar_file}"/>
			<env key="LPG_TEMPLATE" path="${lpg_template}"/>
			
		</exec>
		
		<move overwrite="true" toDir="${output_dir}">
		    <fileset dir=".">
			    <include name="${grammar_name}*.*"/>
			</fileset>
		</move>
	</target> 
	
</project>  

Back to the top