-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathDocstringPython.hpp
More file actions
47 lines (34 loc) · 1 KB
/
DocstringPython.hpp
File metadata and controls
47 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: GPL-3.0-only
/**
* @file DocstringPython.hpp
*
* @copyright Copyright (C) 2024 srcML, LLC. (www.srcML.org)
*
* This file is part of the srcML Toolkit.
*
* Alters string literals that should be docstrings in the token stream
*/
#ifndef INCLUDED_DOCSTRINGPYTHON_HPP
#define INCLUDED_DOCSTRINGPYTHON_HPP
#include <antlr/TokenStream.hpp>
#include <srcMLToken.hpp>
#include <srcMLParser.hpp>
#include <deque>
#include <algorithm>
class DocstringPython : public antlr::TokenStream {
public:
DocstringPython(antlr::TokenStream& input) : input(input) {}
antlr::RefToken nextToken();
void countWSNewlineTokens(antlr::RefToken token);
void setBlockStartToken(int token);
int getBlockStartToken() const;
private:
antlr::TokenStream& input;
std::deque<antlr::RefToken> buffer;
bool isFunctionOrClass = false;
bool isBlockStart = false;
int numBrackets = 0; // encompasses (), {}, and []
int blockStartToken = -1;
int lineNumber = 1;
};
#endif