$(srcdir)/src/mbo_getopt.cc \
$(srcdir)/src/parse/input.cc \
$(srcdir)/src/parse/scanner.cc \
- $(srcdir)/src/util/range.cc \
- $(srcdir)/src/util/substr.cc
+ $(srcdir)/src/util/range.cc
# omit SRC_PARSER here; include it in EXTRA_DIST instead
# (automake generates standard build rules for all YACC-ish
# sources, they will conflict with our custom build rule).
-/* Generated by re2c 0.14.1.dev on Thu May 14 13:56:12 2015*/
+/* Generated by re2c 0.14.1.dev on Thu May 14 17:19:41 2015*/
#include <stdlib.h>
#include <string.h>
#include <iostream>
} else {
/* Add one char in front and one behind instead of 's or "s */
cur = cursor;
+ SubStr s (tok, cur - tok);
if (bCaseInsensitive || bCaseInverted)
{
- yylval.regexp = strToCaseInsensitiveRE(token());
+ yylval.regexp = strToCaseInsensitiveRE (s);
}
else
{
- yylval.regexp = strToRE(token());
+ yylval.regexp = strToRE (s);
}
return STRING;
}
++YYCURSOR;
{
cur = cursor;
- yylval.regexp = ranToRE(token());
+ SubStr s (tok, cur - tok);
+ yylval.regexp = ranToRE (s);
return RANGE;
}
yy193:
++YYCURSOR;
{
cur = cursor;
- yylval.regexp = invToRE(token());
+ SubStr s (tok, cur - tok);
+ yylval.regexp = invToRE (s);
return RANGE;
}
yy196:
++YYCURSOR;
{
cur = cursor;
+ SubStr s (tok + 1, cur - tok - 2);
if (bCaseInverted)
{
- yylval.regexp = strToRE(token(1, cur - tok - 2));
+ yylval.regexp = strToRE (s);
}
else
{
- yylval.regexp = strToCaseInsensitiveRE(token(1, cur - tok - 2));
+ yylval.regexp = strToCaseInsensitiveRE (s);
}
return STRING;
}
++YYCURSOR;
{
cur = cursor;
+ SubStr s (tok + 1, cur - tok - 2);
if (bCaseInsensitive || bCaseInverted)
{
- yylval.regexp = strToCaseInsensitiveRE(token(1, cur - tok - 2));
+ yylval.regexp = strToCaseInsensitiveRE (s);
}
else
{
- yylval.regexp = strToRE(token(1, cur - tok - 2));
+ yylval.regexp = strToRE (s);
}
return STRING;
}
yy352:
{
cur = cursor;
- yylval.number = atoi(token().to_string().c_str());
+ yylval.number = atoi(std::string (tok, cur - tok).c_str());
iscfg = 0;
return NUMBER;
}
yy380:
{
cur = cursor;
- cline = atoi(token().to_string().c_str());
+ cline = atoi(std::string (tok, cur - tok).c_str());
goto sourceline;
}
yy381:
++YYCURSOR;
{
cur = cursor;
- escape (in.file_name, token(1, cur - tok - 2).to_string());
+ escape (in.file_name, std::string (tok + 1, cur - tok - 2));
goto sourceline;
}
}
# checks for library functions
-AC_CHECK_FUNCS([strdup strndup])
+AC_CHECK_FUNCS([strdup])
AC_CONFIG_FILES([\
return new MatchOp(new Range(c, c + 1));
}
-RegExp * Scanner::strToRE(SubStr s) const
+RegExp * Scanner::strToRE (SubStr & s) const
{
if (s.len == 0)
return new NullOp;
return re;
}
-RegExp * Scanner::strToCaseInsensitiveRE(SubStr s) const
+RegExp * Scanner::strToCaseInsensitiveRE (SubStr & s) const
{
if (s.len == 0)
return new NullOp;
return new MatchOp(r);
}
-RegExp * Scanner::ranToRE(SubStr s) const
+RegExp * Scanner::ranToRE (SubStr & s) const
{
s.len -= 2;
s.str += 1;
return matchSymbolRange(mkRange(s));
}
-RegExp * Scanner::invToRE(SubStr s) const
+RegExp * Scanner::invToRE (SubStr & s) const
{
s.len -= 3;
s.str += 2;
#include <stdarg.h>
+#include <string.h>
#include "scanner.h"
+// used by Scanner::fatal_at and Scanner::fatalf
+#if defined(_MSC_VER) && !defined(vsnprintf)
+# define vsnprintf _vsnprintf
+#endif
+
namespace re2c {
void Scanner::config(const std::string & cfg, int num)
}
}
-void Scanner::check_token_length(char *pos, uint32_t len) const
-{
- if (pos < bot || pos + len > top)
- {
- fatal("Token exceeds limit");
- }
-}
-
void Scanner::reuse()
{
next_label = 0;
void config(const std::string &, int);
void config(const std::string &, const std::string &);
- void check_token_length(char *pos, uint32_t len) const;
- SubStr token() const;
- SubStr token(uint32_t start, uint32_t len) const;
-
uint32_t unescape(SubStr &s) const;
std::string& unescape(SubStr& str_in, std::string& str_out) const;
- Range * mkRange(SubStr &s) const;
- Range * getRange(SubStr &s) const;
- RegExp * matchSymbol(uint32_t c) const;
- RegExp * matchSymbolRange(Range * r) const;
- RegExp * strToName(SubStr s) const;
- RegExp * strToRE(SubStr s) const;
- RegExp * strToCaseInsensitiveRE(SubStr s) const;
- RegExp * ranToRE(SubStr s) const;
- RegExp * invToRE(SubStr s) const;
- RegExp * mkDot() const;
- RegExp * mkDefault() const;
+ Range * mkRange (SubStr & s) const;
+ Range * getRange (SubStr & s) const;
+ RegExp * matchSymbol (uint32_t c) const;
+ RegExp * matchSymbolRange (Range * r) const;
+ RegExp * strToRE (SubStr & s) const;
+ RegExp * strToCaseInsensitiveRE (SubStr & s) const;
+ RegExp * ranToRE (SubStr & s) const;
+ RegExp * invToRE (SubStr & s) const;
+ RegExp * mkDot () const;
+ RegExp * mkDefault () const;
FORBID_COPY (Scanner);
};
fatal(0, msg);
}
-inline SubStr Scanner::token() const
-{
- check_token_length(tok, cur - tok);
- return SubStr(tok, cur - tok);
-}
-
-inline SubStr Scanner::token(uint32_t start, uint32_t len) const
-{
- check_token_length(tok + start, len);
- return SubStr(tok + start, len);
-}
-
} // end namespace re2c
#endif
dstring {
cur = cursor;
+ SubStr s (tok + 1, cur - tok - 2);
if (bCaseInsensitive || bCaseInverted)
{
- yylval.regexp = strToCaseInsensitiveRE(token(1, cur - tok - 2));
+ yylval.regexp = strToCaseInsensitiveRE (s);
}
else
{
- yylval.regexp = strToRE(token(1, cur - tok - 2));
+ yylval.regexp = strToRE (s);
}
return STRING;
}
sstring {
cur = cursor;
+ SubStr s (tok + 1, cur - tok - 2);
if (bCaseInverted)
{
- yylval.regexp = strToRE(token(1, cur - tok - 2));
+ yylval.regexp = strToRE (s);
}
else
{
- yylval.regexp = strToCaseInsensitiveRE(token(1, cur - tok - 2));
+ yylval.regexp = strToCaseInsensitiveRE (s);
}
return STRING;
}
istring {
cur = cursor;
- yylval.regexp = invToRE(token());
+ SubStr s (tok, cur - tok);
+ yylval.regexp = invToRE (s);
return RANGE;
}
cstring {
cur = cursor;
- yylval.regexp = ranToRE(token());
+ SubStr s (tok, cur - tok);
+ yylval.regexp = ranToRE (s);
return RANGE;
}
} else {
/* Add one char in front and one behind instead of 's or "s */
cur = cursor;
+ SubStr s (tok, cur - tok);
if (bCaseInsensitive || bCaseInverted)
{
- yylval.regexp = strToCaseInsensitiveRE(token());
+ yylval.regexp = strToCaseInsensitiveRE (s);
}
else
{
- yylval.regexp = strToRE(token());
+ yylval.regexp = strToRE (s);
}
return STRING;
}
/*!re2c
number {
cur = cursor;
- yylval.number = atoi(token().to_string().c_str());
+ yylval.number = atoi(std::string (tok, cur - tok).c_str());
iscfg = 0;
return NUMBER;
}
/*!re2c
lineno {
cur = cursor;
- cline = atoi(token().to_string().c_str());
+ cline = atoi(std::string (tok, cur - tok).c_str());
goto sourceline;
}
dstring {
cur = cursor;
- escape (in.file_name, token(1, cur - tok - 2).to_string());
+ escape (in.file_name, std::string (tok + 1, cur - tok - 2));
goto sourceline;
}
"\n" {
+++ /dev/null
-/* $Id$ */
-#include <string.h>
-#include <stdlib.h>
-
-#include "src/globals.h"
-#include "src/util/substr.h"
-
-#ifndef HAVE_STRNDUP
-
-char *strndup(const char *str, size_t len)
-{
- char * ret = (char*)malloc(len + 1);
-
- memcpy(ret, str, len);
- ret[len] = '\0';
- return ret;
-}
-
-#endif
-
-namespace re2c
-{
-
-void SubStr::out(std::ostream& o) const
-{
- o.write(str, len);
-}
-
-bool operator==(const SubStr &s1, const SubStr &s2)
-{
- return (bool) (s1.len == s2.len && memcmp(s1.str, s2.str, s1.len) == 0);
-}
-
-} // end namespace re2c
-/* $Id$ */
-#ifndef _substr_h
-#define _substr_h
+#ifndef __SUBSTR__
+#define __SUBSTR__
-#include <iostream>
-#include <string>
-#include <string.h>
-
-#include "config.h"
#include "src/util/c99_stdint.h"
+#include "src/util/forbid_copy.h"
namespace re2c
{
const char * const org;
uint32_t len;
-public:
- friend bool operator==(const SubStr &, const SubStr &);
- SubStr(const uint8_t *, uint32_t);
- SubStr(const char*, uint32_t);
- explicit SubStr(const char*);
- SubStr(const SubStr&);
- virtual ~SubStr();
- void out(std::ostream&) const;
- std::string to_string() const;
- uint32_t ofs() const;
-
-private:
- SubStr & operator = (const SubStr &);
+ inline SubStr (const char * s, uint32_t l)
+ : str (s)
+ , org (s)
+ , len (l)
+ {}
+ inline uint32_t ofs () const
+ {
+ return str - org;
+ }
+
+ FORBID_COPY (SubStr);
};
-inline std::ostream& operator<<(std::ostream& o, const SubStr &s)
-{
- s.out(o);
- return o;
-}
-
-inline std::ostream& operator<<(std::ostream& o, const SubStr* s)
-{
- return o << *s;
-}
-
-inline SubStr::SubStr(const uint8_t *s, uint32_t l)
- : str((char*)s), org((char*)s), len(l)
-{ }
-
-inline SubStr::SubStr(const char *s, uint32_t l)
- : str(s), org(s), len(l)
-{ }
-
-inline SubStr::SubStr(const char *s)
- : str(s), org(s), len(strlen(s))
-{ }
-
-inline SubStr::SubStr(const SubStr &s)
- : str(s.str), org(s.str), len(s.len)
-{ }
-
-inline SubStr::~SubStr()
-{ }
-
-inline std::string SubStr::to_string() const
-{
- return str && len ? std::string(str, len) : std::string();
-}
-
-inline uint32_t SubStr::ofs() const
-{
- return str - org;
-}
-
-} // end namespace re2c
-
-#ifndef HAVE_STRNDUP
-
-char *strndup(const char *str, size_t len);
-
-#endif
-
-#if defined(_MSC_VER) && !defined(vsnprintf)
-#define vsnprintf _vsnprintf
-#endif
+} // namespace re2c
-#endif
+#endif // __SUBSTR__