15#include "llvm/Support/ErrorHandling.h"
20 for (StringRef::const_iterator
I = S.begin(),
E = S.end();
I !=
E; ++
I) {
31 llvm::BumpPtrAllocator &Allocator;
35 bool NoMoreInterestingTokens;
42 const char *BufferStart;
43 const char *BufferEnd;
44 const char *BufferPtr;
53 return Pos.CurToken >= Toks.size();
59 const Token &Tok = Toks[Pos.CurToken];
61 Pos.BufferStart = Tok.
getText().begin();
62 Pos.BufferEnd = Tok.
getText().end();
63 Pos.BufferPtr = Pos.BufferStart;
68 const unsigned CharNo = Pos.BufferPtr - Pos.BufferStart;
69 return Pos.BufferStartLoc.getLocWithOffset(CharNo);
74 assert(Pos.BufferPtr != Pos.BufferEnd);
75 return *Pos.BufferPtr;
80 assert(Pos.BufferPtr != Pos.BufferEnd);
82 if (Pos.BufferPtr == Pos.BufferEnd) {
84 if (isEnd() && !addToken())
94 unsigned BracketCount = 0;
96 const char C = peek();
97 WordText.push_back(
C);
121 if (NoMoreInterestingTokens)
130 NoMoreInterestingTokens =
true;
135 NoMoreInterestingTokens =
true;
139 Toks.push_back(
P.Tok);
141 if (Toks.size() == 1)
146 void consumeWhitespace() {
157 const char *TokBegin,
162 Result.setLength(TokLength);
164 Result.TextPtr =
"<UNSET>";
172 Allocator(Allocator),
P(
P), NoMoreInterestingTokens(
false) {
184 Position SavedPos = Pos;
189 const char *WordBegin = Pos.BufferPtr;
193 const char C = peek();
198 if (!lexTemplate(WordText))
201 WordText.push_back(
C);
210 const unsigned Length = WordText.size();
216 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
218 memcpy(TextPtr, WordText.c_str(), Length + 1);
219 StringRef
Text = StringRef(TextPtr, Length);
221 formTokenWithChars(Tok,
Loc, WordBegin, Length,
Text);
237 llvm::StringRef LineStart(Pos.BufferPtr - Offset - 3, 4);
238 return LineStart.starts_with(
"\\par") || LineStart.starts_with(
"@par");
246 Position SavedPos = Pos;
250 const char *WordBegin = Pos.BufferPtr;
259 WordText.push_back(peek());
260 if (Pos.BufferPtr + 1 == Pos.BufferEnd) {
267 unsigned Length = WordText.size();
273 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
275 memcpy(TextPtr, WordText.c_str(), Length + 1);
276 StringRef
Text = StringRef(TextPtr, Length);
278 formTokenWithChars(Tok,
Loc, WordBegin, Length,
Text);
287 Position SavedPos = Pos;
291 const char *WordBegin = Pos.BufferPtr;
294 const char C = peek();
296 WordText.push_back(
C);
301 const unsigned Length = WordText.size();
307 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
309 memcpy(TextPtr, WordText.c_str(), Length + 1);
310 StringRef
Text = StringRef(TextPtr, Length);
312 formTokenWithChars(Tok,
Loc, WordBegin, Length,
Text);
320 Position SavedPos = Pos;
324 const char *WordBegin = Pos.BufferPtr;
328 const char C = peek();
329 if (
C == OpenDelim) {
330 WordText.push_back(
C);
336 while (!Error && !isEnd()) {
338 WordText.push_back(
C);
343 if (!Error &&
C != CloseDelim)
351 const unsigned Length = WordText.size();
352 char *TextPtr = Allocator.Allocate<
char>(Length + 1);
354 memcpy(TextPtr, WordText.c_str(), Length + 1);
355 StringRef
Text = StringRef(TextPtr, Length);
357 formTokenWithChars(Tok,
Loc, WordBegin,
358 Pos.BufferPtr - WordBegin,
Text);
367 bool HavePartialTok =
false;
369 if (Pos.BufferPtr != Pos.BufferStart) {
370 formTokenWithChars(PartialTok, getSourceLocation(),
371 Pos.BufferPtr, Pos.BufferEnd - Pos.BufferPtr,
372 StringRef(Pos.BufferPtr,
373 Pos.BufferEnd - Pos.BufferPtr));
374 HavePartialTok =
true;
379 Pos.CurToken = Toks.size();
382 P.putBack(PartialTok);
386Parser::Parser(
Lexer &L,
Sema &S, llvm::BumpPtrAllocator &Allocator,
389 L(L), S(S), Allocator(Allocator), SourceMgr(SourceMgr), Diags(Diags),
426 unsigned ParsedArgs = 0;
428 while (ParsedArgs < NumArgs && Retokenizer.
lexWord(Arg)) {
442 unsigned ParsedArgs = 0;
445 while (ParsedArgs < NumArgs && Retokenizer.
lexType(Arg)) {
460 unsigned ParsedArgs = 0;
463 while (ParsedArgs < NumArgs && Retokenizer.
lexParHeading(Arg)) {
499 if (isTokBlockCommand()) {
515 if (PC || TPC || Info->
NumArgs > 0) {
538 bool EmptyParagraph =
false;
539 if (isTokBlockCommand())
540 EmptyParagraph =
true;
544 EmptyParagraph = isTokBlockCommand();
555 Paragraph = cast<ParagraphComment>(
Block);
574 const Token CommandTok = Tok;
585 if (Args.size() < Info->
NumArgs) {
587 diag::warn_doc_inline_command_not_enough_arguments)
620 diag::warn_doc_html_start_tag_expected_quoted_string)
632 Equals.getLocation(),
657 diag::warn_doc_html_start_tag_expected_ident_or_greater);
676 bool StartLineInvalid;
684 if (StartLineInvalid || EndLineInvalid || StartLine == EndLine)
686 diag::warn_doc_html_start_tag_expected_ident_or_greater)
690 diag::warn_doc_html_start_tag_expected_ident_or_greater);
691 Diag(HST->
getLocation(), diag::note_doc_html_tag_started_here)
701 Token TokEndTag = Tok;
735 if (Content.size() == 0)
741 diag::warn_verbatim_block_end_without_start)
769 Token WhitespaceTok = Tok;
776 putBack(WhitespaceTok);
778 if (Content.size() > 0)
779 Content.back()->addTrailingNewline();
807 llvm_unreachable(
"should not see this token");
844 Lines.push_back(
Line);
913 llvm_unreachable(
"should not see this token");
915 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',...