Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 96f11442b79b5fd6b369f510cbcd29d87b976e1a (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
<!--
 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" default="both" 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="cpp_location" value="../src/org/eclipse/cdt/internal/core/dom/lrparser/cpp"/>

	
	<target name="clean_l_files">
		<delete>
			<fileset dir="${c99_location}" includes="**/*.l"/>
			<fileset dir="${cpp_location}" includes="**/*.l"/>
		</delete>
	</target>
	
	
	<target name="both" depends="cpp, c99">
		<description>Generates the C99 and C++ parsers</description>	
		<echo message="Done"/>
	</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="C99ExpressionStatementParser"/>
		</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="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="CPPExpressionStatementParser"/>
		</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>
	</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="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="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