libqasm
library for handling cQASM files
cqasm-v1-parser.hpp
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 3.0. */
2 
3 /* Bison interface for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
33 #ifndef YY_CQASM_V1_HOME_DOCS_CHECKOUTS_READTHEDOCS_ORG_USER_BUILDS_LIBQASM_CHECKOUTS_LATEST_CBUILD_SRC_CQASM_CQASM_V1_PARSER_HPP_INCLUDED
34 # define YY_CQASM_V1_HOME_DOCS_CHECKOUTS_READTHEDOCS_ORG_USER_BUILDS_LIBQASM_CHECKOUTS_LATEST_CBUILD_SRC_CQASM_CQASM_V1_PARSER_HPP_INCLUDED
35 /* Debug traces. */
36 #ifndef CQASM_V1DEBUG
37 # if defined YYDEBUG
38 #if YYDEBUG
39 # define CQASM_V1DEBUG 1
40 # else
41 # define CQASM_V1DEBUG 0
42 # endif
43 # else /* ! defined YYDEBUG */
44 # define CQASM_V1DEBUG 0
45 # endif /* ! defined YYDEBUG */
46 #endif /* ! defined CQASM_V1DEBUG */
47 #if CQASM_V1DEBUG
48 extern int cqasm_v1debug;
49 #endif
50 /* "%code requires" blocks. */
51 #line 5 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-v1-parser.y" /* yacc.c:1915 */
52 
57  #include <memory>
58  #include <cstdio>
59  #include <cstdint>
60  #include "cqasm-annotations.hpp"
61  #include "cqasm-v1-ast.hpp"
62  #include "cqasm-v1-parse-helper.hpp"
63  using namespace cqasm::v1::ast;
64  typedef void* yyscan_t;
65 
66  #define YYSTYPE CQASM_V1STYPE
67  #define YYLTYPE CQASM_V1LTYPE
68 
69 
70 #line 71 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-v1-parser.hpp" /* yacc.c:1915 */
71 
72 /* Token type. */
73 #ifndef CQASM_V1TOKENTYPE
74 # define CQASM_V1TOKENTYPE
76  {
77  NEWLINE = 258,
78  VERSION = 259,
79  QUBITS = 260,
80  MAP = 261,
81  VAR = 262,
82  CDASH = 263,
83  COND = 264,
84  IF = 265,
85  ELSE = 266,
86  FOR = 267,
87  FOREACH = 268,
88  WHILE = 269,
89  REPEAT = 270,
90  UNTIL = 271,
91  CONTINUE = 272,
92  BREAK = 273,
93  SET = 274,
94  INT_LITERAL = 275,
96  BAD_NUMBER = 277,
97  STRING_OPEN = 278,
98  STRING_CLOSE = 279,
99  JSON_OPEN = 280,
100  JSON_CLOSE = 281,
103  IDENTIFIER = 284,
104  POWER = 285,
105  INT_DIV = 286,
106  LOGIC_OR = 287,
107  LOGIC_AND = 288,
108  LOGIC_XOR = 289,
109  CMP_GE = 290,
110  CMP_LE = 291,
111  CMP_EQ = 292,
112  CMP_NE = 293,
113  SHL = 294,
114  ARITH_SHR = 295,
115  LOGIC_SHR = 296,
116  ELLIPSIS = 297,
118  END_OF_FILE = 299,
119  UMINUS = 300,
120  UCOMP = 301,
121  UNOT = 302
122  };
123 #endif
124 
125 /* Value type. */
126 #if ! defined CQASM_V1STYPE && ! defined CQASM_V1STYPE_IS_DECLARED
128 union CQASM_V1STYPE
129 {
130 #line 76 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/src/cqasm/src/cqasm-v1-parser.y" /* yacc.c:1915 */
131 
132  char *str;
133  IntegerLiteral *ilit;
134  FloatLiteral *flit;
135  MatrixLiteral *mat;
136  StringBuilder *strb;
137  StringLiteral *slit;
138  JsonLiteral *jlit;
139  Identifier *idnt;
140  FunctionCall *func;
141  Index *indx;
142  UnaryOp *unop;
143  BinaryOp *biop;
144  TernaryCond *tcnd;
145  Expression *expr;
146  ExpressionList *expl;
147  IndexItem *idxi;
148  IndexRange *idxr;
149  IndexEntry *idxe;
150  IndexList *idxl;
151  AnnotationData *adat;
152  Instruction *inst;
153  Bundle *bun;
154  Mapping *map;
155  Variables *vars;
156  Subcircuit *sub;
157  Assignment *asgn;
158  IfElse *ifel;
159  ForLoop *forl;
160  ForeachLoop *fore;
161  WhileLoop *whil;
162  RepeatUntilLoop *repu;
163  BreakStatement *brk;
164  ContinueStatement *cont;
165  Statement *stmt;
166  StatementList *stms;
167  Version *vers;
168  Program *prog;
169 
170 #line 171 "/home/docs/checkouts/readthedocs.org/user_builds/libqasm/checkouts/latest/cbuild/src/cqasm/cqasm-v1-parser.hpp" /* yacc.c:1915 */
171 };
172 # define CQASM_V1STYPE_IS_TRIVIAL 1
173 # define CQASM_V1STYPE_IS_DECLARED 1
174 #endif
175 
176 /* Location type. */
177 #if ! defined CQASM_V1LTYPE && ! defined CQASM_V1LTYPE_IS_DECLARED
179 struct CQASM_V1LTYPE
180 {
181  int first_line;
182  int first_column;
183  int last_line;
184  int last_column;
185 };
186 # define CQASM_V1LTYPE_IS_DECLARED 1
187 # define CQASM_V1LTYPE_IS_TRIVIAL 1
188 #endif
189 
190 
191 
193 
194 #endif /* !YY_CQASM_V1_HOME_DOCS_CHECKOUTS_READTHEDOCS_ORG_USER_BUILDS_LIBQASM_CHECKOUTS_LATEST_CBUILD_SRC_CQASM_CQASM_V1_PARSER_HPP_INCLUDED */
The file version identifier.
Defines the types for the cQASM abstract syntax tree, based on the classes from cqasm::tree.
A floating point literal.
A C-style for loop.
A list of parallel instructions.
Contains annotation objects used within the trees by libqasm.
Represents a JSON literal.
Any kind of instruction.
A mapping (alias) for an expression.
Special/temporary string builder node, used to build strings from fragments and escape sequences whil...
An assignment statement within a loop definition.
int cqasm_v1parse(yyscan_t scanner, cqasm::v1::parser::ParseHelper &helper)
A list of one or more indices.
void * yyscan_t
Any unary operator.
Internal helper class for parsing cQASM files.
Contains helper classes and objects for the lexer and parser generated by flex/bison, as well as the entry points for invoking the parser directly, in case you don&#39;t need semantic analysis.
One or more variable declaration for some type.
Represents a matrix literal.
A single index in an index list.
Any kind of statement.
Represents an annotation.
void * yyscan_t
An inclusive range of indices in an index list.
An entry in an index list.
Any binary operator.
Represents a string literal.
A complete program.
Namespace for the abstract syntax tree node classes.
cqasm_v1tokentype
Indexation operator.
Represents a comma-separated list of expressions.
Any kind of expression.
Ternary conditional operator.