16#include "llvm/Support/ErrorHandling.h"
21 for (StringRef::const_iterator I = S.begin(),
E = S.end(); I !=
E; ++I) {
32 llvm::BumpPtrAllocator &Allocator;
36 bool NoMoreInterestingTokens;
43 const char *BufferStart;
44 const char *BufferEnd;
45 const char *BufferPtr;
54 return Pos.CurToken >= Toks.size();
60 const Token &Tok = Toks[Pos.CurToken];
62 Pos.BufferStart = Tok.
getText().begin();
63 Pos.BufferEnd = Tok.
getText().end();
64 Pos.BufferPtr = Pos.BufferStart;
69 const unsigned CharNo = Pos.BufferPtr - Pos.BufferStart;
70 return Pos.BufferStartLoc.getLocWithOffset(CharNo);
75 assert(Pos.BufferPtr != Pos.BufferEnd);
76 return *Pos.BufferPtr;
81 assert(Pos.BufferPtr != Pos.BufferEnd);
83 if (Pos.BufferPtr == Pos.BufferEnd) {
85 if (isEnd() && !addToken())
95 unsigned BracketCount = 0;
97 const char C = peek();
98 WordText.push_back(
C);
122 if (NoMoreInterestingTokens)
131 NoMoreInterestingTokens =
true;
136 NoMoreInterestingTokens =
true;
140 Toks.push_back(
P.Tok);
142 if (Toks.size() == 1)
147 void consumeWhitespace() {
158 const char *TokBegin,
163 Result.setLength(TokLength);
165 Result.TextPtr =
"<UNSET>";
173 Allocator(Allocator),
P(
P), NoMoreInterestingTokens(
false) {
185 Position SavedPos = Pos;
190 const char *WordBegin = Pos.BufferPtr;
194 const char C = peek();
199 if (!lexTemplate(WordText))
202 WordText.push_back(
C);
211 const unsigned Length = WordText.size();
217 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
219 memcpy(TextPtr, WordText.c_str(), Length + 1);
220 StringRef
Text = StringRef(TextPtr, Length);
222 formTokenWithChars(Tok,
Loc, WordBegin, Length,
Text);
238 llvm::StringRef LineStart(Pos.BufferPtr - Offset - 3, 4);
239 return LineStart.starts_with(
"\\par") || LineStart.starts_with(
"@par");
247 Position SavedPos = Pos;
251 const char *WordBegin = Pos.BufferPtr;
260 WordText.push_back(peek());
261 if (Pos.BufferPtr + 1 == Pos.BufferEnd) {
268 unsigned Length = WordText.size();
274 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
276 memcpy(TextPtr, WordText.c_str(), Length + 1);
277 StringRef
Text = StringRef(TextPtr, Length);
279 formTokenWithChars(Tok,
Loc, WordBegin, Length,
Text);
288 Position SavedPos = Pos;
292 const char *WordBegin = Pos.BufferPtr;
295 const char C = peek();
297 WordText.push_back(
C);
302 const unsigned Length = WordText.size();
308 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
310 memcpy(TextPtr, WordText.c_str(), Length + 1);
311 StringRef
Text = StringRef(TextPtr, Length);
313 formTokenWithChars(Tok,
Loc, WordBegin, Length,
Text);
321 Position SavedPos = Pos;
325 const char *WordBegin = Pos.BufferPtr;
329 const char C = peek();
330 if (
C == OpenDelim) {
331 WordText.push_back(
C);
337 while (!Error && !isEnd()) {
339 WordText.push_back(
C);
344 if (!Error &&
C != CloseDelim)
352 const unsigned Length = WordText.size();
353 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
355 memcpy(TextPtr, WordText.c_str(), Length + 1);
356 StringRef
Text = StringRef(TextPtr, Length);
358 formTokenWithChars(Tok,
Loc, WordBegin,
359 Pos.BufferPtr - WordBegin,
Text);
368 bool HavePartialTok =
false;
370 if (Pos.BufferPtr != Pos.BufferStart) {
371 formTokenWithChars(PartialTok, getSourceLocation(),
372 Pos.BufferPtr, Pos.BufferEnd - Pos.BufferPtr,
373 StringRef(Pos.BufferPtr,
374 Pos.BufferEnd - Pos.BufferPtr));
375 HavePartialTok =
true;
379 P.putBack(
ArrayRef(Toks.begin() + Pos.CurToken, Toks.end()));
380 Pos.CurToken = Toks.size();
383 P.putBack(PartialTok);
387Parser::Parser(
Lexer &L,
Sema &S, llvm::BumpPtrAllocator &Allocator,
390 L(L), S(S), Allocator(Allocator), SourceMgr(SourceMgr), Diags(Diags),
427 unsigned ParsedArgs = 0;
429 while (ParsedArgs < NumArgs && Retokenizer.
lexWord(Arg)) {
443 unsigned ParsedArgs = 0;
446 while (ParsedArgs < NumArgs && Retokenizer.
lexType(Arg)) {
461 unsigned ParsedArgs = 0;
464 while (ParsedArgs < NumArgs && Retokenizer.
lexParHeading(Arg)) {
500 if (isTokBlockCommand()) {
516 if (PC || TPC || Info->
NumArgs > 0) {
539 bool EmptyParagraph =
false;
540 if (isTokBlockCommand())
541 EmptyParagraph =
true;
545 EmptyParagraph = isTokBlockCommand();
556 Paragraph = cast<ParagraphComment>(
Block);
577 const Token CommandTok = Tok;
588 if (Args.size() < Info->
NumArgs) {
590 diag::warn_doc_inline_command_not_enough_arguments)
623 diag::warn_doc_html_start_tag_expected_quoted_string)
635 Equals.getLocation(),
660 diag::warn_doc_html_start_tag_expected_ident_or_greater);
679 bool StartLineInvalid;
687 if (StartLineInvalid || EndLineInvalid || StartLine == EndLine)
689 diag::warn_doc_html_start_tag_expected_ident_or_greater)
693 diag::warn_doc_html_start_tag_expected_ident_or_greater);
694 Diag(HST->
getLocation(), diag::note_doc_html_tag_started_here)
704 Token TokEndTag = Tok;
738 if (Content.size() == 0)
744 diag::warn_verbatim_block_end_without_start)
772 Token WhitespaceTok = Tok;
779 putBack(WhitespaceTok);
781 if (Content.size() > 0)
782 Content.back()->addTrailingNewline();
810 llvm_unreachable(
"should not see this token");
847 Lines.push_back(
Line);
916 llvm_unreachable(
"should not see this token");
918 llvm_unreachable(
"bogus token kind");
Defines the SourceManager interface.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Concrete class used by the front-end to report problems and issues.
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
unsigned getPresumedLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
A trivial tuple used to represent a source range.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...