• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
2   Use of this source code is governed by a BSD-style license that can be
3  found in the LICENSE file. */
4
5/* Test Enum productions
6
7Run with --test to generate an AST and verify that all comments accurately
8reflect the state of the Nodes.
9
10BUILD Type(Name)
11This comment signals that a node of type <Type> is created with the
12name <Name>.
13
14ERROR Error String
15This comment signals that a error of <Error String> is generated.  The error
16is not assigned to a node, but are expected in order.
17
18PROP Key=Value
19This comment signals that a property has been set on the Node such that
20<Key> = <Value>.
21
22TREE
23Type(Name)
24  Type(Name)
25  Type(Name)
26    Type(Name)
27    ...
28This comment signals that a tree of nodes matching the BUILD comment
29symatics should exist.  This is an exact match.
30*/
31
32/* TREE
33 *Enum(MealType1)
34 *  EnumItem(rice)
35 *  EnumItem(noodles)
36 *  EnumItem(other)
37*/
38enum MealType1 {
39  /* BUILD EnumItem (rice) */
40  "rice",
41  /* BUILD EnumItem (noodles) */
42  "noodles",
43  /* BUILD EnumItem(other) */
44  "other"
45};
46
47/* BUILD Error(Enum missing name.) */
48/* ERROR Enum missing name. */
49enum {
50  "rice",
51  "noodles",
52  "other"
53};
54
55/* TREE
56 *Enum(MealType2)
57 *  EnumItem(rice)
58 *  EnumItem(noodles)
59 *  EnumItem(other)
60*/
61enum MealType2 {
62  /* BUILD EnumItem(rice) */
63  "rice",
64  /* BUILD EnumItem(noodles) */
65  "noodles",
66  /* BUILD EnumItem(other) */
67  "other"
68};
69
70/* TREE
71 *Enum(TrailingComma)
72 *  EnumItem(rice)
73 *  EnumItem(noodles)
74 *  EnumItem(other)
75*/
76enum TrailingComma {
77  "rice",
78  "noodles",
79  "other",
80};
81
82/* BUILD Error(Unexpected string "noodles" after string "rice".) */
83/* ERROR Unexpected string "noodles" after string "rice". */
84enum MissingComma {
85  "rice"
86  "noodles",
87  "other"
88};
89
90/* BUILD Error(Unexpected "," after ",".) */
91/* ERROR Unexpected "," after ",". */
92enum ExtraComma {
93  "rice",
94  "noodles",
95  ,"other",
96};
97
98/* BUILD Error(Unexpected keyword "interface" after "{".) */
99/* ERROR Unexpected keyword "interface" after "{". */
100enum ExtraComma {
101  interface,
102  "noodles",
103  ,"other",
104};
105
106/* BUILD Error(Unexpected identifier "somename" after "{".) */
107/* ERROR Unexpected identifier "somename" after "{". */
108enum ExtraComma {
109  somename,
110  "noodles",
111  ,"other",
112};
113
114/* BUILD Enum(MealType3) */
115enum MealType3 {
116  /* BUILD EnumItem(rice) */
117  "rice",
118  /* BUILD EnumItem(noodles) */
119  "noodles",
120  /* BUILD EnumItem(other) */
121  "other"
122};
123
124