]> granicus.if.org Git - re2c/commitdiff
Reduced "src/codegen/print.h" dependency for some unrelated files.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 11 May 2015 16:46:26 +0000 (17:46 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 11 May 2015 16:46:26 +0000 (17:46 +0100)
This is the first part of effort to reduce the total number of
interdependencies between different files.

"src/codegen/print.h" contains some pretty-printing functions
mostly used for code generation. There two other cases where.
these functions can also be useful:
    1. debug: it's not yet well developed, just some messy chunks
       of code that are commented out
    2. error messages: character pretty-printing is not actually
       very useful, since error messages mostly contain printable
       characters (pieces of user-supplied input)
From the above I conclude that non-codegen files don't really need
"src/codegen/print.h". If this will change, I'll consider moving
this functions to src/util.

re2c/bootstrap/scanner.cc
re2c/src/dfa/actions.cc
re2c/src/dfa/dfa.cc
re2c/src/parse/scanner.re
re2c/src/util/range.cc
re2c/src/util/range.h

index a90292ea0a60b0c04e508d91af8b4f1fb4b6eef4..9908d3aaf25a45f3a14dc8cc8b749b850f05e7ee 100644 (file)
@@ -1,10 +1,9 @@
-/* Generated by re2c 0.14.1.dev on Mon May 11 13:39:25 2015*/
+/* Generated by re2c 0.14.1.dev on Mon May 11 17:45:17 2015*/
 #include <stdlib.h>
 #include <string.h>
 #include <iostream>
 #include <sstream>
 
-#include "src/codegen/print.h"
 #include "src/dfa/dfa.h"
 #include "src/globals.h"
 #include "src/parse/parser.h"
@@ -674,10 +673,7 @@ yy112:
        ++YYCURSOR;
 yy113:
        {
-                                       std::ostringstream msg;
-                                       msg << "unexpected character: ";
-                                       prtChOrHex(msg, *tok);
-                                       fatal(msg.str().c_str());
+                                       fatalf("unexpected character: '%c'", *tok);
                                        goto scan;
                                }
 yy114:
index 6beb3a81503cc93647c5a166bc0c96cc34a74f46..bb0adbcf09e38e2ff65970a1bff38d7cd0972c56 100644 (file)
@@ -5,7 +5,6 @@
 #include <iomanip>
 #include <cctype>
 
-#include "src/codegen/print.h"
 #include "src/codegen/skeleton/skeleton.h"
 #include "src/dfa/dfa.h"
 #include "src/dfa/encoding/utf16/utf16_regexp.h"
@@ -56,7 +55,9 @@ const Ins* showIns(std::ostream &o, const Ins &i, const Ins &base)
                        o << "match ";
 
                        for (; ret < (Ins*) i.i.link; ++ret)
-                               prtCh(o, ret->c.value);
+                       {
+                               o << "\\x" << std::hex << ret->c.value;
+                       }
 
                        break;
                }
@@ -1051,15 +1052,7 @@ smart_ptr<DFA> genCode(RegExp *re, Output & output, uint32_t ind)
 {
        CharSet cs;
        re->split(cs);
-       
-       /*for(uint32_t k = 0; k < encoding.nCodeUnits();)
-       {
-               uint32_t j;
-               for(j = k; ++k < encoding.nCodeUnits() && cs.rep[k] == cs.rep[j];);
-               printSpan(std::cerr, j, k);
-               std::cerr << "\t" << cs.rep[j] - &cs.ptn[0] << std::endl;
-       }*/
-       
+
        Char *rep = new Char[encoding.nCodeUnits()];
 
        for (uint32_t j = 0; j < encoding.nCodeUnits(); ++j)
@@ -1081,7 +1074,8 @@ smart_ptr<DFA> genCode(RegExp *re, Output & output, uint32_t ind)
        optimize(ins);
 
        /*
-       for (const Ins *inst = &ins[0]; inst < &ins[size]; ) {
+       for (const Ins *inst = &ins[0]; inst < &ins[size]; )
+       {
                inst = showIns(std::cout, *inst, ins[0]);
        }
        */
index dde4584099dd03189b20f439bdc8290efab81c00..de490e5e15ed609bd3a32216f5eac73e61d2c7e0 100644 (file)
@@ -2,7 +2,6 @@
 #include <ctype.h>
 #include <string.h>
 
-#include "src/codegen/print.h"
 #include "src/dfa/dfa.h"
 #include "src/globals.h"
 #include "src/util/substr.h"
index 6b7332a9b0dab1b7736ceb1008f372f234630665..206ebe4bfb40d6dd8aab6ca804b430a83937a525 100644 (file)
@@ -3,7 +3,6 @@
 #include <iostream>
 #include <sstream>
 
-#include "src/codegen/print.h"
 #include "src/dfa/dfa.h"
 #include "src/globals.h"
 #include "src/parse/parser.h"
@@ -420,10 +419,7 @@ scan:
                                }
 
        *                       {
-                                       std::ostringstream msg;
-                                       msg << "unexpected character: ";
-                                       prtChOrHex(msg, *tok);
-                                       fatal(msg.str().c_str());
+                                       fatalf("unexpected character: '%c'", *tok);
                                        goto scan;
                                }
 */
index 73dc2fc326f765d6e7b31dc7b781adffd01bc247..f815ea57d1c74df16d4c1c3cc3b11eb1d8fbe44a 100644 (file)
@@ -1,25 +1,8 @@
-#include "src/codegen/print.h"
 #include "src/util/range.h"
 
 namespace re2c
 {
 
-std::ostream& operator<<(std::ostream &o, const Range &r)
-{
-       if ((r.ub - r.lb) == 1)
-       {
-               prtCh(o, r.lb);
-       }
-       else
-       {
-               prtCh(o, r.lb);
-               o << "-";
-               prtCh(o, r.ub - 1);
-       }
-
-       return o << r.next;
-}
-
 Range *doUnion(Range *r1, Range *r2)
 {
        if (r1 == NULL)
index ed1478d90f8e7a41ca6c3a4afa0999dfb5bf9a87..561281789e2b2fe696a1f31b947a6616c5f3f865 100644 (file)
@@ -33,16 +33,8 @@ public:
        {
                vFreeList.erase(this);
        }
-
-       friend std::ostream& operator<<(std::ostream&, const Range&);
-       friend std::ostream& operator<<(std::ostream&, const Range*);
 };
 
-inline std::ostream& operator<<(std::ostream &o, const Range *r)
-{
-       return r ? o << *r : o;
-}
-
 Range *doUnion(Range *r1, Range *r2);
 Range *doDiff(Range *r1, Range *r2);