This commit is contained in:
vadim 2017-11-16 19:58:46 +02:00
parent abf8af04f8
commit 7ab895a8a0
2 changed files with 277 additions and 138 deletions

View File

@ -38,6 +38,7 @@ const (
STRING_VAR_NAME STRING_VAR_NAME
PROPERTY PROPERTY
HEREDOC_END HEREDOC_END
NOWDOC
) )
type lexer struct { type lexer struct {
@ -155,6 +156,8 @@ yystate0:
goto yystart506 goto yystart506
case 7: // start condition: HEREDOC_END case 7: // start condition: HEREDOC_END
goto yystart514 goto yystart514
case 8: // start condition: NOWDOC
goto yystart519
} }
goto yystate0 // silence unused label error goto yystate0 // silence unused label error
@ -443,6 +446,10 @@ yyAction:
goto yyrule140 goto yyrule140
case 141: case 141:
goto yyrule141 goto yyrule141
case 142:
goto yyrule142
case 143:
goto yyrule143
} }
goto yystate1 // silence unused label error goto yystate1 // silence unused label error
yystate1: yystate1:
@ -646,9 +653,9 @@ yystart11:
yystate12: yystate12:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
goto yyrule141 goto yyrule143
yystate13: yystate13:
c = l.Next() c = l.Next()
@ -702,17 +709,17 @@ yystate17:
yystate18: yystate18:
c = l.Next() c = l.Next()
yyrule = 121 yyrule = 123
l.Mark() l.Mark()
goto yyrule121 goto yyrule123
yystate19: yystate19:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == '\n': case c == '\n':
goto yystate20 goto yystate20
case c == '\r': case c == '\r':
@ -802,11 +809,11 @@ yystate28:
yystate29: yystate29:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == '\'': case c == '\'':
goto yystate31 goto yystate31
case c == '\\': case c == '\\':
@ -1986,11 +1993,11 @@ yystate151:
yystate152: yystate152:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == '_': case c == '_':
goto yystate153 goto yystate153
} }
@ -2527,11 +2534,11 @@ yystate212:
yystate213: yystate213:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'b': case c == 'b':
goto yystate214 goto yystate214
case c == 'n': case c == 'n':
@ -2658,11 +2665,11 @@ yystate227:
yystate228: yystate228:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == '"': case c == '"':
goto yystate229 goto yystate229
case c == '<': case c == '<':
@ -2673,9 +2680,9 @@ yystate228:
yystate229: yystate229:
c = l.Next() c = l.Next()
yyrule = 121 yyrule = 123
l.Mark() l.Mark()
goto yyrule121 goto yyrule123
yystate230: yystate230:
c = l.Next() c = l.Next()
@ -2730,11 +2737,11 @@ yystate235:
yystate236: yystate236:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'a': case c == 'a':
goto yystate237 goto yystate237
case c == 'f': case c == 'f':
@ -3055,11 +3062,11 @@ yystate272:
yystate273: yystate273:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'e': case c == 'e':
goto yystate274 goto yystate274
case c == 'i': case c == 'i':
@ -3186,11 +3193,11 @@ yystate287:
yystate288: yystate288:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'c': case c == 'c':
goto yystate289 goto yystate289
case c == 'l': case c == 'l':
@ -3562,11 +3569,11 @@ yystate329:
yystate330: yystate330:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'i': case c == 'i':
goto yystate331 goto yystate331
case c == 'o': case c == 'o':
@ -3683,11 +3690,11 @@ yystate342:
yystate343: yystate343:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'l': case c == 'l':
goto yystate344 goto yystate344
case c == 'o': case c == 'o':
@ -3762,11 +3769,11 @@ yystate351:
yystate352: yystate352:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'f': case c == 'f':
goto yystate353 goto yystate353
case c == 'm': case c == 'm':
@ -4045,11 +4052,11 @@ yystate383:
yystate384: yystate384:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'a': case c == 'a':
goto yystate385 goto yystate385
case c == 'e': case c == 'e':
@ -4142,11 +4149,11 @@ yystate394:
yystate395: yystate395:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'r': case c == 'r':
goto yystate396 goto yystate396
} }
@ -4159,11 +4166,11 @@ yystate396:
yystate397: yystate397:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'r': case c == 'r':
goto yystate398 goto yystate398
case c == 'u': case c == 'u':
@ -4327,11 +4334,11 @@ yystate415:
yystate416: yystate416:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'e': case c == 'e':
goto yystate417 goto yystate417
} }
@ -4380,11 +4387,11 @@ yystate421:
yystate422: yystate422:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 't': case c == 't':
goto yystate423 goto yystate423
case c == 'w': case c == 'w':
@ -4477,11 +4484,11 @@ yystate432:
yystate433: yystate433:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'h': case c == 'h':
goto yystate434 goto yystate434
case c == 'r': case c == 'r':
@ -4564,11 +4571,11 @@ yystate442:
yystate443: yystate443:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 's': case c == 's':
goto yystate444 goto yystate444
} }
@ -4590,11 +4597,11 @@ yystate445:
yystate446: yystate446:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'a': case c == 'a':
goto yystate447 goto yystate447
} }
@ -4616,11 +4623,11 @@ yystate448:
yystate449: yystate449:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'h': case c == 'h':
goto yystate450 goto yystate450
} }
@ -4660,11 +4667,11 @@ yystate453:
yystate454: yystate454:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'o': case c == 'o':
goto yystate455 goto yystate455
} }
@ -4686,11 +4693,11 @@ yystate456:
yystate457: yystate457:
c = l.Next() c = l.Next()
yyrule = 141 yyrule = 143
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule141 goto yyrule143
case c == 'i': case c == 'i':
goto yystate458 goto yystate458
} }
@ -4836,49 +4843,49 @@ yystart472:
yystate473: yystate473:
c = l.Next() c = l.Next()
yyrule = 126 yyrule = 128
l.Mark() l.Mark()
goto yyrule126 goto yyrule128
yystate474: yystate474:
c = l.Next() c = l.Next()
yyrule = 122 yyrule = 124
l.Mark() l.Mark()
goto yyrule122 goto yyrule124
yystate475: yystate475:
c = l.Next() c = l.Next()
yyrule = 125 yyrule = 127
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule125 goto yyrule127
case c == '{': case c == '{':
goto yystate476 goto yystate476
} }
yystate476: yystate476:
c = l.Next() c = l.Next()
yyrule = 124 yyrule = 126
l.Mark() l.Mark()
goto yyrule124 goto yyrule126
yystate477: yystate477:
c = l.Next() c = l.Next()
yyrule = 126 yyrule = 128
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule126 goto yyrule128
case c == '$': case c == '$':
goto yystate478 goto yystate478
} }
yystate478: yystate478:
c = l.Next() c = l.Next()
yyrule = 123 yyrule = 125
l.Mark() l.Mark()
goto yyrule123 goto yyrule125
goto yystate479 // silence unused label error goto yystate479 // silence unused label error
yystate479: yystate479:
@ -4901,39 +4908,39 @@ yystart479:
yystate480: yystate480:
c = l.Next() c = l.Next()
yyrule = 131 yyrule = 133
l.Mark() l.Mark()
goto yyrule131 goto yyrule133
yystate481: yystate481:
c = l.Next() c = l.Next()
yyrule = 131 yyrule = 133
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule131 goto yyrule133
case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate482 goto yystate482
} }
yystate482: yystate482:
c = l.Next() c = l.Next()
yyrule = 127 yyrule = 129
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule127 goto yyrule129
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate482 goto yystate482
} }
yystate483: yystate483:
c = l.Next() c = l.Next()
yyrule = 131 yyrule = 133
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule131 goto yyrule133
case c == '>': case c == '>':
goto yystate484 goto yystate484
} }
@ -4949,42 +4956,42 @@ yystate484:
yystate485: yystate485:
c = l.Next() c = l.Next()
yyrule = 128 yyrule = 130
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule128 goto yyrule130
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate485 goto yystate485
} }
yystate486: yystate486:
c = l.Next() c = l.Next()
yyrule = 129 yyrule = 131
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule129 goto yyrule131
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate487 goto yystate487
} }
yystate487: yystate487:
c = l.Next() c = l.Next()
yyrule = 129 yyrule = 131
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule129 goto yyrule131
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate487 goto yystate487
} }
yystate488: yystate488:
c = l.Next() c = l.Next()
yyrule = 130 yyrule = 132
l.Mark() l.Mark()
goto yyrule130 goto yyrule132
goto yystate489 // silence unused label error goto yystate489 // silence unused label error
yystate489: yystate489:
@ -5012,100 +5019,100 @@ yystart489:
} }
yystate490: yystate490:
c = l.Next()
yyrule = 140
l.Mark()
goto yyrule140
yystate491:
c = l.Next() c = l.Next()
yyrule = 138 yyrule = 138
l.Mark() l.Mark()
goto yyrule138 goto yyrule138
yystate491:
c = l.Next()
yyrule = 136
l.Mark()
goto yyrule136
yystate492: yystate492:
c = l.Next() c = l.Next()
yyrule = 136 yyrule = 138
l.Mark() l.Mark()
goto yyrule136 goto yyrule138
yystate493: yystate493:
c = l.Next() c = l.Next()
yyrule = 137 yyrule = 139
l.Mark() l.Mark()
goto yyrule137 goto yyrule139
yystate494: yystate494:
c = l.Next() c = l.Next()
yyrule = 137 yyrule = 139
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule137 goto yyrule139
case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate495 goto yystate495
} }
yystate495: yystate495:
c = l.Next() c = l.Next()
yyrule = 133 yyrule = 135
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule133 goto yyrule135
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate495 goto yystate495
} }
yystate496: yystate496:
c = l.Next() c = l.Next()
yyrule = 132 yyrule = 134
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule132 goto yyrule134
case c >= '0' && c <= '9': case c >= '0' && c <= '9':
goto yystate497 goto yystate497
} }
yystate497: yystate497:
c = l.Next() c = l.Next()
yyrule = 132 yyrule = 134
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule132 goto yyrule134
case c >= '0' && c <= '9': case c >= '0' && c <= '9':
goto yystate497 goto yystate497
} }
yystate498: yystate498:
c = l.Next() c = l.Next()
yyrule = 134 yyrule = 136
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule134 goto yyrule136
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate499 goto yystate499
} }
yystate499: yystate499:
c = l.Next() c = l.Next()
yyrule = 134 yyrule = 136
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule134 goto yyrule136
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate499 goto yystate499
} }
yystate500: yystate500:
c = l.Next() c = l.Next()
yyrule = 135 yyrule = 137
l.Mark() l.Mark()
goto yyrule135 goto yyrule137
goto yystate501 // silence unused label error goto yystate501 // silence unused label error
yystate501: yystate501:
@ -5122,17 +5129,17 @@ yystart501:
yystate502: yystate502:
c = l.Next() c = l.Next()
yyrule = 140 yyrule = 142
l.Mark() l.Mark()
goto yyrule140 goto yyrule142
yystate503: yystate503:
c = l.Next() c = l.Next()
yyrule = 140 yyrule = 142
l.Mark() l.Mark()
switch { switch {
default: default:
goto yyrule140 goto yyrule142
case c == '[' || c == '}': case c == '[' || c == '}':
goto yystate505 goto yystate505
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
@ -5152,9 +5159,9 @@ yystate504:
yystate505: yystate505:
c = l.Next() c = l.Next()
yyrule = 139 yyrule = 141
l.Mark() l.Mark()
goto yyrule139 goto yyrule141
goto yystate506 // silence unused label error goto yystate506 // silence unused label error
yystate506: yystate506:
@ -5250,21 +5257,59 @@ yystart514:
default: default:
goto yyabort goto yyabort
case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate516
case c >= '\x01' && c <= '\t' || c >= '\v' && c <= '@' || c >= '[' && c <= '^' || c == '`' || c >= '{' && c <= '~':
goto yystate515 goto yystate515
} }
yystate515: yystate515:
c = l.Next()
yyrule = 122
l.Mark()
goto yyrule122
yystate516:
c = l.Next()
yyrule = 122
l.Mark()
switch {
default:
goto yyrule122
case c == ';':
goto yystate518
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate517
}
yystate517:
c = l.Next() c = l.Next()
switch { switch {
default: default:
goto yyabort goto yyabort
case c == ';': case c == ';':
goto yystate516 goto yystate518
case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ': case c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c >= '\u007f' && c <= 'ÿ':
goto yystate515 goto yystate517
} }
yystate516: yystate518:
c = l.Next()
yyrule = 121
l.Mark()
goto yyrule121
goto yystate519 // silence unused label error
yystate519:
c = l.Next()
yystart519:
switch {
default:
goto yyabort
case c >= '\x01' && c <= '\t' || c >= '\v' && c <= 'ÿ':
goto yystate520
}
yystate520:
c = l.Next() c = l.Next()
yyrule = 120 yyrule = 120
l.Mark() l.Mark()
@ -5888,8 +5933,7 @@ yyrule119: // [b]?\<\<\<[ \t]*({VAR_NAME}|([']{VAR_NAME}['])|(["]{VAR_NAME}["]))
case '\'': case '\'':
lblFirst++ lblFirst++
lblLast-- lblLast--
fmt.Println("NOWDOC") begin(NOWDOC)
//begin(NOWDOC)
case '"': case '"':
lblFirst++ lblFirst++
lblLast-- lblLast--
@ -5920,13 +5964,81 @@ yyrule119: // [b]?\<\<\<[ \t]*({VAR_NAME}|([']{VAR_NAME}['])|(["]{VAR_NAME}["]))
fmt.Printf("T_START_HEREDOC: %q\n", tb) fmt.Printf("T_START_HEREDOC: %q\n", tb)
goto yystate0 goto yystate0
} }
yyrule120: // {VAR_NAME}\; yyrule120: // .
{
searchLabel := []byte{}
tb := []byte{}
ND_FOR:
for {
if c == -1 {
break
}
if '\n' == rune(c) || '\r' == rune(c) {
if bytes.Equal(append(heredocLabel, ';'), searchLabel) {
begin(HEREDOC_END)
tb = l.ungetN(len(heredocLabel) + 1)
break ND_FOR
}
searchLabel = []byte{}
} else {
searchLabel = append(searchLabel, byte(rune(c)))
}
// fmt.Printf("current: %q\n", rune(c));
// ND_SWITCH:switch c {
// case '\r':
// c = l.Next()
// if rune(c) != '\n' {
// l.ungetN(0)
// }
// fallthrough
// case '\n':
// c = l.Next()
// ungetCnt := len(heredocLabel)
// searchLabelAhead := []byte{}
// for i := 0; i <= len(heredocLabel); i++ {
// if c == -1 {
// break ND_FOR;
// }
// if '\n' == rune(c) || '\r' == rune(c) {
// break ND_SWITCH;
// }
// searchLabelAhead = append(searchLabelAhead, byte(rune(c)))
// c = l.Next()
// }
// fmt.Printf("searchLabelAhead: %q %q\n", searchLabelAhead, heredocLabel);
// if bytes.Equal(heredocLabel, searchLabelAhead) && ';' == rune(c) {
// ungetCnt++
// c = l.Next()
// if c == -1 {
// break ND_FOR;
// }
// if '\n' == rune(c) || '\r' == rune(c) {
// begin(HEREDOC_END)
// l.ungetN(ungetCnt)
// break ND_FOR;
// }
// }
// }
c = l.Next()
}
fmt.Printf("T_ENCAPSED_AND_WHITESPACE: %q\n", tb)
goto yystate0
}
yyrule121: // {VAR_NAME}\;
{ {
fmt.Printf("T_END_HEREDOC: %q\n", l.ungetN(1)) fmt.Printf("T_END_HEREDOC: %q\n", l.ungetN(1))
begin(PHP) begin(PHP)
goto yystate0 goto yystate0
} }
yyrule121: // [b]?[\"] yyrule122: // .
{
fmt.Printf("ERROR HEREDOC: %q\n", l.ungetN(1))
goto yystate0
}
yyrule123: // [b]?[\"]
{ {
binPrefix := l.TokenBytes(nil)[0] == 'b' binPrefix := l.TokenBytes(nil)[0] == 'b'
@ -5974,31 +6086,31 @@ yyrule121: // [b]?[\"]
} }
goto yystate0 goto yystate0
} }
yyrule122: // \" yyrule124: // \"
{ {
fmt.Println("\"") fmt.Println("\"")
popState() popState()
goto yystate0 goto yystate0
} }
yyrule123: // \{\$ yyrule125: // \{\$
{ {
fmt.Printf("T_CURLY_OPEN: %q\n", l.ungetN(1)) fmt.Printf("T_CURLY_OPEN: %q\n", l.ungetN(1))
pushState(PHP) pushState(PHP)
goto yystate0 goto yystate0
} }
yyrule124: // \$\{ yyrule126: // \$\{
{ {
fmt.Printf("T_DOLLAR_OPEN_CURLY_BRACES: %q\n", l.TokenBytes(nil)) fmt.Printf("T_DOLLAR_OPEN_CURLY_BRACES: %q\n", l.TokenBytes(nil))
pushState(STRING_VAR_NAME) pushState(STRING_VAR_NAME)
goto yystate0 goto yystate0
} }
yyrule125: // \$ yyrule127: // \$
{ {
l.ungetN(1) l.ungetN(1)
begin(STRING_VAR) begin(STRING_VAR)
goto yystate0 goto yystate0
} }
yyrule126: // . yyrule128: // .
{ {
F1: F1:
@ -6037,86 +6149,86 @@ yyrule126: // .
} }
goto yystate0 goto yystate0
} }
yyrule127: // \${VAR_NAME} yyrule129: // \${VAR_NAME}
{ {
fmt.Printf("T_VARIABLE: %q\n", l.TokenBytes(nil)) fmt.Printf("T_VARIABLE: %q\n", l.TokenBytes(nil))
goto yystate0 goto yystate0
} }
yyrule128: // ->{VAR_NAME} yyrule130: // ->{VAR_NAME}
{ {
fmt.Printf("T_OBJECT_OPERATOR: %q\n", l.ungetN(len(l.TokenBytes(nil))-2)) fmt.Printf("T_OBJECT_OPERATOR: %q\n", l.ungetN(len(l.TokenBytes(nil))-2))
goto yystate0 goto yystate0
} }
yyrule129: // {VAR_NAME} yyrule131: // {VAR_NAME}
{ {
fmt.Printf("T_STRING: %q\n", l.TokenBytes(nil)) fmt.Printf("T_STRING: %q\n", l.TokenBytes(nil))
begin(STRING) begin(STRING)
goto yystate0 goto yystate0
} }
yyrule130: // \[ yyrule132: // \[
{ {
fmt.Println("[") fmt.Println("[")
begin(STRING_VAR_INDEX) begin(STRING_VAR_INDEX)
goto yystate0 goto yystate0
} }
yyrule131: // . yyrule133: // .
{ {
l.ungetN(1) l.ungetN(1)
begin(STRING) begin(STRING)
goto yystate0 goto yystate0
} }
yyrule132: // {LNUM} yyrule134: // {LNUM}
{ {
fmt.Printf("T_NUM_STRING: %q\n", l.TokenBytes(nil)) fmt.Printf("T_NUM_STRING: %q\n", l.TokenBytes(nil))
goto yystate0 goto yystate0
} }
yyrule133: // \${VAR_NAME} yyrule135: // \${VAR_NAME}
{ {
fmt.Printf("T_VARIABLE: %q\n", l.TokenBytes(nil)) fmt.Printf("T_VARIABLE: %q\n", l.TokenBytes(nil))
goto yystate0 goto yystate0
} }
yyrule134: // {VAR_NAME} yyrule136: // {VAR_NAME}
{ {
fmt.Printf("T_STRING: %q\n", l.TokenBytes(nil)) fmt.Printf("T_STRING: %q\n", l.TokenBytes(nil))
goto yystate0 goto yystate0
} }
yyrule135: // \] yyrule137: // \]
{ {
fmt.Println("\"]\"") fmt.Println("\"]\"")
begin(STRING) begin(STRING)
goto yystate0 goto yystate0
} }
yyrule136: // [ \n\r\t\\'#] yyrule138: // [ \n\r\t\\'#]
{ {
fmt.Printf("T_ENCAPSED_AND_WHITESPACE: %q\n", l.ungetN(1)) fmt.Printf("T_ENCAPSED_AND_WHITESPACE: %q\n", l.ungetN(1))
begin(STRING) begin(STRING)
goto yystate0 goto yystate0
} }
yyrule137: // {OPERATORS} yyrule139: // {OPERATORS}
{ {
fmt.Printf("%q\n", l.TokenBytes(nil)) fmt.Printf("%q\n", l.TokenBytes(nil))
goto yystate0 goto yystate0
} }
yyrule138: // . yyrule140: // .
{ {
fmt.Printf("%q\n", l.TokenBytes(nil)) fmt.Printf("%q\n", l.TokenBytes(nil))
goto yystate0 goto yystate0
} }
yyrule139: // {VAR_NAME}[\[\}] yyrule141: // {VAR_NAME}[\[\}]
{ {
fmt.Printf("T_STRING_VARNAME: %q\n", l.ungetN(1)) fmt.Printf("T_STRING_VARNAME: %q\n", l.ungetN(1))
popState() popState()
pushState(PHP) pushState(PHP)
goto yystate0 goto yystate0
} }
yyrule140: // . yyrule142: // .
{ {
l.ungetN(1) l.ungetN(1)
popState() popState()
pushState(PHP) pushState(PHP)
goto yystate0 goto yystate0
} }
yyrule141: // . yyrule143: // .
{ {
fmt.Printf("other: %q\n", l.TokenBytes(nil)) fmt.Printf("other: %q\n", l.TokenBytes(nil))
goto yystate0 goto yystate0

View File

@ -37,6 +37,7 @@ const (
STRING_VAR_NAME STRING_VAR_NAME
PROPERTY PROPERTY
HEREDOC_END HEREDOC_END
NOWDOC
) )
@ -130,7 +131,7 @@ func (l *lexer) Lex() int { // Lex(lval *yySymType)
%} %}
%s PHP STRING STRING_VAR STRING_VAR_INDEX STRING_VAR_NAME PROPERTY HEREDOC_END %s PHP STRING STRING_VAR STRING_VAR_INDEX STRING_VAR_NAME PROPERTY HEREDOC_END NOWDOC
%yyb last == '\n' || last = '\0' %yyb last == '\n' || last = '\0'
%yyt sc %yyt sc
@ -301,8 +302,7 @@ NEW_LINE (\r|\n|\r\n)
case '\'' : case '\'' :
lblFirst++ lblFirst++
lblLast-- lblLast--
fmt.Println("NOWDOC"); begin(NOWDOC)
//begin(NOWDOC)
case '"' : case '"' :
lblFirst++ lblFirst++
lblLast-- lblLast--
@ -336,7 +336,34 @@ NEW_LINE (\r|\n|\r\n)
fmt.Printf("T_START_HEREDOC: %q\n", tb); fmt.Printf("T_START_HEREDOC: %q\n", tb);
<NOWDOC>.
searchLabel := []byte{}
tb := []byte{}
for {
if c == -1 {
break;
}
if '\n' == rune(c) || '\r' == rune(c) {
if bytes.Equal(append(heredocLabel, ';'), searchLabel) {
begin(HEREDOC_END)
tb = l.ungetN(len(heredocLabel)+1)
break;
}
searchLabel = []byte{}
} else {
searchLabel = append(searchLabel, byte(rune(c)))
}
c = l.Next()
}
fmt.Printf("T_ENCAPSED_AND_WHITESPACE: %q\n", tb);
<HEREDOC_END>{VAR_NAME}\; fmt.Printf("T_END_HEREDOC: %q\n", l.ungetN(1));begin(PHP) <HEREDOC_END>{VAR_NAME}\; fmt.Printf("T_END_HEREDOC: %q\n", l.ungetN(1));begin(PHP)
<HEREDOC_END>. fmt.Printf("ERROR HEREDOC: %q\n", l.ungetN(1));
<PHP>[b]?[\"] <PHP>[b]?[\"]
binPrefix := l.TokenBytes(nil)[0] == 'b' binPrefix := l.TokenBytes(nil)[0] == 'b'