@@ -29,6 +29,20 @@ namespace llvm {
29
29
const char *CurPtr;
30
30
StringRef CurBuf;
31
31
32
+ // The line number at `CurPtr-1`, zero-indexed
33
+ unsigned CurLineNum = 0 ;
34
+ // The column number at `CurPtr-1`, zero-indexed
35
+ unsigned CurColNum = -1 ;
36
+ // The line number of the start of the current token, zero-indexed
37
+ unsigned CurTokLineNum = 0 ;
38
+ // The column number of the start of the current token, zero-indexed
39
+ unsigned CurTokColNum = 0 ;
40
+ // The line number of the end of the current token, zero-indexed
41
+ unsigned PrevTokEndLineNum = -1 ;
42
+ // The column number of the end (exclusive) of the current token,
43
+ // zero-indexed
44
+ unsigned PrevTokEndColNum = -1 ;
45
+
32
46
enum class ErrorPriority {
33
47
None, // No error message present.
34
48
Parser, // Errors issued by parser.
@@ -62,9 +76,7 @@ namespace llvm {
62
76
explicit LLLexer (StringRef StartBuf, SourceMgr &SM, SMDiagnostic &,
63
77
LLVMContext &C);
64
78
65
- lltok::Kind Lex () {
66
- return CurKind = LexToken ();
67
- }
79
+ lltok::Kind Lex () { return CurKind = LexToken (); }
68
80
69
81
typedef SMLoc LocTy;
70
82
LocTy getLoc () const { return SMLoc::getFromPointer (TokStart); }
@@ -79,6 +91,21 @@ namespace llvm {
79
91
IgnoreColonInIdentifiers = val;
80
92
}
81
93
94
+ // Get the current line number, zero-indexed
95
+ unsigned getLineNum () { return CurLineNum; }
96
+ // Get the current column number, zero-indexed
97
+ unsigned getColNum () { return CurColNum; }
98
+ // Get the line number of the start of the current token, zero-indexed
99
+ unsigned getTokLineNum () { return CurTokLineNum; }
100
+ // Get the column number of the start of the current token, zero-indexed
101
+ unsigned getTokColNum () { return CurTokColNum; }
102
+ // Get the line number of the end of the previous token, zero-indexed,
103
+ // exclusive
104
+ unsigned getPrevTokEndLineNum () { return PrevTokEndLineNum; }
105
+ // Get the column number of the end of the previous token, zero-indexed,
106
+ // exclusive
107
+ unsigned getPrevTokEndColNum () { return PrevTokEndColNum; }
108
+
82
109
// This returns true as a convenience for the parser functions that return
83
110
// true on error.
84
111
bool ParseError (LocTy ErrorLoc, const Twine &Msg) {
@@ -94,6 +121,8 @@ namespace llvm {
94
121
lltok::Kind LexToken ();
95
122
96
123
int getNextChar ();
124
+ const char *skipNChars (unsigned N);
125
+ void advancePositionTo (const char *Ptr);
97
126
void SkipLineComment ();
98
127
bool SkipCComment ();
99
128
lltok::Kind ReadString (lltok::Kind kind);
0 commit comments