MLIR  20.0.0git
Parser.h
Go to the documentation of this file.
1 //===- Parser.h - MLIR Base Parser Class ------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef MLIR_LIB_ASMPARSER_PARSER_H
10 #define MLIR_LIB_ASMPARSER_PARSER_H
11 
12 #include "ParserState.h"
13 #include "mlir/IR/Builders.h"
15 #include <optional>
16 
17 namespace mlir {
18 namespace detail {
19 //===----------------------------------------------------------------------===//
20 // Parser
21 //===----------------------------------------------------------------------===//
22 
23 /// This class implement support for parsing global entities like attributes and
24 /// types. It is intended to be subclassed by specialized subparsers that
25 /// include state.
26 class Parser {
27 public:
29 
31 
33  : builder(state.config.getContext()), state(state) {}
34 
35  // Helper methods to get stuff from the parser-global state.
36  ParserState &getState() const { return state; }
37  MLIRContext *getContext() const { return state.config.getContext(); }
38  const llvm::SourceMgr &getSourceMgr() { return state.lex.getSourceMgr(); }
39 
40  /// Parse a comma-separated list of elements up until the specified end token.
41  ParseResult
43  function_ref<ParseResult()> parseElement,
44  bool allowEmptyList = true);
45 
46  /// Parse a list of comma-separated items with an optional delimiter. If a
47  /// delimiter is provided, then an empty list is allowed. If not, then at
48  /// least one element will be parsed.
49  ParseResult
51  function_ref<ParseResult()> parseElementFn,
52  StringRef contextMessage = StringRef());
53 
54  /// Parse a comma separated list of elements that must have at least one entry
55  /// in it.
56  ParseResult
57  parseCommaSeparatedList(function_ref<ParseResult()> parseElementFn) {
58  return parseCommaSeparatedList(Delimiter::None, parseElementFn);
59  }
60 
61  /// Parse the body of a dialect symbol, which starts and ends with <>'s, and
62  /// may be recursive. Return with the 'body' StringRef encompassing the entire
63  /// body. `isCodeCompletion` is set to true if the body contained a code
64  /// completion location, in which case the body is only populated up to the
65  /// completion.
66  ParseResult parseDialectSymbolBody(StringRef &body, bool &isCodeCompletion);
67  ParseResult parseDialectSymbolBody(StringRef &body) {
68  bool isCodeCompletion = false;
69  return parseDialectSymbolBody(body, isCodeCompletion);
70  }
71 
72  // We have two forms of parsing methods - those that return a non-null
73  // pointer on success, and those that return a ParseResult to indicate whether
74  // they returned a failure. The second class fills in by-reference arguments
75  // as the results of their action.
76 
77  //===--------------------------------------------------------------------===//
78  // Error Handling
79  //===--------------------------------------------------------------------===//
80 
81  /// Emit an error and return failure.
82  InFlightDiagnostic emitError(const Twine &message = {});
83  InFlightDiagnostic emitError(SMLoc loc, const Twine &message = {});
84 
85  /// Emit an error about a "wrong token". If the current token is at the
86  /// start of a source line, this will apply heuristics to back up and report
87  /// the error at the end of the previous line, which is where the expected
88  /// token is supposed to be.
89  InFlightDiagnostic emitWrongTokenError(const Twine &message = {});
90 
91  /// Encode the specified source location information into an attribute for
92  /// attachment to the IR.
95  }
96 
97  //===--------------------------------------------------------------------===//
98  // Token Parsing
99  //===--------------------------------------------------------------------===//
100 
101  /// Return the current token the parser is inspecting.
102  const Token &getToken() const { return state.curToken; }
103  StringRef getTokenSpelling() const { return state.curToken.getSpelling(); }
104 
105  /// Return the last parsed token.
106  const Token &getLastToken() const { return state.lastToken; }
107 
108  /// If the current token has the specified kind, consume it and return true.
109  /// If not, return false.
110  bool consumeIf(Token::Kind kind) {
111  if (state.curToken.isNot(kind))
112  return false;
113  consumeToken(kind);
114  return true;
115  }
116 
117  /// Advance the current lexer onto the next token.
118  void consumeToken() {
119  assert(state.curToken.isNot(Token::eof, Token::error) &&
120  "shouldn't advance past EOF or errors");
123  }
124 
125  /// Advance the current lexer onto the next token, asserting what the expected
126  /// current token is. This is preferred to the above method because it leads
127  /// to more self-documenting code with better checking.
129  assert(state.curToken.is(kind) && "consumed an unexpected token");
130  consumeToken();
131  }
132 
133  /// Reset the parser to the given lexer position. Resetting the parser/lexer
134  /// position does not update 'state.lastToken'. 'state.lastToken' is the
135  /// last parsed token, and is used to provide the scope end location for
136  /// OperationDefinitions. To ensure the correctness of the end location, the
137  /// last consumed token of an OperationDefinition needs to be the last token
138  /// belonging to it.
139  void resetToken(const char *tokPos) {
140  state.lex.resetPointer(tokPos);
142  }
143 
144  /// Consume the specified token if present and return success. On failure,
145  /// output a diagnostic and return failure.
146  ParseResult parseToken(Token::Kind expectedToken, const Twine &message);
147 
148  /// Parse an optional integer value from the stream.
150 
151  /// Parse an optional integer value only in decimal format from the stream.
153 
154  /// Parse a floating point value from an integer literal token.
155  ParseResult parseFloatFromIntegerLiteral(std::optional<APFloat> &result,
156  const Token &tok, bool isNegative,
157  const llvm::fltSemantics &semantics,
158  size_t typeSizeInBits);
159 
160  /// Returns true if the current token corresponds to a keyword.
161  bool isCurrentTokenAKeyword() const {
162  return getToken().isAny(Token::bare_identifier, Token::inttype) ||
163  getToken().isKeyword();
164  }
165 
166  /// Parse a keyword, if present, into 'keyword'.
167  ParseResult parseOptionalKeyword(StringRef *keyword);
168 
169  //===--------------------------------------------------------------------===//
170  // Resource Parsing
171  //===--------------------------------------------------------------------===//
172 
173  /// Parse a handle to a dialect resource within the assembly format.
174  FailureOr<AsmDialectResourceHandle>
175  parseResourceHandle(const OpAsmDialectInterface *dialect, StringRef &name);
176  FailureOr<AsmDialectResourceHandle> parseResourceHandle(Dialect *dialect);
177 
178  //===--------------------------------------------------------------------===//
179  // Type Parsing
180  //===--------------------------------------------------------------------===//
181 
182  /// Invoke the `getChecked` method of the given Attribute or Type class, using
183  /// the provided location to emit errors in the case of failure. Note that
184  /// unlike `OpBuilder::getType`, this method does not implicitly insert a
185  /// context parameter.
186  template <typename T, typename... ParamsT>
187  T getChecked(SMLoc loc, ParamsT &&...params) {
188  return T::getChecked([&] { return emitError(loc); },
189  std::forward<ParamsT>(params)...);
190  }
191 
192  ParseResult parseFunctionResultTypes(SmallVectorImpl<Type> &elements);
193  ParseResult parseTypeListNoParens(SmallVectorImpl<Type> &elements);
194  ParseResult parseTypeListParens(SmallVectorImpl<Type> &elements);
195 
196  /// Optionally parse a type.
198 
199  /// Parse an arbitrary type.
200  Type parseType();
201 
202  /// Parse a complex type.
204 
205  /// Parse an extended type.
207 
208  /// Parse a function type.
210 
211  /// Parse a memref type.
213 
214  /// Parse a non function type.
216 
217  /// Parse a tensor type.
219 
220  /// Parse a tuple type.
222 
223  /// Parse a vector type.
224  VectorType parseVectorType();
225  ParseResult parseVectorDimensionList(SmallVectorImpl<int64_t> &dimensions,
226  SmallVectorImpl<bool> &scalableDims);
227  ParseResult parseDimensionListRanked(SmallVectorImpl<int64_t> &dimensions,
228  bool allowDynamic = true,
229  bool withTrailingX = true);
230  ParseResult parseIntegerInDimensionList(int64_t &value);
231  ParseResult parseXInDimensionList();
232 
233  //===--------------------------------------------------------------------===//
234  // Attribute Parsing
235  //===--------------------------------------------------------------------===//
236 
237  /// Parse an arbitrary attribute with an optional type.
238  Attribute parseAttribute(Type type = {});
239 
240  /// Parse an optional attribute with the provided type.
242  Type type = {});
243  OptionalParseResult parseOptionalAttribute(ArrayAttr &attribute, Type type);
244  OptionalParseResult parseOptionalAttribute(StringAttr &attribute, Type type);
245  OptionalParseResult parseOptionalAttribute(SymbolRefAttr &result, Type type);
246 
247  /// Parse an optional attribute that is demarcated by a specific token.
248  template <typename AttributeT>
250  AttributeT &attr,
251  Type type = {}) {
252  if (getToken().isNot(kind))
253  return std::nullopt;
254 
255  if (Attribute parsedAttr = parseAttribute(type)) {
256  attr = cast<AttributeT>(parsedAttr);
257  return success();
258  }
259  return failure();
260  }
261 
262  /// Parse an attribute dictionary.
263  ParseResult parseAttributeDict(NamedAttrList &attributes);
264 
265  /// Parse a distinct attribute.
266  Attribute parseDistinctAttr(Type type);
267 
268  /// Parse an extended attribute.
269  Attribute parseExtendedAttr(Type type);
270 
271  /// Parse a float attribute.
272  Attribute parseFloatAttr(Type type, bool isNegative);
273 
274  /// Parse a decimal or a hexadecimal literal, which can be either an integer
275  /// or a float attribute.
276  Attribute parseDecOrHexAttr(Type type, bool isNegative);
277 
278  /// Parse a dense elements attribute.
279  Attribute parseDenseElementsAttr(Type attrType);
280  ShapedType parseElementsLiteralType(Type type);
281 
282  /// Parse a dense resource elements attribute.
283  Attribute parseDenseResourceElementsAttr(Type attrType);
284 
285  /// Parse a DenseArrayAttr.
286  Attribute parseDenseArrayAttr(Type type);
287 
288  /// Parse a sparse elements attribute.
289  Attribute parseSparseElementsAttr(Type attrType);
290 
291  /// Parse a strided layout attribute.
292  Attribute parseStridedLayoutAttr();
293 
294  //===--------------------------------------------------------------------===//
295  // Location Parsing
296  //===--------------------------------------------------------------------===//
297 
298  /// Parse a raw location instance.
299  ParseResult parseLocationInstance(LocationAttr &loc);
300 
301  /// Parse a callsite location instance.
302  ParseResult parseCallSiteLocation(LocationAttr &loc);
303 
304  /// Parse a fused location instance.
305  ParseResult parseFusedLocation(LocationAttr &loc);
306 
307  /// Parse a name or FileLineCol location instance.
308  ParseResult parseNameOrFileLineColLocation(LocationAttr &loc);
309 
310  //===--------------------------------------------------------------------===//
311  // Affine Parsing
312  //===--------------------------------------------------------------------===//
313 
314  /// Parse a reference to either an affine map, expr, or an integer set.
315  ParseResult parseAffineMapOrIntegerSetReference(AffineMap &map,
316  IntegerSet &set);
317  ParseResult parseAffineMapReference(AffineMap &map);
318  ParseResult
319  parseAffineExprReference(ArrayRef<std::pair<StringRef, AffineExpr>> symbolSet,
320  AffineExpr &expr);
321  ParseResult parseIntegerSetReference(IntegerSet &set);
322 
323  /// Parse an AffineMap where the dim and symbol identifiers are SSA ids.
324  ParseResult
325  parseAffineMapOfSSAIds(AffineMap &map,
326  function_ref<ParseResult(bool)> parseElement,
327  Delimiter delimiter);
328 
329  /// Parse an AffineExpr where dim and symbol identifiers are SSA ids.
330  ParseResult
331  parseAffineExprOfSSAIds(AffineExpr &expr,
332  function_ref<ParseResult(bool)> parseElement);
333 
334  //===--------------------------------------------------------------------===//
335  // Code Completion
336  //===--------------------------------------------------------------------===//
337 
338  /// The set of various code completion methods. Every completion method
339  /// returns `failure` to signal that parsing should abort after any desired
340  /// completions have been enqueued. Note that `failure` is does not mean
341  /// completion failed, it's just a signal to the parser to stop.
342 
343  ParseResult codeCompleteDialectName();
344  ParseResult codeCompleteOperationName(StringRef dialectName);
345  ParseResult codeCompleteDialectOrElidedOpName(SMLoc loc);
346  ParseResult codeCompleteStringDialectOrOperationName(StringRef name);
347  ParseResult codeCompleteExpectedTokens(ArrayRef<StringRef> tokens);
348  ParseResult codeCompleteOptionalTokens(ArrayRef<StringRef> tokens);
349 
350  Attribute codeCompleteAttribute();
351  Type codeCompleteType();
352  Attribute
353  codeCompleteDialectSymbol(const llvm::StringMap<Attribute> &aliases);
354  Type codeCompleteDialectSymbol(const llvm::StringMap<Type> &aliases);
355 
356 protected:
357  /// The Parser is subclassed and reinstantiated. Do not add additional
358  /// non-trivial state here, add it to the ParserState class.
360 };
361 } // namespace detail
362 } // namespace mlir
363 
364 #endif // MLIR_LIB_ASMPARSER_PARSER_H
Delimiter
These are the supported delimiters around operand lists and region argument lists,...
@ None
Zero or more operands with no delimiters.
Attributes are known-constant values of operations.
Definition: Attributes.h:25
This class is a general helper class for creating context-global objects like types,...
Definition: Builders.h:50
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
Definition: Dialect.h:38
This class represents a diagnostic that is inflight and set to be reported.
Definition: Diagnostics.h:313
Token lexToken()
Definition: Lexer.cpp:73
const llvm::SourceMgr & getSourceMgr()
Definition: Lexer.h:28
Location getEncodedSourceLocation(SMLoc loc)
Encode the specified source location information into a Location object for attachment to the IR or e...
Definition: Lexer.cpp:50
void resetPointer(const char *newPointer)
Change the position of the lexer cursor.
Definition: Lexer.h:38
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition: Location.h:63
MLIRContext is the top-level object for a collection of MLIR operations.
Definition: MLIRContext.h:60
This class implements Optional functionality for ParseResult.
Definition: OpDefinition.h:39
MLIRContext * getContext() const
Return the MLIRContext to be used when parsing.
Definition: AsmState.h:474
This represents a token in the MLIR syntax.
Definition: Token.h:20
bool isKeyword() const
Return true if this is one of the keyword token kinds (e.g. kw_if).
Definition: Token.cpp:192
bool is(Kind k) const
Definition: Token.h:38
bool isAny(Kind k1, Kind k2) const
Definition: Token.h:40
bool isNot(Kind k) const
Definition: Token.h:50
StringRef getSpelling() const
Definition: Token.h:34
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:74
This class implement support for parsing global entities like attributes and types.
Definition: Parser.h:26
ParseResult parseOptionalKeyword(StringRef *keyword)
Parse a keyword, if present, into 'keyword'.
Definition: Parser.cpp:381
const Token & getLastToken() const
Return the last parsed token.
Definition: Parser.h:106
Attribute parseDenseArrayAttr(Type type)
Parse a DenseArrayAttr.
Attribute parseStridedLayoutAttr()
Parse a strided layout attribute.
Attribute parseDecOrHexAttr(Type type, bool isNegative)
Parse a decimal or a hexadecimal literal, which can be either an integer or a float attribute.
OpAsmParser::Delimiter Delimiter
Definition: Parser.h:28
ParseResult parseXInDimensionList()
Parse an 'x' token in a dimension list, handling the case where the x is juxtaposed with an element t...
Definition: TypeParser.cpp:596
T getChecked(SMLoc loc, ParamsT &&...params)
Invoke the getChecked method of the given Attribute or Type class, using the provided location to emi...
Definition: Parser.h:187
OptionalParseResult parseOptionalType(Type &type)
Optionally parse a type.
Definition: TypeParser.cpp:32
ParseResult parseToken(Token::Kind expectedToken, const Twine &message)
Consume the specified token if present and return success.
Definition: Parser.cpp:267
ParseResult parseCommaSeparatedListUntil(Token::Kind rightToken, function_ref< ParseResult()> parseElement, bool allowEmptyList=true)
Parse a comma-separated list of elements up until the specified end token.
Definition: Parser.cpp:173
ParseResult codeCompleteOperationName(StringRef dialectName)
Definition: Parser.cpp:442
OptionalParseResult parseOptionalDecimalInteger(APInt &result)
Parse an optional integer value only in decimal format from the stream.
Definition: Parser.cpp:312
Builder builder
Definition: Parser.h:30
Type parseType()
Parse an arbitrary type.
Definition: TypeParser.cpp:72
Attribute parseDenseElementsAttr(Type attrType)
Parse a dense elements attribute.
void consumeToken(Token::Kind kind)
Advance the current lexer onto the next token, asserting what the expected current token is.
Definition: Parser.h:128
ParseResult parseTypeListParens(SmallVectorImpl< Type > &elements)
Parse a parenthesized list of types.
Definition: TypeParser.cpp:114
ParserState & getState() const
Definition: Parser.h:36
Attribute parseDenseResourceElementsAttr(Type attrType)
Parse a dense resource elements attribute.
ParseResult parseVectorDimensionList(SmallVectorImpl< int64_t > &dimensions, SmallVectorImpl< bool > &scalableDims)
Parse a dimension list in a vector type.
Definition: TypeParser.cpp:495
Type parseMemRefType()
Parse a memref type.
Definition: TypeParser.cpp:181
Type parseNonFunctionType()
Parse a non function type.
Definition: TypeParser.cpp:273
Parser(ParserState &state)
Definition: Parser.h:32
Type codeCompleteType()
Definition: Parser.cpp:502
ParseResult parseAffineMapReference(AffineMap &map)
Location getEncodedSourceLocation(SMLoc loc)
Encode the specified source location information into an attribute for attachment to the IR.
Definition: Parser.h:93
Type parseExtendedType()
Parse an extended type.
Type parseTupleType()
Parse a tuple type.
Definition: TypeParser.cpp:438
InFlightDiagnostic emitError(const Twine &message={})
Emit an error and return failure.
Definition: Parser.cpp:192
ParserState & state
The Parser is subclassed and reinstantiated.
Definition: Parser.h:359
ParseResult codeCompleteDialectName()
The set of various code completion methods.
Definition: Parser.cpp:437
ParseResult parseAffineExprReference(ArrayRef< std::pair< StringRef, AffineExpr >> symbolSet, AffineExpr &expr)
Attribute parseAttribute(Type type={})
Parse an arbitrary attribute with an optional type.
const llvm::SourceMgr & getSourceMgr()
Definition: Parser.h:38
StringRef getTokenSpelling() const
Definition: Parser.h:103
ParseResult parseLocationInstance(LocationAttr &loc)
Parse a raw location instance.
void consumeToken()
Advance the current lexer onto the next token.
Definition: Parser.h:118
ParseResult codeCompleteExpectedTokens(ArrayRef< StringRef > tokens)
Definition: Parser.cpp:488
Attribute codeCompleteAttribute()
Definition: Parser.cpp:497
ParseResult parseIntegerInDimensionList(int64_t &value)
Definition: TypeParser.cpp:568
ParseResult parseAttributeDict(NamedAttrList &attributes)
Parse an attribute dictionary.
ParseResult parseDialectSymbolBody(StringRef &body, bool &isCodeCompletion)
Parse the body of a dialect symbol, which starts and ends with <>'s, and may be recursive.
ShapedType parseElementsLiteralType(Type type)
Shaped type for elements attribute.
Type parseComplexType()
Parse a complex type.
Definition: TypeParser.cpp:132
ParseResult parseDimensionListRanked(SmallVectorImpl< int64_t > &dimensions, bool allowDynamic=true, bool withTrailingX=true)
Parse a dimension list of a tensor or memref type.
Definition: TypeParser.cpp:531
ParseResult parseFunctionResultTypes(SmallVectorImpl< Type > &elements)
Parse a function result type.
Definition: TypeParser.cpp:83
ParseResult codeCompleteDialectOrElidedOpName(SMLoc loc)
Definition: Parser.cpp:452
ParseResult parseDialectSymbolBody(StringRef &body)
Definition: Parser.h:67
MLIRContext * getContext() const
Definition: Parser.h:37
Attribute parseDistinctAttr(Type type)
Parse a distinct attribute.
InFlightDiagnostic emitWrongTokenError(const Twine &message={})
Emit an error about a "wrong token".
Definition: Parser.cpp:215
ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())
Parse a list of comma-separated items with an optional delimiter.
Definition: Parser.cpp:84
VectorType parseVectorType()
Parse a vector type.
Definition: TypeParser.cpp:464
OptionalParseResult parseOptionalInteger(APInt &result)
Parse an optional integer value from the stream.
Definition: Parser.cpp:275
ParseResult parseFusedLocation(LocationAttr &loc)
Parse a fused location instance.
Type parseFunctionType()
Parse a function type.
Definition: TypeParser.cpp:155
Attribute parseSparseElementsAttr(Type attrType)
Parse a sparse elements attribute.
ParseResult parseAffineMapOrIntegerSetReference(AffineMap &map, IntegerSet &set)
Parse a reference to either an affine map, expr, or an integer set.
OptionalParseResult parseOptionalAttribute(Attribute &attribute, Type type={})
Parse an optional attribute with the provided type.
bool isCurrentTokenAKeyword() const
Returns true if the current token corresponds to a keyword.
Definition: Parser.h:161
ParseResult codeCompleteStringDialectOrOperationName(StringRef name)
Definition: Parser.cpp:475
ParseResult parseFloatFromIntegerLiteral(std::optional< APFloat > &result, const Token &tok, bool isNegative, const llvm::fltSemantics &semantics, size_t typeSizeInBits)
Parse a floating point value from an integer literal token.
Definition: Parser.cpp:351
ParseResult codeCompleteOptionalTokens(ArrayRef< StringRef > tokens)
Definition: Parser.cpp:492
ParseResult parseAffineMapOfSSAIds(AffineMap &map, function_ref< ParseResult(bool)> parseElement, Delimiter delimiter)
Parse an AffineMap where the dim and symbol identifiers are SSA ids.
Attribute parseFloatAttr(Type type, bool isNegative)
Parse a float attribute.
ParseResult parseCallSiteLocation(LocationAttr &loc)
Parse a callsite location instance.
ParseResult parseIntegerSetReference(IntegerSet &set)
ParseResult parseNameOrFileLineColLocation(LocationAttr &loc)
Parse a name or FileLineCol location instance.
ParseResult parseTypeListNoParens(SmallVectorImpl< Type > &elements)
Parse a list of types without an enclosing parenthesis.
Definition: TypeParser.cpp:99
void resetToken(const char *tokPos)
Reset the parser to the given lexer position.
Definition: Parser.h:139
ParseResult parseAffineExprOfSSAIds(AffineExpr &expr, function_ref< ParseResult(bool)> parseElement)
Parse an AffineExpr where dim and symbol identifiers are SSA ids.
Attribute parseExtendedAttr(Type type)
Parse an extended attribute.
const Token & getToken() const
Return the current token the parser is inspecting.
Definition: Parser.h:102
ParseResult parseCommaSeparatedList(function_ref< ParseResult()> parseElementFn)
Parse a comma separated list of elements that must have at least one entry in it.
Definition: Parser.h:57
FailureOr< AsmDialectResourceHandle > parseResourceHandle(const OpAsmDialectInterface *dialect, StringRef &name)
Parse a handle to a dialect resource within the assembly format.
Definition: Parser.cpp:395
Type parseTensorType()
Parse a tensor type.
Definition: TypeParser.cpp:380
bool consumeIf(Token::Kind kind)
If the current token has the specified kind, consume it and return true.
Definition: Parser.h:110
OptionalParseResult parseOptionalAttributeWithToken(Token::Kind kind, AttributeT &attr, Type type={})
Parse an optional attribute that is demarcated by a specific token.
Definition: Parser.h:249
Attribute codeCompleteDialectSymbol(const llvm::StringMap< Attribute > &aliases)
Definition: Parser.cpp:508
Include the generated interface declarations.
llvm::function_ref< Fn > function_ref
Definition: LLVM.h:152
This class refers to all of the state maintained globally by the parser, such as the current lexer po...
Definition: ParserState.h:51
const ParserConfig & config
The configuration used to setup the parser.
Definition: ParserState.h:63
Lexer lex
The lexer for the source file we're parsing.
Definition: ParserState.h:66
Token curToken
This is the next token that hasn't been consumed yet.
Definition: ParserState.h:69
Token lastToken
This is the last token that has been consumed.
Definition: ParserState.h:72