aboutsummaryrefslogtreecommitdiff
path: root/gcc/cobol/lexio.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cobol/lexio.h')
-rw-r--r--gcc/cobol/lexio.h35
1 files changed, 17 insertions, 18 deletions
diff --git a/gcc/cobol/lexio.h b/gcc/cobol/lexio.h
index cf7f53a..eb41068 100644
--- a/gcc/cobol/lexio.h
+++ b/gcc/cobol/lexio.h
@@ -43,7 +43,6 @@
#define SPACE ' '
bool lexer_echo();
-
bool is_reference_format();
static inline bool isquote( char ch ) {
@@ -70,7 +69,9 @@ erase_source( char *src, char *esrc ) {
struct bytespan_t {
char *data, *eodata;
- bytespan_t( char *data = NULL, char *eodata = NULL )
+ bytespan_t() : data( nullptr), eodata(nullptr) {}
+
+ bytespan_t( char *data, char *eodata )
: data(data), eodata(eodata)
{
if( eodata < data ) {
@@ -111,19 +112,7 @@ struct bytespan_t {
}
};
-/* Location type. Borrowed from parse.h as generated by Bison. */
-#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
-typedef struct YYLTYPE YYLTYPE;
-struct YYLTYPE
-{
- int first_line;
- int first_column;
- int last_line;
- int last_column;
-};
-# define YYLTYPE_IS_DECLARED 1
-# define YYLTYPE_IS_TRIVIAL 1
-#endif
+// YYLTYPE supplied by cbldiag.h. Borrowed from parse.h as generated by Bison.
struct filespan_t : public bytespan_t {
char *cur, *eol, *quote;
@@ -137,7 +126,7 @@ struct filespan_t : public bytespan_t {
{}
filespan_t(void *p, size_t len)
: bytespan_t( static_cast<char*>(p), static_cast<char*>(p) + len )
- , cur(data), eol(data), quote(NULL), iline(0), line_quote72(0)
+ , cur(data), eol(data), quote(NULL), iline(0), icol(0), line_quote72(0)
{}
size_t lineno() const { return iline; }
@@ -237,6 +226,7 @@ struct span_t {
span_t( const char *data, const char *eodata ) : p(data), pend(eodata) {
verify();
}
+ // cppcheck-suppress operatorEqRetRefThis
span_t& operator=( const csub_match& cm ) {
p = cm.first;
pend = cm.second;
@@ -245,6 +235,8 @@ struct span_t {
int size() const { return pend - p; }
+ size_t nlines() const { return p && pend? std::count(p, pend, '\n') : 0; }
+
span_t dup() const {
auto output = new char[size() + 1];
auto eout = std::copy(p, pend, output);
@@ -255,12 +247,19 @@ struct span_t {
auto p = std::find(this->p, pend, '\0');
return p != pend? p : NULL;
}
+
+ bool at_eol() const {
+ return p < pend && '\n' == pend[-1];
+ }
+ const char * optional_eol() const {
+ return at_eol() ? "" : "\n";
+ }
};
struct replace_t {
struct span_t before, after;
- replace_t( span_t before = span_t(),
- span_t after = span_t() )
+ replace_t() : before(span_t()), after(span_t()) {}
+ replace_t( span_t before, span_t after )
: before(before), after(after)
{}
replace_t& reset() {