From 6a5cc88e4b7b7e77308c23f2650b2f6022dda8e4 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 26 Mar 2015 16:42:58 +0000 Subject: [PATCH] Don't output YYCTXMARKER stuff in .dot mode. Added test that revealed error. --- re2c/code.cc | 4 +- re2c/test/scanner_re2c_default.D.c | 757 ++++++++++++++++++++++++++++ re2c/test/scanner_re2c_default.D.re | 652 ++++++++++++++++++++++++ 3 files changed, 1411 insertions(+), 2 deletions(-) create mode 100644 re2c/test/scanner_re2c_default.D.c create mode 100644 re2c/test/scanner_re2c_default.D.re diff --git a/re2c/code.cc b/re2c/code.cc index 7fb6da1f..2d80fd3a 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -581,7 +581,7 @@ void Rule::emit(Output & output, uint ind, bool &, const std::string& condName) uint back = rule->ctx->fixedLength(); - if (back != 0u) + if (back != 0u && !DFlag) { o << input_api.stmt_restorectx (ind); } @@ -622,7 +622,7 @@ void State::emit(Output & output, uint ind, bool &readCh, const std::string& con { o << indent(ind) << mapCodeName["YYDEBUG"] << "(" << label << ", " << input_api.expr_peek () << ");\n"; } - if (isPreCtxt) + if (isPreCtxt && !DFlag) { o << input_api.stmt_backupctx (ind); } diff --git a/re2c/test/scanner_re2c_default.D.c b/re2c/test/scanner_re2c_default.D.c new file mode 100644 index 00000000..32256c3f --- /dev/null +++ b/re2c/test/scanner_re2c_default.D.c @@ -0,0 +1,757 @@ +/* Generated by re2c */ + +digraph re2c { + + +1 -> 2 [label="[0x00]"] +1 -> 4 [label="[0x01-0x09][0x0B-$][&-)][+-.][0-0xFF]"] +1 -> 6 [label="[0x0A]"] +1 -> 8 [label="[%]"] +1 -> 9 [label="[*]"] +1 -> 10 [label="[/]"] +2 -> 3 +3 [label="scanner_re2c_default.D.re:210"] +4 -> 5 +5 [label="scanner_re2c_default.D.re:221"] +6 -> 7 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +6 -> 89 [label="[0x09][ ]"] +6 -> 91 [label="[#]"] +7 [label="scanner_re2c_default.D.re:197"] +8 -> 5 [label="[0x00-z][|-0xFF]"] +8 -> 32 [label="[{]"] +9 -> 5 [label="[0x00-.][0-0xFF]"] +9 -> 84 [label="[/]"] +10 -> 5 [label="[0x00-)][+-0xFF]"] +10 -> 11 [label="[*]"] +11 -> 12 [label="[0x00- ][\"-0xFF]"] +11 -> 13 [label="[!]"] +12 -> 7 [label="yyaccept=0"] +12 -> 5 [label="yyaccept=1"] +12 -> 85 [label="yyaccept=2"] +13 -> 12 [label="[0x00-f][h][j-l][n-q][s][v-0xFF]"] +13 -> 16 [label="[g]"] +13 -> 15 [label="[i]"] +13 -> 17 [label="[m]"] +13 -> 19 [label="[r]"] +13 -> 14 [label="[t]"] +13 -> 18 [label="[u]"] +14 -> 12 [label="[0x00-x][z-0xFF]"] +14 -> 74 [label="[y]"] +15 -> 12 [label="[0x00-f][h-0xFF]"] +15 -> 63 [label="[g]"] +16 -> 12 [label="[0x00-d][f-0xFF]"] +16 -> 50 [label="[e]"] +17 -> 12 [label="[0x00-`][b-0xFF]"] +17 -> 42 [label="[a]"] +18 -> 12 [label="[0x00-r][t-0xFF]"] +18 -> 34 [label="[s]"] +19 -> 12 [label="[0x00-d][f-t][v-0xFF]"] +19 -> 20 [label="[e]"] +19 -> 21 [label="[u]"] +20 -> 12 [label="[0x00-1][3-0xFF]"] +20 -> 31 [label="[2]"] +21 -> 12 [label="[0x00-k][m-0xFF]"] +21 -> 22 [label="[l]"] +22 -> 12 [label="[0x00-d][f-0xFF]"] +22 -> 23 [label="[e]"] +23 -> 12 [label="[0x00-r][t-0xFF]"] +23 -> 24 [label="[s]"] +24 -> 12 [label="[0x00-9][;-0xFF]"] +24 -> 25 [label="[:]"] +25 -> 12 [label="[0x00-q][s-0xFF]"] +25 -> 26 [label="[r]"] +26 -> 12 [label="[0x00-d][f-0xFF]"] +26 -> 27 [label="[e]"] +27 -> 12 [label="[0x00-1][3-0xFF]"] +27 -> 28 [label="[2]"] +28 -> 12 [label="[0x00-b][d-0xFF]"] +28 -> 29 [label="[c]"] +29 -> 30 +30 [label="scanner_re2c_default.D.re:83"] +31 -> 12 [label="[0x00-b][d-0xFF]"] +31 -> 32 [label="[c]"] +32 -> 33 +33 [label="scanner_re2c_default.D.re:67"] +34 -> 12 [label="[0x00-d][f-0xFF]"] +34 -> 35 [label="[e]"] +35 -> 12 [label="[0x00-9][;-0xFF]"] +35 -> 36 [label="[:]"] +36 -> 12 [label="[0x00-q][s-0xFF]"] +36 -> 37 [label="[r]"] +37 -> 12 [label="[0x00-d][f-0xFF]"] +37 -> 38 [label="[e]"] +38 -> 12 [label="[0x00-1][3-0xFF]"] +38 -> 39 [label="[2]"] +39 -> 12 [label="[0x00-b][d-0xFF]"] +39 -> 40 [label="[c]"] +40 -> 41 +41 [label="scanner_re2c_default.D.re:99"] +42 -> 12 [label="[0x00-w][y-0xFF]"] +42 -> 43 [label="[x]"] +43 -> 12 [label="[0x00-9][;-0xFF]"] +43 -> 44 [label="[:]"] +44 -> 12 [label="[0x00-q][s-0xFF]"] +44 -> 45 [label="[r]"] +45 -> 12 [label="[0x00-d][f-0xFF]"] +45 -> 46 [label="[e]"] +46 -> 12 [label="[0x00-1][3-0xFF]"] +46 -> 47 [label="[2]"] +47 -> 12 [label="[0x00-b][d-0xFF]"] +47 -> 48 [label="[c]"] +48 -> 49 +49 [label="scanner_re2c_default.D.re:116"] +50 -> 12 [label="[0x00-s][u-0xFF]"] +50 -> 51 [label="[t]"] +51 -> 12 [label="[0x00-r][t-0xFF]"] +51 -> 52 [label="[s]"] +52 -> 12 [label="[0x00-s][u-0xFF]"] +52 -> 53 [label="[t]"] +53 -> 12 [label="[0x00-`][b-0xFF]"] +53 -> 54 [label="[a]"] +54 -> 12 [label="[0x00-s][u-0xFF]"] +54 -> 55 [label="[t]"] +55 -> 12 [label="[0x00-d][f-0xFF]"] +55 -> 56 [label="[e]"] +56 -> 12 [label="[0x00-9][;-0xFF]"] +56 -> 57 [label="[:]"] +57 -> 12 [label="[0x00-q][s-0xFF]"] +57 -> 58 [label="[r]"] +58 -> 12 [label="[0x00-d][f-0xFF]"] +58 -> 59 [label="[e]"] +59 -> 12 [label="[0x00-1][3-0xFF]"] +59 -> 60 [label="[2]"] +60 -> 12 [label="[0x00-b][d-0xFF]"] +60 -> 61 [label="[c]"] +61 -> 62 +62 [label="scanner_re2c_default.D.re:130"] +63 -> 12 [label="[0x00-m][o-0xFF]"] +63 -> 64 [label="[n]"] +64 -> 12 [label="[0x00-n][p-0xFF]"] +64 -> 65 [label="[o]"] +65 -> 12 [label="[0x00-q][s-0xFF]"] +65 -> 66 [label="[r]"] +66 -> 12 [label="[0x00-d][f-0xFF]"] +66 -> 67 [label="[e]"] +67 -> 12 [label="[0x00-9][;-0xFF]"] +67 -> 68 [label="[:]"] +68 -> 12 [label="[0x00-q][s-0xFF]"] +68 -> 69 [label="[r]"] +69 -> 12 [label="[0x00-d][f-0xFF]"] +69 -> 70 [label="[e]"] +70 -> 12 [label="[0x00-1][3-0xFF]"] +70 -> 71 [label="[2]"] +71 -> 12 [label="[0x00-b][d-0xFF]"] +71 -> 72 [label="[c]"] +72 -> 73 +73 [label="scanner_re2c_default.D.re:136"] +74 -> 12 [label="[0x00-o][q-0xFF]"] +74 -> 75 [label="[p]"] +75 -> 12 [label="[0x00-d][f-0xFF]"] +75 -> 76 [label="[e]"] +76 -> 12 [label="[0x00-r][t-0xFF]"] +76 -> 77 [label="[s]"] +77 -> 12 [label="[0x00-9][;-0xFF]"] +77 -> 78 [label="[:]"] +78 -> 12 [label="[0x00-q][s-0xFF]"] +78 -> 79 [label="[r]"] +79 -> 12 [label="[0x00-d][f-0xFF]"] +79 -> 80 [label="[e]"] +80 -> 12 [label="[0x00-1][3-0xFF]"] +80 -> 81 [label="[2]"] +81 -> 12 [label="[0x00-b][d-0xFF]"] +81 -> 82 [label="[c]"] +82 -> 83 +83 [label="scanner_re2c_default.D.re:141"] +84 -> 85 [label="[0x00-0x09][0x0B-0x0C][0x0E-0xFF]"] +84 -> 87 [label="[0x0A]"] +84 -> 86 [label="[0x0D]"] +85 [label="scanner_re2c_default.D.re:176"] +86 -> 12 [label="[0x00-0x09][0x0B-0xFF]"] +86 -> 87 [label="[0x0A]"] +87 -> 88 +88 [label="scanner_re2c_default.D.re:158"] +89 -> 90 +90 -> 12 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +90 -> 89 [label="[0x09][ ]"] +90 -> 91 [label="[#]"] +91 -> 92 +92 -> 12 [label="[0x00-0x08][0x0A-0x1F][!-k][m-0xFF]"] +92 -> 91 [label="[0x09][ ]"] +92 -> 93 [label="[l]"] +93 -> 12 [label="[0x00-h][j-0xFF]"] +93 -> 94 [label="[i]"] +94 -> 12 [label="[0x00-m][o-0xFF]"] +94 -> 95 [label="[n]"] +95 -> 12 [label="[0x00-d][f-0xFF]"] +95 -> 96 [label="[e]"] +96 -> 98 [label="[0x00-0][:-0xFF]"] +96 -> 12 [label="[1-9]"] +97 -> 98 +98 -> 12 [label="[0x00-0x08][0x0A-0x1F][!-0][:-0xFF]"] +98 -> 97 [label="[0x09][ ]"] +98 -> 99 [label="[1-9]"] +99 -> 100 +100 -> 12 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-/][:-0xFF]"] +100 -> 101 [label="[0x09][ ]"] +100 -> 103 [label="[0x0A]"] +100 -> 105 [label="[0x0D]"] +100 -> 99 [label="[0-9]"] +101 -> 102 +102 -> 12 [label="[0x00-0x08][0x0A-0x1F][!][#-0xFF]"] +102 -> 101 [label="[0x09][ ]"] +102 -> 106 [label="[\"]"] +103 -> 104 +104 [label="scanner_re2c_default.D.re:193"] +105 -> 12 [label="[0x00-0x09][0x0B-0xFF]"] +105 -> 103 [label="[0x0A]"] +106 -> 107 +107 -> 106 [label="[0x00-0x09][0x0B-!][#-[][0x5D-0xFF]"] +107 -> 12 [label="[0x0A]"] +107 -> 109 [label="[\"]"] +107 -> 108 [label="[\\]"] +108 -> 106 [label="[0x00-0x09][0x0B-0xFF]"] +108 -> 12 [label="[0x0A]"] +109 -> 12 [label="[0x00-0x09][0x0B-0x0C][0x0E-0xFF]"] +109 -> 103 [label="[0x0A]"] +109 -> 105 [label="[0x0D]"] +} + +digraph re2c { + +111 -> 112 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!][#-$][&][-][0-9][@][0x5D-^][`][}-0xFF]"] +111 -> 114 [label="[0x09][ ]"] +111 -> 116 [label="[0x0A]"] +111 -> 118 [label="[0x0D]"] +111 -> 119 [label="[\"]"] +111 -> 121 [label="[%]"] +111 -> 122 [label="[']"] +111 -> 124 [label="[(-)][,][;][=->][\\][|]"] +111 -> 126 [label="[*]"] +111 -> 128 [label="[+][?]"] +111 -> 130 [label="[.]"] +111 -> 132 [label="[/]"] +111 -> 133 [label="[:]"] +111 -> 134 [label="[<]"] +111 -> 135 [label="[A-Z][_][a-q][s-z]"] +111 -> 136 [label="[[]"] +111 -> 138 [label="[r]"] +111 -> 139 [label="[{]"] +112 -> 113 +113 [label="scanner_re2c_default.D.re:441"] +114 -> 248 +115 [label="scanner_re2c_default.D.re:425"] +116 -> 117 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +116 -> 226 [label="[0x09][ ]"] +116 -> 228 [label="[#]"] +117 [label="scanner_re2c_default.D.re:434"] +118 -> 113 [label="[0x00-0x09][0x0B-0xFF]"] +118 -> 225 [label="[0x0A]"] +119 -> 221 [label="[0x00-0x09][0x0B-0xFF]"] +119 -> 120 [label="[0x0A]"] +120 [label="scanner_re2c_default.D.re:301"] +121 -> 113 [label="[0x00-|][~-0xFF]"] +121 -> 213 [label="[}]"] +122 -> 216 [label="[0x00-0x09][0x0B-0xFF]"] +122 -> 123 [label="[0x0A]"] +123 [label="scanner_re2c_default.D.re:304"] +124 -> 125 +125 [label="scanner_re2c_default.D.re:330"] +126 -> 127 [label="[0x00-.][0-0xFF]"] +126 -> 213 [label="[/]"] +127 [label="scanner_re2c_default.D.re:334"] +128 -> 129 +129 [label="scanner_re2c_default.D.re:338"] +130 -> 131 +131 [label="scanner_re2c_default.D.re:419"] +132 -> 125 [label="[0x00-)][+-.][0-0xFF]"] +132 -> 209 [label="[*]"] +132 -> 211 [label="[/]"] +133 -> 113 [label="[0x00-<][>-0xFF]"] +133 -> 205 [label="[=]"] +134 -> 125 [label="[0x00- ][\"-=][?-0xFF]"] +134 -> 196 [label="[!]"] +134 -> 198 [label="[>]"] +135 -> 164 +136 -> 187 [label="[0x00-0x09][0x0B-0x5D][_-0xFF]"] +136 -> 137 [label="[0x0A]"] +136 -> 188 [label="[^]"] +137 [label="scanner_re2c_default.D.re:320"] +138 -> 164 [label="[0x00-d][f-0xFF]"] +138 -> 166 [label="[e]"] +139 -> 140 [label="[0x00-+][--/][:-@][[-^][`][{-0xFF]"] +139 -> 147 [label="[,]"] +139 -> 144 [label="[0]"] +139 -> 145 [label="[1-9]"] +139 -> 141 [label="[A-Z][_][a-z]"] +140 [label="scanner_re2c_default.D.re:245"] +141 -> 142 +142 -> 143 [label="[0x00-/][:-@][[-^][`][{-|][~-0xFF]"] +142 -> 141 [label="[0-9][A-Z][_][a-z]"] +142 -> 161 [label="[}]"] +143 -> 117 [label="yyaccept=0"] +143 -> 120 [label="yyaccept=1"] +143 -> 123 [label="yyaccept=2"] +143 -> 125 [label="yyaccept=3"] +143 -> 137 [label="yyaccept=4"] +143 -> 140 [label="yyaccept=5"] +143 -> 148 [label="yyaccept=6"] +143 -> 181 [label="yyaccept=7"] +144 -> 146 [label="[0x00-+][--0xFF]"] +144 -> 158 [label="[,]"] +145 -> 146 +146 -> 143 [label="[0x00-+][--/][:-|][~-0xFF]"] +146 -> 151 [label="[,]"] +146 -> 145 [label="[0-9]"] +146 -> 149 [label="[}]"] +147 -> 148 +148 [label="scanner_re2c_default.D.re:366"] +149 -> 150 +150 [label="scanner_re2c_default.D.re:348"] +151 -> 148 [label="[0x00-/][:-|][~-0xFF]"] +151 -> 154 [label="[0-9]"] +151 -> 152 [label="[}]"] +152 -> 153 +153 [label="scanner_re2c_default.D.re:360"] +154 -> 155 +155 -> 143 [label="[0x00-/][:-|][~-0xFF]"] +155 -> 154 [label="[0-9]"] +155 -> 156 [label="[}]"] +156 -> 157 +157 [label="scanner_re2c_default.D.re:354"] +158 -> 148 [label="[0x00-/][:-|][~-0xFF]"] +158 -> 154 [label="[0-9]"] +158 -> 159 [label="[}]"] +159 -> 160 +160 [label="scanner_re2c_default.D.re:343"] +161 -> 162 +162 [label="scanner_re2c_default.D.re:370"] +163 -> 164 +164 -> 167 [label="[0x00-0x08][0x0A-0x1F][!-+][--/][:-<][?-@][[-^][`][{-0xFF]"] +164 -> 168 [label="[0x09][ ]"] +164 -> 169 [label="[,][=->]"] +164 -> 163 [label="[0-9][A-Z][_][a-z]"] +165 [label="scanner_re2c_default.D.re:399"] +166 -> 164 [label="[0x00-1][3-0xFF]"] +166 -> 176 [label="[2]"] +167 -> 165 +168 -> 174 +169 -> 170 +170 [label="scanner_re2c_default.D.re:393"] +171 -> 172 +172 [label="scanner_re2c_default.D.re:387"] +173 -> 174 +174 -> 171 [label="[0x00-0x08][0x0A-0x1F][!-+][--<][?-0xFF]"] +174 -> 173 [label="[0x09][ ]"] +174 -> 175 [label="[,][=->]"] +175 -> 170 +176 -> 164 [label="[0x00-b][d-0xFF]"] +176 -> 177 [label="[c]"] +177 -> 164 [label="[0x00-9][;-0xFF]"] +177 -> 178 [label="[:]"] +178 -> 165 [label="[0x00-@][[-^][`][{-0xFF]"] +178 -> 179 [label="[A-Z][_][a-z]"] +179 -> 180 +180 -> 181 [label="[0x00-/][;-?][[-^][`][{-0xFF]"] +180 -> 179 [label="[0-9][A-Z][_][a-z]"] +180 -> 183 [label="[:]"] +180 -> 182 [label="[@]"] +181 [label="scanner_re2c_default.D.re:379"] +182 -> 143 [label="[0x00-@][[-^][`][{-0xFF]"] +182 -> 184 [label="[A-Z][_][a-z]"] +183 -> 143 [label="[0x00-@][[-^][`][{-0xFF]"] +183 -> 179 [label="[A-Z][_][a-z]"] +184 -> 185 +185 -> 181 [label="[0x00-/][:-@][[-^][`][{-0xFF]"] +185 -> 184 [label="[0-9][A-Z][_][a-z]"] +186 -> 187 +187 -> 186 [label="[0x00-0x09][0x0B-[][^-0xFF]"] +187 -> 143 [label="[0x0A]"] +187 -> 190 [label="[\\]"] +187 -> 191 [label="[0x5D]"] +188 -> 189 +189 -> 188 [label="[0x00-0x09][0x0B-[][^-0xFF]"] +189 -> 143 [label="[0x0A]"] +189 -> 193 [label="[\\]"] +189 -> 194 [label="[0x5D]"] +190 -> 186 [label="[0x00-0x09][0x0B-0xFF]"] +190 -> 143 [label="[0x0A]"] +191 -> 192 +192 [label="scanner_re2c_default.D.re:314"] +193 -> 188 [label="[0x00-0x09][0x0B-0xFF]"] +193 -> 143 [label="[0x0A]"] +194 -> 195 +195 [label="scanner_re2c_default.D.re:308"] +196 -> 197 +197 [label="scanner_re2c_default.D.re:327"] +198 -> 200 +199 -> 200 +200 -> 143 [label="[0x00-0x08][0x0A-0x1F][!-9][;-<][>-z][|-0xFF]"] +200 -> 199 [label="[0x09][ ]"] +200 -> 204 [label="[:]"] +200 -> 203 [label="[=]"] +200 -> 201 [label="[{]"] +201 -> 202 +202 [label="scanner_re2c_default.D.re:324"] +203 -> 143 [label="[0x00-=][?-0xFF]"] +203 -> 201 [label="[>]"] +204 -> 143 [label="[0x00-<][>-0xFF]"] +204 -> 201 [label="[=]"] +205 -> 206 [label="[0x00-=][?-0xFF]"] +205 -> 207 [label="[>]"] +206 [label="scanner_re2c_default.D.re:254"] +207 -> 208 +208 [label="scanner_re2c_default.D.re:250"] +209 -> 210 +210 [label="scanner_re2c_default.D.re:264"] +211 -> 212 +212 [label="scanner_re2c_default.D.re:261"] +213 -> 214 +214 [label="scanner_re2c_default.D.re:270"] +215 -> 216 +216 -> 215 [label="[0x00-0x09][0x0B-&][(-[][0x5D-0xFF]"] +216 -> 143 [label="[0x0A]"] +216 -> 218 [label="[']"] +216 -> 217 [label="[\\]"] +217 -> 215 [label="[0x00-0x09][0x0B-0xFF]"] +217 -> 143 [label="[0x0A]"] +218 -> 219 +219 [label="scanner_re2c_default.D.re:288"] +220 -> 221 +221 -> 220 [label="[0x00-0x09][0x0B-!][#-[][0x5D-0xFF]"] +221 -> 143 [label="[0x0A]"] +221 -> 223 [label="[\"]"] +221 -> 222 [label="[\\]"] +222 -> 220 [label="[0x00-0x09][0x0B-0xFF]"] +222 -> 143 [label="[0x0A]"] +223 -> 224 +224 [label="scanner_re2c_default.D.re:275"] +225 -> 117 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +225 -> 226 [label="[0x09][ ]"] +225 -> 228 [label="[#]"] +226 -> 227 +227 -> 143 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +227 -> 226 [label="[0x09][ ]"] +227 -> 228 [label="[#]"] +228 -> 229 +229 -> 143 [label="[0x00-0x08][0x0A-0x1F][!-k][m-0xFF]"] +229 -> 228 [label="[0x09][ ]"] +229 -> 230 [label="[l]"] +230 -> 143 [label="[0x00-h][j-0xFF]"] +230 -> 231 [label="[i]"] +231 -> 143 [label="[0x00-m][o-0xFF]"] +231 -> 232 [label="[n]"] +232 -> 143 [label="[0x00-d][f-0xFF]"] +232 -> 233 [label="[e]"] +233 -> 235 [label="[0x00-0][:-0xFF]"] +233 -> 143 [label="[1-9]"] +234 -> 235 +235 -> 143 [label="[0x00-0x08][0x0A-0x1F][!-0][:-0xFF]"] +235 -> 234 [label="[0x09][ ]"] +235 -> 236 [label="[1-9]"] +236 -> 237 +237 -> 143 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-/][:-0xFF]"] +237 -> 238 [label="[0x09][ ]"] +237 -> 240 [label="[0x0A]"] +237 -> 242 [label="[0x0D]"] +237 -> 236 [label="[0-9]"] +238 -> 239 +239 -> 143 [label="[0x00-0x08][0x0A-0x1F][!][#-0xFF]"] +239 -> 238 [label="[0x09][ ]"] +239 -> 243 [label="[\"]"] +240 -> 241 +241 [label="scanner_re2c_default.D.re:429"] +242 -> 143 [label="[0x00-0x09][0x0B-0xFF]"] +242 -> 240 [label="[0x0A]"] +243 -> 244 +244 -> 243 [label="[0x00-0x09][0x0B-!][#-[][0x5D-0xFF]"] +244 -> 143 [label="[0x0A]"] +244 -> 246 [label="[\"]"] +244 -> 245 [label="[\\]"] +245 -> 243 [label="[0x00-0x09][0x0B-0xFF]"] +245 -> 143 [label="[0x0A]"] +246 -> 143 [label="[0x00-0x09][0x0B-0x0C][0x0E-0xFF]"] +246 -> 240 [label="[0x0A]"] +246 -> 242 [label="[0x0D]"] +247 -> 248 +248 -> 115 [label="[0x00-0x08][0x0A-0x1F][!-0xFF]"] +248 -> 247 [label="[0x09][ ]"] +} + +digraph re2c { + +250 -> 251 [label="[0x00]"] +250 -> 253 [label="[0x01-0x09][0x0B-!][#-&][(-z][|][~-0xFF]"] +250 -> 255 [label="[0x0A]"] +250 -> 257 [label="[\"]"] +250 -> 258 [label="[']"] +250 -> 259 [label="[{]"] +250 -> 261 [label="[}]"] +251 -> 252 +252 [label="scanner_re2c_default.D.re:513"] +253 -> 254 +254 [label="scanner_re2c_default.D.re:527"] +255 -> 256 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-\"][$-0xFF]"] +255 -> 272 [label="[0x09][ ]"] +255 -> 274 [label="[0x0A][0x0D]"] +255 -> 275 [label="[#]"] +256 [label="scanner_re2c_default.D.re:493"] +257 -> 270 [label="[0x00-0x09][0x0B-0xFF]"] +257 -> 254 [label="[0x0A]"] +258 -> 264 [label="[0x00-0x09][0x0B-0xFF]"] +258 -> 254 [label="[0x0A]"] +259 -> 260 +260 [label="scanner_re2c_default.D.re:465"] +261 -> 262 +262 [label="scanner_re2c_default.D.re:452"] +263 -> 264 +264 -> 263 [label="[0x00-0x09][0x0B-&][(-[][0x5D-0xFF]"] +264 -> 265 [label="[0x0A]"] +264 -> 267 [label="[']"] +264 -> 266 [label="[\\]"] +265 -> 256 [label="yyaccept=0"] +265 -> 254 [label="yyaccept=1"] +265 -> 273 [label="yyaccept=2"] +266 -> 263 [label="[0x00-0x09][0x0B-0xFF]"] +266 -> 265 [label="[0x0A]"] +267 -> 268 +268 [label="scanner_re2c_default.D.re:524"] +269 -> 270 +270 -> 269 [label="[0x00-0x09][0x0B-!][#-[][0x5D-0xFF]"] +270 -> 265 [label="[0x0A]"] +270 -> 267 [label="[\"]"] +270 -> 271 [label="[\\]"] +271 -> 269 [label="[0x00-0x09][0x0B-0xFF]"] +271 -> 265 [label="[0x0A]"] +272 -> 273 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +272 -> 294 [label="[0x09][ ]"] +272 -> 275 [label="[#]"] +273 [label="scanner_re2c_default.D.re:480"] +274 -> 273 +275 -> 276 +276 -> 265 [label="[0x00-0x08][0x0A-0x1F][!-k][m-0xFF]"] +276 -> 275 [label="[0x09][ ]"] +276 -> 277 [label="[l]"] +277 -> 265 [label="[0x00-h][j-0xFF]"] +277 -> 278 [label="[i]"] +278 -> 265 [label="[0x00-m][o-0xFF]"] +278 -> 279 [label="[n]"] +279 -> 265 [label="[0x00-d][f-0xFF]"] +279 -> 280 [label="[e]"] +280 -> 282 [label="[0x00-0][:-0xFF]"] +280 -> 265 [label="[1-9]"] +281 -> 282 +282 -> 265 [label="[0x00-0x08][0x0A-0x1F][!-0][:-0xFF]"] +282 -> 281 [label="[0x09][ ]"] +282 -> 283 [label="[1-9]"] +283 -> 284 +284 -> 265 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-/][:-0xFF]"] +284 -> 285 [label="[0x09][ ]"] +284 -> 287 [label="[0x0A]"] +284 -> 289 [label="[0x0D]"] +284 -> 283 [label="[0-9]"] +285 -> 286 +286 -> 265 [label="[0x00-0x08][0x0A-0x1F][!][#-0xFF]"] +286 -> 285 [label="[0x09][ ]"] +286 -> 290 [label="[\"]"] +287 -> 288 +288 [label="scanner_re2c_default.D.re:476"] +289 -> 265 [label="[0x00-0x09][0x0B-0xFF]"] +289 -> 287 [label="[0x0A]"] +290 -> 291 +291 -> 290 [label="[0x00-0x09][0x0B-!][#-[][0x5D-0xFF]"] +291 -> 265 [label="[0x0A]"] +291 -> 293 [label="[\"]"] +291 -> 292 [label="[\\]"] +292 -> 290 [label="[0x00-0x09][0x0B-0xFF]"] +292 -> 265 [label="[0x0A]"] +293 -> 265 [label="[0x00-0x09][0x0B-0x0C][0x0E-0xFF]"] +293 -> 287 [label="[0x0A]"] +293 -> 289 [label="[0x0D]"] +294 -> 295 +295 -> 265 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +295 -> 294 [label="[0x09][ ]"] +295 -> 275 [label="[#]"] +} + +digraph re2c { + +297 -> 298 [label="[0x00-0x09][0x0B-)][+-.][0-0xFF]"] +297 -> 300 [label="[0x0A]"] +297 -> 302 [label="[*]"] +297 -> 303 [label="[/]"] +298 -> 299 +299 [label="scanner_re2c_default.D.re:562"] +300 -> 301 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +300 -> 308 [label="[0x09][ ]"] +300 -> 311 [label="[#]"] +301 [label="scanner_re2c_default.D.re:553"] +302 -> 299 [label="[0x00-.][0-0xFF]"] +302 -> 306 [label="[/]"] +303 -> 299 [label="[0x00-)][+-0xFF]"] +303 -> 304 [label="[*]"] +304 -> 305 +305 [label="scanner_re2c_default.D.re:544"] +306 -> 307 +307 [label="scanner_re2c_default.D.re:534"] +308 -> 309 +309 -> 310 [label="[0x00-0x08][0x0A-0x1F][!-\"][$-0xFF]"] +309 -> 308 [label="[0x09][ ]"] +309 -> 311 [label="[#]"] +310 -> 301 +311 -> 312 +312 -> 310 [label="[0x00-0x08][0x0A-0x1F][!-k][m-0xFF]"] +312 -> 311 [label="[0x09][ ]"] +312 -> 313 [label="[l]"] +313 -> 310 [label="[0x00-h][j-0xFF]"] +313 -> 314 [label="[i]"] +314 -> 310 [label="[0x00-m][o-0xFF]"] +314 -> 315 [label="[n]"] +315 -> 310 [label="[0x00-d][f-0xFF]"] +315 -> 316 [label="[e]"] +316 -> 318 [label="[0x00-0][:-0xFF]"] +316 -> 310 [label="[1-9]"] +317 -> 318 +318 -> 310 [label="[0x00-0x08][0x0A-0x1F][!-0][:-0xFF]"] +318 -> 317 [label="[0x09][ ]"] +318 -> 319 [label="[1-9]"] +319 -> 320 +320 -> 310 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-/][:-0xFF]"] +320 -> 321 [label="[0x09][ ]"] +320 -> 323 [label="[0x0A]"] +320 -> 325 [label="[0x0D]"] +320 -> 319 [label="[0-9]"] +321 -> 322 +322 -> 310 [label="[0x00-0x08][0x0A-0x1F][!][#-0xFF]"] +322 -> 321 [label="[0x09][ ]"] +322 -> 326 [label="[\"]"] +323 -> 324 +324 [label="scanner_re2c_default.D.re:549"] +325 -> 310 [label="[0x00-0x09][0x0B-0xFF]"] +325 -> 323 [label="[0x0A]"] +326 -> 327 +327 -> 326 [label="[0x00-0x09][0x0B-!][#-[][0x5D-0xFF]"] +327 -> 310 [label="[0x0A]"] +327 -> 329 [label="[\"]"] +327 -> 328 [label="[\\]"] +328 -> 326 [label="[0x00-0x09][0x0B-0xFF]"] +328 -> 310 [label="[0x0A]"] +329 -> 310 [label="[0x00-0x09][0x0B-0x0C][0x0E-0xFF]"] +329 -> 323 [label="[0x0A]"] +329 -> 325 [label="[0x0D]"] +} + +digraph re2c { + +331 -> 332 [label="[0x00-0x09][0x0B-0xFF]"] +331 -> 334 [label="[0x0A]"] +332 -> 333 +333 [label="scanner_re2c_default.D.re:580"] +334 -> 335 +335 [label="scanner_re2c_default.D.re:573"] +} + +digraph re2c { + +337 -> 338 [label="[0x00-0x08][0x0A-0x1F][!-<][>-0xFF]"] +337 -> 340 [label="[0x09][ ]"] +337 -> 342 [label="[=]"] +338 -> 339 +339 [label="scanner_re2c_default.D.re:597"] +340 -> 347 +341 [label="scanner_re2c_default.D.re:589"] +342 -> 345 +343 [label="scanner_re2c_default.D.re:592"] +344 -> 345 +345 -> 343 [label="[0x00-0x08][0x0A-0x1F][!-0xFF]"] +345 -> 344 [label="[0x09][ ]"] +346 -> 347 +347 -> 341 [label="[0x00-0x08][0x0A-0x1F][!-0xFF]"] +347 -> 346 [label="[0x09][ ]"] +} + +digraph re2c { + +349 -> 356 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!][#-&][(-,][.-/][:][<-0xFF]"] +349 -> 350 [label="[0x09-0x0A][0x0D][ ][;]"] +349 -> 358 [label="[\"]"] +349 -> 360 [label="[']"] +349 -> 353 [label="[-]"] +349 -> 351 [label="[0]"] +349 -> 354 [label="[1-9]"] +350 [label="scanner_re2c_default.D.re:610"] +351 -> 356 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-:][<-0xFF]"] +351 -> 352 [label="[0x09-0x0A][0x0D][ ][;]"] +352 [label="scanner_re2c_default.D.re:604"] +353 -> 357 [label="[0x00-0][:-0xFF]"] +353 -> 354 [label="[1-9]"] +354 -> 355 +355 -> 356 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-/][:][<-0xFF]"] +355 -> 352 [label="[0x09-0x0A][0x0D][ ][;]"] +355 -> 354 [label="[0-9]"] +356 -> 357 +357 -> 356 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-:][<-0xFF]"] +357 -> 350 [label="[0x09-0x0A][0x0D][ ][;]"] +358 -> 359 +359 -> 358 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!][#-:][<-[][0x5D-0xFF]"] +359 -> 368 [label="[0x09][0x0D][ ][;]"] +359 -> 350 [label="[0x0A]"] +359 -> 356 [label="[\"]"] +359 -> 370 [label="[\\]"] +360 -> 361 +361 -> 360 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-&][(-:][<-[][0x5D-0xFF]"] +361 -> 362 [label="[0x09][0x0D][ ][;]"] +361 -> 350 [label="[0x0A]"] +361 -> 356 [label="[']"] +361 -> 365 [label="[\\]"] +362 -> 363 +363 -> 362 [label="[0x00-0x09][0x0B-&][(-[][0x5D-0xFF]"] +363 -> 364 [label="[0x0A]"] +363 -> 366 [label="[']"] +363 -> 367 [label="[\\]"] +364 -> 350 +365 -> 360 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-:][<-0xFF]"] +365 -> 362 [label="[0x09][0x0D][ ][;]"] +365 -> 350 [label="[0x0A]"] +366 -> 350 +367 -> 362 [label="[0x00-0x09][0x0B-0xFF]"] +367 -> 364 [label="[0x0A]"] +368 -> 369 +369 -> 368 [label="[0x00-0x09][0x0B-!][#-[][0x5D-0xFF]"] +369 -> 364 [label="[0x0A]"] +369 -> 366 [label="[\"]"] +369 -> 371 [label="[\\]"] +370 -> 358 [label="[0x00-0x08][0x0B-0x0C][0x0E-0x1F][!-:][<-0xFF]"] +370 -> 368 [label="[0x09][0x0D][ ][;]"] +370 -> 350 [label="[0x0A]"] +371 -> 368 [label="[0x00-0x09][0x0B-0xFF]"] +371 -> 364 [label="[0x0A]"] +} + +digraph re2c { + +373 -> 374 [label="[0x00-0x09][0x0B-!][#-0][:-0xFF]"] +373 -> 376 [label="[0x0A]"] +373 -> 378 [label="[\"]"] +373 -> 379 [label="[1-9]"] +374 -> 375 +375 [label="scanner_re2c_default.D.re:646"] +376 -> 377 +377 [label="scanner_re2c_default.D.re:634"] +378 -> 384 [label="[0x00-0x09][0x0B-0xFF]"] +378 -> 375 [label="[0x0A]"] +379 -> 382 +380 [label="scanner_re2c_default.D.re:624"] +381 -> 382 +382 -> 380 [label="[0x00-/][:-0xFF]"] +382 -> 381 [label="[0-9]"] +383 -> 384 +384 -> 383 [label="[0x00-0x09][0x0B-!][#-[][0x5D-0xFF]"] +384 -> 385 [label="[0x0A]"] +384 -> 387 [label="[\"]"] +384 -> 386 [label="[\\]"] +385 -> 375 +386 -> 383 [label="[0x00-0x09][0x0B-0xFF]"] +386 -> 385 [label="[0x0A]"] +387 -> 388 +388 [label="scanner_re2c_default.D.re:629"] +} diff --git a/re2c/test/scanner_re2c_default.D.re b/re2c/test/scanner_re2c_default.D.re new file mode 100644 index 00000000..ed8ffb65 --- /dev/null +++ b/re2c/test/scanner_re2c_default.D.re @@ -0,0 +1,652 @@ +/* $Id$ */ +#include +#include +#include +#include +#include "scanner.h" +#include "parser.h" +#include "y.tab.h" +#include "globals.h" +#include "dfa.h" + +extern YYSTYPE yylval; + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define YYCTYPE unsigned char +#define YYCURSOR cursor +#define YYLIMIT lim +#define YYMARKER ptr +#define YYCTXMARKER ctx +#define YYFILL(n) {cursor = fill(cursor, n);} + +#define RETURN(i) {cur = cursor; return i;} + +namespace re2c +{ + +/*!re2c +zero = "\000"; +dot = .; +esc = dot \ [\\]; +istring = "[" "^" ((esc \ [\]]) | "\\" dot)* "]" ; +cstring = "[" ((esc \ [\]]) | "\\" dot)* "]" ; +dstring = "\"" ((esc \ ["] ) | "\\" dot)* "\""; +sstring = "'" ((esc \ ['] ) | "\\" dot)* "'" ; +letter = [a-zA-Z]; +digit = [0-9]; +lineno = [1-9] digit*; +number = "0" | ("-"? [1-9] digit*); +name = (letter|"_") (letter|digit|"_")*; +cname = ":" name; +space = [ \t]; +ws = (space | [\r\n]); +eol = ("\r\n" | "\n"); +config = "re2c" cname+ ("@" name)?; +value = [^\r\n; \t]* | dstring | sstring; +lineinf = lineno (space+ dstring)? eol; +*/ + +Scanner::ParseMode Scanner::echo() +{ + char *cursor = cur; + bool ignore_eoc = false; + int ignore_cnt = 0; + + if (eof && cursor == eof) // Catch EOF + { + return Stop; + } + + tok = cursor; +echo: +/*!re2c + beginRE = "%{" | "/*!re2c"; + beginRE { + if (rFlag) + { + fatal("found standard 're2c' block while using -r flag"); + } + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + if (!DFlag) + { + out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok)); + } + tok = cursor; + RETURN(Parse); + } + "/*!rules:re2c" { + if (rFlag) + { + mapCodeName.clear(); + } + else + { + fatal("found 'rules:re2c' block without -r flag"); + } + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + tok = cursor; + RETURN(Rules); + } + "/*!use:re2c" { + if (!rFlag) + { + fatal("found 'use:re2c' block without -r flag"); + } + reuse(); + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + if (!DFlag) + { + out.write((const char*)(tok), (const char*)(&cursor[-11]) - (const char*)(tok)); + } + tok = cursor; + RETURN(Reuse); + } + "/*!max:re2c" { + if (bUsedYYMaxFill) + { + fatal("cannot generate YYMAXFILL twice"); + } + if (!DFlag) + { + out << "#define YYMAXFILL " << maxFill << std::endl; + } + tok = pos = cursor; + ignore_eoc = true; + bUsedYYMaxFill = true; + goto echo; + } + "/*!getstate:re2c" { + tok = pos = cursor; + genGetStateGoto(out, topIndent, 0); + ignore_eoc = true; + goto echo; + } + "/*!ignore:re2c" { + tok = pos = cursor; + ignore_eoc = true; + goto echo; + } + "/*!types:re2c" { + if (bSinglePass) + { + fatal("cannot generate types inline in single pass mode"); + } + tok = pos = cursor; + ignore_eoc = true; + if (bLastPass && !DFlag) + { + out << outputFileInfo; + out << "\n"; + out << typesInline; + out << "\n"; + out << sourceFileInfo; + } + goto echo; + } + "*" "/" "\r"? "\n" { + cline++; + if (ignore_eoc) + { + if (ignore_cnt) + { + out << sourceFileInfo; + } + ignore_eoc = false; + ignore_cnt = 0; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + goto echo; + } + "*" "/" { + if (ignore_eoc) + { + if (ignore_cnt) + { + out << "\n" << sourceFileInfo; + } + ignore_eoc = false; + ignore_cnt = 0; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + goto echo; + } + "\n" space* "#" space* "line" space+ / lineinf { + set_sourceline(cursor); + goto echo; + } + "\n" { + if (ignore_eoc) + { + ignore_cnt++; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + cline++; + goto echo; + } + zero { + if (!ignore_eoc && !DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok) - 1); + // -1 so we don't write out the \0 + } + if(cursor == eof) + { + RETURN(Stop); + } + } + * { + goto echo; + } +*/ +} + +int Scanner::scan() +{ + char *cursor = cur; + uint depth; + +scan: + tchar = cursor - pos; + tline = cline; + tok = cursor; + if (iscfg == 1) + { + goto config; + } + else if (iscfg == 2) + { + goto value; + } +/*!re2c + "{" { + depth = 1; + goto code; + } + + ":" / "=>" { + RETURN(*tok); + } + + ":=" { + cur = cursor; + tok += 2; /* skip ":=" */ + depth = 0; + goto code; + } + + "//" { + goto nextLine; + } + "/*" { + depth = 1; + goto comment; + } + + endRE = "%}" | "*/"; + endRE { + tok = cursor; + RETURN(0); + } + + dstring { + cur = cursor; + if (bCaseInsensitive || bCaseInverted) + { + yylval.regexp = strToCaseInsensitiveRE(token()); + } + else + { + yylval.regexp = strToRE(token()); + } + return STRING; + } + + sstring { + cur = cursor; + if (bCaseInverted) + { + yylval.regexp = strToRE(token()); + } + else + { + yylval.regexp = strToCaseInsensitiveRE(token()); + } + return STRING; + } + + "\"" { + fatal("unterminated string constant (missing \")"); + } + "'" { + fatal("unterminated string constant (missing ')"); + } + + istring { + cur = cursor; + yylval.regexp = invToRE(token()); + return RANGE; + } + + cstring { + cur = cursor; + yylval.regexp = ranToRE(token()); + return RANGE; + } + + "[" { + fatal("unterminated range (missing ])"); + } + + "<>" / (space* ("{" | "=>" | ":=")) { + RETURN(NOCOND); + } + ",()|=;/\\] { + RETURN(*tok); + } + + "*" { + yylval.op = *tok; + RETURN(STAR); + } + [+?] { + yylval.op = *tok; + RETURN(CLOSE); + } + + "{0,}" { + yylval.op = '*'; + RETURN(CLOSE); + } + + "{" [0-9]+ "}" { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = atoi((char *)tok+1); + RETURN(CLOSESIZE); + } + + "{" [0-9]+ "," [0-9]+ "}" { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1)); + RETURN(CLOSESIZE); + } + + "{" [0-9]+ ",}" { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = -1; + RETURN(CLOSESIZE); + } + + "{" [0-9]* "," { + fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); + } + + "{" name "}" { + if (!FFlag) { + fatal("curly braces for names only allowed with -F switch"); + } + cur = cursor; + yylval.symbol = Symbol::find(token(1, cur - tok - 2)); + return ID; + } + + config { + cur = cursor; + tok += 5; /* skip "re2c:" */ + iscfg = 1; + yylval.str = new Str(token()); + return CONFIG; + } + + name / (space+ [^=>,]) { + cur = ptr > tok ? ptr - 1 : cursor; + yylval.symbol = Symbol::find(token()); + return FFlag ? FID : ID; + } + + name / (space* [=>,]) { + cur = ptr > tok ? ptr - 1 : cursor; + yylval.symbol = Symbol::find(token()); + return ID; + } + + name / [^] { + if (!FFlag) { + cur = cursor; + yylval.symbol = Symbol::find(token()); + return ID; + } else { + /* Add one char in front and one behind instead of 's or "s */ + cur = cursor; + if (bCaseInsensitive || bCaseInverted) + { + yylval.regexp = strToCaseInsensitiveRE(raw_token("\"")); + } + else + { + yylval.regexp = strToRE(raw_token("\"")); + } + return STRING; + } + } + + "." { + cur = cursor; + yylval.regexp = mkDot(); + return RANGE; + } + + space+ { + goto scan; + } + + eol space* "#" space* "line" space+ / lineinf { + set_sourceline(cursor); + goto scan; + } + + eol { + if (cursor == eof) RETURN(0); + pos = cursor; + cline++; + goto scan; + } + + * { + std::ostringstream msg; + msg << "unexpected character: "; + prtChOrHex(msg, *tok); + fatal(msg.str().c_str()); + goto scan; + } +*/ + +code: +/*!re2c + "}" { + if (depth == 0) + { + fatal("Curly braces are not allowed after ':='"); + } + else if (--depth == 0) + { + cur = cursor; + yylval.token = new Token(token(), sourceFileInfo.fname, tline); + return CODE; + } + goto code; + } + "{" { + if (depth == 0) + { + fatal("Curly braces are not allowed after ':='"); + } + else + { + ++depth; + } + goto code; + } + "\n" space* "#" space* "line" space+ / lineinf { + set_sourceline(cursor); + goto code; + } + "\n" / ws { + if (depth == 0) + { + goto code; + } + else if (cursor == eof) + { + fatal("missing '}'"); + } + pos = cursor; + cline++; + goto code; + } + "\n" { + if (depth == 0) + { + cur = cursor; + tok += strspn(tok, " \t\r\n"); + while (cur > tok && strchr(" \t\r\n", cur[-1])) + { + --cur; + } + yylval.token = new Token(token(), sourceFileInfo.fname, tline); + return CODE; + } + else if (cursor == eof) + { + fatal("missing '}'"); + } + pos = cursor; + cline++; + goto code; + } + zero { + if (cursor == eof) + { + if (depth) + { + fatal("missing '}'"); + } + RETURN(0); + } + goto code; + } + dstring | sstring { + goto code; + } + * { + goto code; + } +*/ + +comment: +/*!re2c + "*/" { + if (--depth == 0) + { + goto scan; + } + else + { + goto comment; + } + } + "/*" { + ++depth; + fatal("ambiguous /* found"); + goto comment; + } + "\n" space* "#" space* "line" space+ / lineinf { + set_sourceline(cursor); + goto comment; + } + "\n" { + if (cursor == eof) + { + RETURN(0); + } + tok = pos = cursor; + cline++; + goto comment; + } + * { + if (cursor == eof) + { + RETURN(0); + } + goto comment; + } +*/ + +nextLine: +/*!re2c /* resync emacs */ + "\n" { if(cursor == eof) { + RETURN(0); + } + tok = pos = cursor; + cline++; + goto scan; + } + * { if(cursor == eof) { + RETURN(0); + } + goto nextLine; + } +*/ + +config: +/*!re2c + space+ { + goto config; + } + "=" space* { + iscfg = 2; + cur = cursor; + RETURN('='); + } + * { + fatal("missing '='"); + } +*/ + +value: +/*!re2c + number { + cur = cursor; + yylval.number = atoi(token().to_string().c_str()); + iscfg = 0; + return NUMBER; + } + value { + cur = cursor; + yylval.str = new Str(token()); + iscfg = 0; + return VALUE; + } +*/ +} + +void Scanner::set_sourceline(char *& cursor) +{ +sourceline: + tok = cursor; +/*!re2c + lineno { + cur = cursor; + cline = atoi(token().to_string().c_str()); + goto sourceline; + } + dstring { + cur = cursor; + sourceFileInfo.set_fname(token(1, cur - tok - 2).to_string()); + goto sourceline; + } + "\n" { + if (cursor == eof) + { + --cursor; + } + else + { + pos = cursor; + } + tok = cursor; + return; + } + * { + goto sourceline; + } +*/ +} + +} // end namespace re2c -- 2.40.0