Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: dart/language/grammar/examples.xsl

Issue 10917035: Remove language directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/language/grammar/example.dart ('k') | dart/language/grammar/stringbuffer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!-- Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 for details. All rights reserved. Use of this source code is governed by a
3 BSD-style license that can be found in the LICENSE file. -->
4 <xsl:stylesheet version="1.0"
5 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
6
7 <xsl:output method="text"/>
8
9 <xsl:template match="GUIDE">
10 <xsl:apply-templates select="//DART_CODE_SNIPPET"/>
11 </xsl:template>
12
13 <xsl:template match="//OBSOLETE//DART_CODE_SNIPPET"/>
14 <xsl:template match="//NO_GRAMMAR_CHECK//DART_CODE_SNIPPET"/>
15 <xsl:template match="OBSOLETE" mode="dart_untyped"/>
16 <xsl:template match="NO_GRAMMAR_CHECK" mode="dart_typed"/>
17 <xsl:template match="OBSOLETE" mode="dart_untyped"/>
18 <xsl:template match="NO_GRAMMAR_CHECK" mode="dart_typed"/>
19
20 <xsl:template match="INT" mode="dart_typed">int </xsl:template>
21 <xsl:template match="INT" mode="dart_untyped"><xsl:value-of select="@alt"/></x sl:template>
22 <xsl:template match="VINT" mode="dart_typed">int</xsl:template>
23 <xsl:template match="VINT" mode="dart_untyped">var</xsl:template>
24 <xsl:template match="DOUBLE" mode="dart_typed">double </xsl:template>
25 <xsl:template match="DOUBLE" mode="dart_untyped"><xsl:value-of select="@alt"/> </xsl:template>
26 <xsl:template match="VDOUBLE" mode="dart_typed">double</xsl:template>
27 <xsl:template match="VDOUBLE" mode="dart_untyped">var</xsl:template>
28 <xsl:template match="BOOL" mode="dart_typed">bool </xsl:template>
29 <xsl:template match="BOOL" mode="dart_untyped"><xsl:value-of select="@alt"/></ xsl:template>
30 <xsl:template match="VBOOL" mode="dart_typed">bool</xsl:template>
31 <xsl:template match="VBOOL" mode="dart_untyped">var</xsl:template>
32 <xsl:template match="STRING" mode="dart_typed">String </xsl:template>
33 <xsl:template match="STRING" mode="dart_untyped"><xsl:value-of select="@alt"/> </xsl:template>
34 <xsl:template match="VSTRING" mode="dart_typed">String</xsl:template>
35 <xsl:template match="VSTRING" mode="dart_untyped">var</xsl:template>
36 <xsl:template match="NUMBER" mode="dart_typed">Number </xsl:template>
37 <xsl:template match="NUMBER" mode="dart_untyped"><xsl:value-of select="@alt"/> </xsl:template>
38 <xsl:template match="VNUMBER" mode="dart_typed">Number</xsl:template>
39 <xsl:template match="VNUMBER" mode="dart_untyped">var</xsl:template>
40 <xsl:template match="OBJECT" mode="dart_typed">Object </xsl:template>
41 <xsl:template match="OBJECT" mode="dart_untyped"><xsl:value-of select="@alt"/> </xsl:template>
42 <xsl:template match="VOBJECT" mode="dart_typed">Object</xsl:template>
43 <xsl:template match="VOBJECT" mode="dart_untyped">var</xsl:template>
44 <xsl:template match="VOID" mode="dart_typed">void </xsl:template>
45 <xsl:template match="VOID" mode="dart_untyped"></xsl:template>
46 <xsl:template match="T" mode="dart_typed"><xsl:value-of select="@t"/><xsl:appl y-templates/></xsl:template>
47 <xsl:template match="T" mode="dart_untyped"><xsl:value-of select="@alt"/></xsl :template>
48 <xsl:template match="TYPE" mode="dart_typed"><xsl:value-of select="@t"/><xsl:a pply-templates/></xsl:template>
49 <xsl:template match="TYPE" mode="dart_untyped"><xsl:value-of select="@alt"/></ xsl:template>
50 <xsl:template match="V" mode="dart_typed"><xsl:value-of select="@t"/><xsl:appl y-templates/></xsl:template>
51 <xsl:template match="V" mode="dart_untyped">var</xsl:template>
52
53 <xsl:template match="STATEMENTS" mode="dart_untyped">
54 class $ {
55 $() {
56 <xsl:apply-templates mode="dart_untyped"/>
57 }
58 }
59 </xsl:template>
60 <xsl:template match="STATEMENTS" mode="dart_typed">
61 class $ {
62 $() {
63 <xsl:apply-templates mode="dart_typed"/>
64 }
65 }
66 </xsl:template>
67
68 <xsl:template match="EXPRESSION" mode="dart_untyped">
69 class $ {
70 $() {
71 return <xsl:apply-templates mode="dart_untyped"/>
72 ;
73 }
74 }
75 </xsl:template>
76 <xsl:template match="EXPRESSION" mode="dart_typed">
77 class $ {
78 $() {
79 return <xsl:apply-templates mode="dart_typed"/>
80 ;
81 }
82 }
83 </xsl:template>
84
85 <xsl:template match="DART_CODE_SNIPPET">
86 <xsl:value-of select="'// Typed&#xA;'"/>
87 <xsl:call-template name="print_without_leading_chars">
88 <xsl:with-param name="text">
89 <xsl:apply-templates mode="dart_typed"/>
90 </xsl:with-param>
91 <xsl:with-param name="strip" select="1"/>
92 <xsl:with-param name="is_firstline" select="1"/>
93 <xsl:with-param name="trim_count">
94 <xsl:call-template name="num_leading_spaces">
95 <xsl:with-param name="max_so_far" select="1000"/>
96 <xsl:with-param name="text">
97 <xsl:apply-templates mode="dart_typed"/>
98 </xsl:with-param>
99 </xsl:call-template>
100 </xsl:with-param>
101 </xsl:call-template>
102 <xsl:value-of select="'&#xA;&#xA;'"/>
103 <xsl:value-of select="'// Untyped&#xA;'"/>
104 <xsl:call-template name="print_without_leading_chars">
105 <xsl:with-param name="text">
106 <xsl:apply-templates mode="dart_untyped"/>
107 </xsl:with-param>
108 <xsl:with-param name="strip" select="1"/>
109 <xsl:with-param name="is_firstline" select="1"/>
110 <xsl:with-param name="trim_count">
111 <xsl:call-template name="num_leading_spaces">
112 <xsl:with-param name="max_so_far" select="1000"/>
113 <xsl:with-param name="text">
114 <xsl:apply-templates mode="dart_untyped"/>
115 </xsl:with-param>
116 </xsl:call-template>
117 </xsl:with-param>
118 </xsl:call-template>
119 <xsl:value-of select="'&#xA;&#xA;'"/>
120 </xsl:template>
121
122 <!-- Given text, evaluates to the number of leading spaces. -->
123 <xsl:template name="num_leading_spaces_one_line">
124 <xsl:param name="text"/>
125 <xsl:param name="current_count"/>
126 <xsl:choose>
127 <xsl:when test="starts-with($text, ' ')">
128 <xsl:call-template name="num_leading_spaces_one_line">
129 <xsl:with-param name="text" select="substring($text, 2)"/>
130 <xsl:with-param name="current_count" select="$current_count + 1"/>
131 </xsl:call-template>
132 </xsl:when>
133 <xsl:otherwise>
134 <xsl:value-of select="$current_count"/>
135 </xsl:otherwise>
136 </xsl:choose>
137 </xsl:template>
138
139 <!-- Given a block of text, each line terminated by \n, evaluates to
140 the indentation-level of that text; that is, the largest number
141 n such that every non-blank line starts with at least n spaces. -->
142 <xsl:template name="num_leading_spaces">
143 <xsl:param name="text"/>
144 <xsl:param name="max_so_far"/>
145 <!-- TODO(csilvers): deal with case text doesn't end in a newline -->
146 <xsl:variable name="line" select="substring-before($text, '&#xA;')"/>
147 <xsl:variable name="rest" select="substring-after($text, '&#xA;')"/>
148 <xsl:variable name="num_spaces_this_line">
149 <xsl:choose>
150 <xsl:when test="$line=''">
151 <xsl:value-of select="$max_so_far"/>
152 </xsl:when>
153 <xsl:otherwise>
154 <xsl:call-template name="num_leading_spaces_one_line">
155 <xsl:with-param name="text" select="$line"/>
156 <xsl:with-param name="current_count" select="0"/>
157 </xsl:call-template>
158 </xsl:otherwise>
159 </xsl:choose>
160 </xsl:variable>
161 <xsl:variable name="new_max_so_far">
162 <xsl:choose>
163 <xsl:when test="$num_spaces_this_line &lt; $max_so_far">
164 <xsl:value-of select="$num_spaces_this_line"/>
165 </xsl:when>
166 <xsl:otherwise>
167 <xsl:value-of select="$max_so_far"/>
168 </xsl:otherwise>
169 </xsl:choose>
170 </xsl:variable>
171 <!-- now check if we're on the last line, and if not, recurse -->
172 <xsl:if test="$rest=''">
173 <xsl:value-of select="$new_max_so_far"/>
174 </xsl:if>
175 <xsl:if test="not($rest='')">
176 <xsl:call-template name="num_leading_spaces">
177 <xsl:with-param name="text" select="$rest"/>
178 <xsl:with-param name="max_so_far" select="$new_max_so_far"/>
179 </xsl:call-template>
180 </xsl:if>
181 </xsl:template>
182
183 <!-- Given a block of text, each line terminated by \n, and a number n,
184 emits the text with the first n characters of each line
185 deleted. If strip==1, then we omit blank lines at the beginning
186 and end of the text (but not the middle!) -->
187 <xsl:template name="print_without_leading_chars">
188 <xsl:param name="text"/>
189 <xsl:param name="trim_count"/>
190 <xsl:param name="strip"/>
191 <xsl:param name="is_firstline"/>
192 <!-- TODO(csilvers): deal with case text doesn't end in a newline -->
193 <xsl:variable name="line" select="substring-before($text, '&#xA;')"/>
194 <xsl:variable name="rest" select="substring-after($text, '&#xA;')"/>
195 <xsl:variable name="stripped_line" select="substring($line, $trim_count+1)"/ >
196 <xsl:choose>
197 <!-- $line (or $rest) is considered empty if we'd trim the entire line -->
198 <xsl:when test="($strip = '1') and ($is_firstline = '1') and
199 (string-length($line) &lt;= $trim_count)">
200 </xsl:when>
201 <xsl:when test="($strip = '1') and
202 (string-length($rest) &lt;= $trim_count)">
203 <xsl:value-of select="$stripped_line"/>
204 </xsl:when>
205 <xsl:otherwise>
206 <xsl:value-of select="$stripped_line"/>
207 <xsl:text>&#xA;</xsl:text>
208 </xsl:otherwise>
209 </xsl:choose>
210 <xsl:if test="not($rest='')">
211 <xsl:call-template name="print_without_leading_chars">
212 <xsl:with-param name="text" select="$rest"/>
213 <xsl:with-param name="trim_count" select="$trim_count"/>
214 <xsl:with-param name="strip" select="$strip"/>
215 <xsl:with-param name="is_firstline" select="0"/>
216 </xsl:call-template>
217 </xsl:if>
218 </xsl:template>
219
220 </xsl:stylesheet>
OLDNEW
« no previous file with comments | « dart/language/grammar/example.dart ('k') | dart/language/grammar/stringbuffer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698