source: pyyaml/trunk/examples/pygments-lexer/example.yaml @ 268

Revision 268, 4.9 KB checked in by xi, 7 years ago (diff)

Added a YAML lexer for Pygments.

Line 
1
2#
3# Examples from the Preview section of the YAML specification
4# (http://yaml.org/spec/1.2/#Preview)
5#
6
7# Sequence of scalars
8---
9- Mark McGwire
10- Sammy Sosa
11- Ken Griffey
12
13# Mapping scalars to scalars
14---
15hr:  65    # Home runs
16avg: 0.278 # Batting average
17rbi: 147   # Runs Batted In
18
19# Mapping scalars to sequences
20---
21american:
22  - Boston Red Sox
23  - Detroit Tigers
24  - New York Yankees
25national:
26  - New York Mets
27  - Chicago Cubs
28  - Atlanta Braves
29
30# Sequence of mappings
31---
32-
33  name: Mark McGwire
34  hr:   65
35  avg:  0.278
36-
37  name: Sammy Sosa
38  hr:   63
39  avg:  0.288
40
41# Sequence of sequences
42---
43- [name        , hr, avg  ]
44- [Mark McGwire, 65, 0.278]
45- [Sammy Sosa  , 63, 0.288]
46
47# Mapping of mappings
48---
49Mark McGwire: {hr: 65, avg: 0.278}
50Sammy Sosa: {
51    hr: 63,
52    avg: 0.288
53  }
54
55# Two documents in a stream
56--- # Ranking of 1998 home runs
57- Mark McGwire
58- Sammy Sosa
59- Ken Griffey
60--- # Team ranking
61- Chicago Cubs
62- St Louis Cardinals
63
64# Documents with the end indicator
65---
66time: 20:03:20
67player: Sammy Sosa
68action: strike (miss)
69...
70---
71time: 20:03:47
72player: Sammy Sosa
73action: grand slam
74...
75
76# Comments
77---
78hr: # 1998 hr ranking
79  - Mark McGwire
80  - Sammy Sosa
81rbi:
82  # 1998 rbi ranking
83  - Sammy Sosa
84  - Ken Griffey
85
86# Anchors and aliases
87---
88hr:
89  - Mark McGwire
90  # Following node labeled SS
91  - &SS Sammy Sosa
92rbi:
93  - *SS # Subsequent occurrence
94  - Ken Griffey
95
96# Mapping between sequences
97---
98? - Detroit Tigers
99  - Chicago cubs
100:
101  - 2001-07-23
102? [ New York Yankees,
103    Atlanta Braves ]
104: [ 2001-07-02, 2001-08-12,
105    2001-08-14 ]
106
107# Inline nested mapping
108---
109# products purchased
110- item    : Super Hoop
111  quantity: 1
112- item    : Basketball
113  quantity: 4
114- item    : Big Shoes
115  quantity: 1
116
117# Literal scalars
118--- | # ASCII art
119  \//||\/||
120  // ||  ||__
121
122# Folded scalars
123--- >
124  Mark McGwire's
125  year was crippled
126  by a knee injury.
127
128# Preserved indented block in a folded scalar
129---
130>
131 Sammy Sosa completed another
132 fine season with great stats.
133
134   63 Home Runs
135   0.288 Batting Average
136
137 What a year!
138
139# Indentation determines scope
140---
141name: Mark McGwire
142accomplishment: >
143  Mark set a major league
144  home run record in 1998.
145stats: |
146  65 Home Runs
147  0.278 Batting Average
148
149# Quoted scalars
150---
151unicode: "Sosa did fine.\u263A"
152control: "\b1998\t1999\t2000\n"
153hex esc: "\x0d\x0a is \r\n"
154single: '"Howdy!" he cried.'
155quoted: ' # not a ''comment''.'
156tie-fighter: '|\-*-/|'
157
158# Multi-line flow scalars
159---
160plain:
161  This unquoted scalar
162  spans many lines.
163quoted: "So does this
164  quoted scalar.\n"
165
166# Integers
167---
168canonical: 12345
169decimal: +12_345
170sexagesimal: 3:25:45
171octal: 014
172hexadecimal: 0xC
173
174# Floating point
175---
176canonical: 1.23015e+3
177exponential: 12.3015e+02
178sexagesimal: 20:30.15
179fixed: 1_230.15
180negative infinity: -.inf
181not a number: .NaN
182
183# Miscellaneous
184---
185null: ~
186true: boolean
187false: boolean
188string: '12345'
189
190# Timestamps
191---
192canonical: 2001-12-15T02:59:43.1Z
193iso8601: 2001-12-14t21:59:43.10-05:00
194spaced: 2001-12-14 21:59:43.10 -5
195date: 2002-12-14
196
197# Various explicit tags
198---
199not-date: !!str 2002-04-28
200picture: !!binary |
201 R0lGODlhDAAMAIQAAP//9/X
202 17unp5WZmZgAAAOfn515eXv
203 Pz7Y6OjuDg4J+fn5OTk6enp
204 56enmleECcgggoBADs=
205application specific tag: !something |
206 The semantics of the tag
207 above may be different for
208 different documents.
209
210# Global tags
211%TAG ! tag:clarkevans.com,2002:
212--- !shape
213  # Use the ! handle for presenting
214  # tag:clarkevans.com,2002:circle
215- !circle
216  center: &ORIGIN {x: 73, y: 129}
217  radius: 7
218- !line
219  start: *ORIGIN
220  finish: { x: 89, y: 102 }
221- !label
222  start: *ORIGIN
223  color: 0xFFEEBB
224  text: Pretty vector drawing.
225
226# Unordered sets
227--- !!set
228# sets are represented as a
229# mapping where each key is
230# associated with the empty string
231? Mark McGwire
232? Sammy Sosa
233? Ken Griff
234
235# Ordered mappings
236--- !!omap
237# ordered maps are represented as
238# a sequence of mappings, with
239# each mapping having one key
240- Mark McGwire: 65
241- Sammy Sosa: 63
242- Ken Griffy: 58
243
244# Full length example
245--- !<tag:clarkevans.com,2002:invoice>
246invoice: 34843
247date   : 2001-01-23
248bill-to: &id001
249    given  : Chris
250    family : Dumars
251    address:
252        lines: |
253            458 Walkman Dr.
254            Suite #292
255        city    : Royal Oak
256        state   : MI
257        postal  : 48046
258ship-to: *id001
259product:
260    - sku         : BL394D
261      quantity    : 4
262      description : Basketball
263      price       : 450.00
264    - sku         : BL4438H
265      quantity    : 1
266      description : Super Hoop
267      price       : 2392.00
268tax  : 251.42
269total: 4443.52
270comments:
271    Late afternoon is best.
272    Backup contact is Nancy
273    Billsmer @ 338-4338.
274
275# Another full-length example
276---
277Time: 2001-11-23 15:01:42 -5
278User: ed
279Warning:
280  This is an error message
281  for the log file
282---
283Time: 2001-11-23 15:02:31 -5
284User: ed
285Warning:
286  A slightly different error
287  message.
288---
289Date: 2001-11-23 15:03:17 -5
290User: ed
291Fatal:
292  Unknown variable "bar"
293Stack:
294  - file: TopClass.py
295    line: 23
296    code: |
297      x = MoreObject("345\n")
298  - file: MoreClass.py
299    line: 58
300    code: |-
301      foo = bar
302
Note: See TracBrowser for help on using the repository browser.