1
0
mirror of https://github.com/danog/liquid.git synced 2024-11-27 01:24:40 +01:00

Property names can end in ?

This commit is contained in:
Oliver Steele 2017-07-11 11:37:20 -04:00
parent 8efaada3af
commit dbba68082c
2 changed files with 141 additions and 157 deletions

View File

@ -5,24 +5,24 @@ import "strconv"
//line scanner.go:9
var _expression_actions []byte = []byte{
0, 1, 0, 1, 1, 1, 2, 1, 13,
1, 14, 1, 15, 1, 16, 1, 17,
1, 18, 1, 19, 1, 20, 1, 21,
1, 22, 1, 23, 1, 24, 1, 25,
1, 26, 1, 27, 1, 28, 1, 29,
2, 2, 3, 2, 2, 4, 2, 2,
5, 2, 2, 6, 2, 2, 7, 2,
2, 8, 2, 2, 9, 2, 2, 10,
2, 2, 11, 2, 2, 12,
0, 1, 0, 1, 1, 1, 2, 1, 11,
1, 12, 1, 13, 1, 14, 1, 15,
1, 16, 1, 17, 1, 18, 1, 19,
1, 20, 1, 21, 1, 22, 1, 23,
1, 24, 1, 25, 1, 26, 1, 27,
1, 28, 2, 2, 3, 2, 2, 4,
2, 2, 5, 2, 2, 6, 2, 2,
7, 2, 2, 8, 2, 2, 9, 2,
2, 10,
}
var _expression_key_offsets []int16 = []int16{
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 12, 38, 41, 42, 43,
45, 46, 49, 51, 54, 62, 70, 71,
72, 73, 83, 84, 95, 106, 117, 128,
139, 150, 161, 172, 183, 195, 206, 217,
228, 239, 250, 261, 272, 283, 294,
45, 46, 49, 51, 54, 62, 71, 80,
81, 82, 83, 93, 94, 105, 116, 127,
138, 149, 160, 171, 182, 193, 205, 216,
227, 238, 249, 260, 271, 282, 293, 304,
}
var _expression_trans_keys []byte = []byte{
@ -33,65 +33,66 @@ var _expression_trans_keys []byte = []byte{
48, 57, 65, 90, 98, 122, 32, 9,
13, 61, 34, 97, 108, 39, 46, 48,
57, 48, 57, 46, 48, 57, 45, 95,
48, 57, 65, 90, 97, 122, 45, 95,
48, 57, 65, 90, 97, 122, 61, 61,
61, 45, 58, 63, 95, 48, 57, 65,
90, 97, 122, 58, 45, 58, 63, 95,
110, 48, 57, 65, 90, 97, 122, 45,
58, 63, 95, 100, 48, 57, 65, 90,
97, 122, 45, 58, 63, 95, 111, 48,
57, 65, 90, 97, 122, 45, 58, 63,
95, 110, 48, 57, 65, 90, 97, 122,
45, 58, 63, 95, 116, 48, 57, 65,
90, 97, 122, 45, 58, 63, 95, 97,
48, 57, 65, 90, 98, 122, 45, 58,
63, 95, 105, 48, 57, 65, 90, 97,
122, 45, 58, 63, 95, 110, 48, 57,
48, 57, 65, 90, 97, 122, 45, 63,
95, 48, 57, 65, 90, 97, 122, 45,
63, 95, 48, 57, 65, 90, 97, 122,
61, 61, 61, 45, 58, 63, 95, 48,
57, 65, 90, 97, 122, 58, 45, 58,
63, 95, 110, 48, 57, 65, 90, 97,
122, 45, 58, 63, 95, 100, 48, 57,
65, 90, 97, 122, 45, 58, 63, 95,
115, 48, 57, 65, 90, 97, 122, 45,
58, 63, 95, 97, 111, 48, 57, 65,
90, 98, 122, 45, 58, 63, 95, 108,
111, 48, 57, 65, 90, 97, 122, 45,
58, 63, 95, 110, 48, 57, 65, 90,
97, 122, 45, 58, 63, 95, 116, 48,
57, 65, 90, 97, 122, 45, 58, 63,
95, 97, 48, 57, 65, 90, 98, 122,
45, 58, 63, 95, 105, 48, 57, 65,
90, 97, 122, 45, 58, 63, 95, 110,
48, 57, 65, 90, 97, 122, 45, 58,
63, 95, 115, 48, 57, 65, 90, 97,
122, 45, 58, 63, 95, 101, 48, 57,
65, 90, 97, 122, 45, 58, 63, 95,
114, 48, 57, 65, 90, 97, 122, 45,
58, 63, 95, 110, 48, 57, 65, 90,
97, 122, 45, 58, 63, 95, 105, 48,
57, 65, 90, 97, 122, 45, 58, 63,
122, 45, 58, 63, 95, 97, 111, 48,
57, 65, 90, 98, 122, 45, 58, 63,
95, 108, 48, 57, 65, 90, 97, 122,
45, 58, 63, 95, 114, 48, 57, 65,
90, 97, 122, 45, 58, 63, 95, 114,
45, 58, 63, 95, 115, 48, 57, 65,
90, 97, 122, 45, 58, 63, 95, 101,
48, 57, 65, 90, 97, 122, 45, 58,
63, 95, 117, 48, 57, 65, 90, 97,
122,
63, 95, 114, 48, 57, 65, 90, 97,
122, 45, 58, 63, 95, 110, 48, 57,
65, 90, 97, 122, 45, 58, 63, 95,
105, 48, 57, 65, 90, 97, 122, 45,
58, 63, 95, 108, 48, 57, 65, 90,
97, 122, 45, 58, 63, 95, 114, 48,
57, 65, 90, 97, 122, 45, 58, 63,
95, 114, 48, 57, 65, 90, 97, 122,
45, 58, 63, 95, 117, 48, 57, 65,
90, 97, 122,
}
var _expression_single_lengths []byte = []byte{
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 0, 18, 1, 1, 1, 2,
1, 1, 0, 1, 2, 2, 1, 1,
1, 4, 1, 5, 5, 5, 5, 5,
5, 5, 5, 5, 6, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5,
1, 1, 0, 1, 2, 3, 3, 1,
1, 1, 4, 1, 5, 5, 5, 5,
5, 5, 5, 5, 5, 6, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
}
var _expression_range_lengths []byte = []byte{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 4, 1, 0, 0, 0,
0, 1, 1, 1, 3, 3, 0, 0,
0, 3, 0, 3, 3, 3, 3, 3,
0, 1, 1, 1, 3, 3, 3, 0,
0, 0, 3, 0, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3,
}
var _expression_index_offsets []int16 = []int16{
0, 2, 4, 6, 8, 10, 12, 14,
16, 18, 20, 22, 45, 48, 50, 52,
55, 57, 60, 62, 65, 71, 77, 79,
81, 83, 91, 93, 102, 111, 120, 129,
138, 147, 156, 165, 174, 184, 193, 202,
211, 220, 229, 238, 247, 256, 265,
55, 57, 60, 62, 65, 71, 78, 85,
87, 89, 91, 99, 101, 110, 119, 128,
137, 146, 155, 164, 173, 182, 192, 201,
210, 219, 228, 237, 246, 255, 264, 273,
}
var _expression_indicies []byte = []byte{
@ -103,57 +104,58 @@ var _expression_indicies []byte = []byte{
14, 21, 25, 25, 13, 14, 14, 33,
35, 34, 2, 1, 36, 37, 34, 2,
11, 38, 21, 34, 12, 39, 12, 21,
40, 42, 42, 43, 42, 42, 41, 42,
42, 42, 42, 42, 44, 45, 34, 46,
34, 47, 34, 25, 48, 49, 25, 25,
25, 25, 41, 48, 50, 25, 48, 49,
25, 51, 25, 25, 25, 50, 25, 48,
49, 25, 52, 25, 25, 25, 50, 25,
48, 49, 25, 53, 25, 25, 25, 50,
25, 48, 49, 25, 54, 25, 25, 25,
50, 25, 48, 49, 25, 55, 25, 25,
25, 50, 25, 48, 49, 25, 56, 25,
25, 25, 50, 25, 48, 49, 25, 57,
25, 25, 25, 50, 25, 48, 49, 25,
58, 25, 25, 25, 50, 25, 48, 49,
25, 59, 25, 25, 25, 50, 25, 48,
49, 25, 60, 61, 25, 25, 25, 50,
25, 48, 49, 25, 62, 25, 25, 25,
50, 25, 48, 49, 25, 63, 25, 25,
25, 50, 25, 48, 49, 25, 64, 25,
25, 25, 50, 25, 48, 49, 25, 65,
25, 25, 25, 50, 25, 48, 49, 25,
66, 25, 25, 25, 50, 25, 48, 49,
25, 67, 25, 25, 25, 50, 25, 48,
49, 25, 68, 25, 25, 25, 50, 25,
48, 49, 25, 69, 25, 25, 25, 50,
25, 48, 49, 25, 70, 25, 25, 25,
50, 25, 48, 49, 25, 63, 25, 25,
25, 50,
40, 41, 41, 42, 41, 41, 34, 41,
44, 41, 41, 41, 41, 43, 41, 44,
41, 42, 41, 41, 39, 45, 34, 46,
34, 47, 34, 25, 49, 50, 25, 25,
25, 25, 48, 49, 51, 25, 49, 50,
25, 52, 25, 25, 25, 51, 25, 49,
50, 25, 53, 25, 25, 25, 51, 25,
49, 50, 25, 54, 25, 25, 25, 51,
25, 49, 50, 25, 55, 25, 25, 25,
51, 25, 49, 50, 25, 56, 25, 25,
25, 51, 25, 49, 50, 25, 57, 25,
25, 25, 51, 25, 49, 50, 25, 58,
25, 25, 25, 51, 25, 49, 50, 25,
59, 25, 25, 25, 51, 25, 49, 50,
25, 60, 25, 25, 25, 51, 25, 49,
50, 25, 61, 62, 25, 25, 25, 51,
25, 49, 50, 25, 63, 25, 25, 25,
51, 25, 49, 50, 25, 64, 25, 25,
25, 51, 25, 49, 50, 25, 65, 25,
25, 25, 51, 25, 49, 50, 25, 66,
25, 25, 25, 51, 25, 49, 50, 25,
67, 25, 25, 25, 51, 25, 49, 50,
25, 68, 25, 25, 25, 51, 25, 49,
50, 25, 69, 25, 25, 25, 51, 25,
49, 50, 25, 70, 25, 25, 25, 51,
25, 49, 50, 25, 71, 25, 25, 25,
51, 25, 49, 50, 25, 64, 25, 25,
25, 51,
}
var _expression_trans_targs []byte = []byte{
11, 0, 11, 2, 3, 4, 5, 11,
7, 8, 11, 9, 18, 11, 12, 13,
14, 15, 16, 17, 20, 19, 22, 23,
24, 25, 27, 29, 36, 41, 42, 44,
45, 11, 11, 11, 1, 6, 10, 11,
11, 11, 21, 20, 11, 11, 11, 11,
11, 26, 11, 28, 25, 30, 31, 32,
33, 34, 35, 25, 37, 40, 38, 39,
25, 25, 25, 43, 25, 25, 46,
14, 15, 16, 17, 20, 19, 23, 24,
25, 26, 28, 30, 37, 42, 43, 45,
46, 11, 11, 11, 1, 6, 10, 11,
11, 21, 22, 11, 11, 11, 11, 11,
11, 11, 27, 11, 29, 26, 31, 32,
33, 34, 35, 36, 26, 38, 41, 39,
40, 26, 26, 26, 44, 26, 26, 47,
}
var _expression_trans_actions []byte = []byte{
37, 0, 11, 0, 0, 0, 0, 7,
0, 0, 9, 0, 0, 23, 0, 0,
5, 5, 5, 5, 68, 0, 0, 0,
0, 65, 0, 0, 0, 0, 0, 0,
0, 33, 35, 15, 0, 0, 0, 27,
25, 39, 0, 41, 31, 19, 13, 17,
21, 0, 29, 0, 50, 0, 0, 0,
0, 0, 0, 56, 0, 0, 0, 0,
44, 59, 62, 0, 47, 53, 0,
39, 0, 11, 0, 0, 0, 0, 7,
0, 0, 9, 0, 0, 25, 0, 0,
5, 5, 5, 5, 0, 0, 0, 0,
0, 64, 0, 0, 0, 0, 0, 0,
0, 35, 37, 15, 0, 0, 0, 29,
27, 0, 0, 33, 23, 19, 13, 17,
41, 21, 0, 31, 0, 49, 0, 0,
0, 0, 0, 0, 55, 0, 0, 0,
0, 43, 58, 61, 0, 46, 52, 0,
}
var _expression_to_state_actions []byte = []byte{
@ -162,7 +164,7 @@ var _expression_to_state_actions []byte = []byte{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
}
var _expression_from_state_actions []byte = []byte{
@ -171,16 +173,16 @@ var _expression_from_state_actions []byte = []byte{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
}
var _expression_eof_trans []int16 = []int16{
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 34, 35, 35, 35,
35, 35, 40, 41, 42, 45, 35, 35,
35, 42, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51,
35, 35, 40, 41, 35, 44, 40, 35,
35, 35, 49, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52,
}
const expression_start int = 11
@ -208,7 +210,7 @@ func newLexer(data []byte) *lexer {
pe: len(data),
}
//line scanner.go:216
//line scanner.go:218
{
lex.cs = expression_start
lex.ts = 0
@ -224,7 +226,7 @@ func (lex *lexer) Lex(out *yySymType) int {
eof := lex.pe
tok := 0
//line scanner.go:233
//line scanner.go:235
{
var _klen int
var _trans int
@ -245,7 +247,7 @@ func (lex *lexer) Lex(out *yySymType) int {
//line NONE:1
lex.ts = (lex.p)
//line scanner.go:253
//line scanner.go:255
}
}
@ -321,36 +323,30 @@ func (lex *lexer) Lex(out *yySymType) int {
lex.te = (lex.p) + 1
case 3:
//line scanner.rl:57
lex.act = 4
case 4:
//line scanner.rl:38
lex.act = 6
case 5:
case 4:
//line scanner.rl:88
lex.act = 7
case 6:
case 5:
//line scanner.rl:93
lex.act = 12
case 7:
case 6:
//line scanner.rl:94
lex.act = 13
case 8:
case 7:
//line scanner.rl:95
lex.act = 14
case 9:
case 8:
//line scanner.rl:96
lex.act = 15
case 10:
case 9:
//line scanner.rl:97
lex.act = 16
case 11:
case 10:
//line scanner.rl:43
lex.act = 18
case 12:
//line scanner.rl:102
lex.act = 21
case 13:
case 11:
//line scanner.rl:82
lex.te = (lex.p) + 1
{
@ -358,7 +354,7 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 14:
case 12:
//line scanner.rl:83
lex.te = (lex.p) + 1
{
@ -366,7 +362,7 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 15:
case 13:
//line scanner.rl:66
lex.te = (lex.p) + 1
{
@ -377,7 +373,7 @@ func (lex *lexer) Lex(out *yySymType) int {
goto _out
}
case 16:
case 14:
//line scanner.rl:89
lex.te = (lex.p) + 1
{
@ -385,7 +381,7 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 17:
case 15:
//line scanner.rl:90
lex.te = (lex.p) + 1
{
@ -393,7 +389,7 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 18:
case 16:
//line scanner.rl:91
lex.te = (lex.p) + 1
{
@ -401,7 +397,7 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 19:
case 17:
//line scanner.rl:92
lex.te = (lex.p) + 1
{
@ -409,7 +405,7 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 20:
case 18:
//line scanner.rl:98
lex.te = (lex.p) + 1
{
@ -418,7 +414,16 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 21:
case 19:
//line scanner.rl:100
lex.te = (lex.p) + 1
{
tok = PROPERTY
out.name = string(lex.data[lex.ts+1 : lex.te])
(lex.p)++
goto _out
}
case 20:
//line scanner.rl:102
lex.te = (lex.p) + 1
{
@ -426,7 +431,7 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 22:
case 21:
//line scanner.rl:48
lex.te = (lex.p)
(lex.p)--
@ -441,7 +446,7 @@ func (lex *lexer) Lex(out *yySymType) int {
goto _out
}
case 23:
case 22:
//line scanner.rl:57
lex.te = (lex.p)
(lex.p)--
@ -456,7 +461,7 @@ func (lex *lexer) Lex(out *yySymType) int {
goto _out
}
case 24:
case 23:
//line scanner.rl:43
lex.te = (lex.p)
(lex.p)--
@ -467,7 +472,7 @@ func (lex *lexer) Lex(out *yySymType) int {
goto _out
}
case 25:
case 24:
//line scanner.rl:100
lex.te = (lex.p)
(lex.p)--
@ -477,12 +482,12 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 26:
case 25:
//line scanner.rl:101
lex.te = (lex.p)
(lex.p)--
case 27:
case 26:
//line scanner.rl:102
lex.te = (lex.p)
(lex.p)--
@ -491,7 +496,7 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 28:
case 27:
//line scanner.rl:102
(lex.p) = (lex.te) - 1
{
@ -499,23 +504,9 @@ func (lex *lexer) Lex(out *yySymType) int {
(lex.p)++
goto _out
}
case 29:
case 28:
//line NONE:1
switch lex.act {
case 4:
{
(lex.p) = (lex.te) - 1
tok = LITERAL
n, err := strconv.ParseFloat(lex.token(), 64)
if err != nil {
panic(err)
}
out.val = n
(lex.p)++
goto _out
}
case 6:
{
(lex.p) = (lex.te) - 1
@ -579,16 +570,9 @@ func (lex *lexer) Lex(out *yySymType) int {
goto _out
}
case 21:
{
(lex.p) = (lex.te) - 1
tok = int(lex.data[lex.ts])
(lex.p)++
goto _out
}
}
//line scanner.go:528
//line scanner.go:513
}
}
@ -603,7 +587,7 @@ func (lex *lexer) Lex(out *yySymType) int {
//line NONE:1
lex.ts = 0
//line scanner.go:542
//line scanner.go:527
}
}

View File

@ -73,7 +73,7 @@ func (lex *lexer) Lex(out *yySymType) int {
identifier = (alpha | '_') . (alnum | '_' | '-')* '?'? ;
# TODO what can a property name contain?
property = '.' (alnum | '_' | '-')+ ;
property = '.' (alnum | '_' | '-')+ '?' ? ;
int = '-'? digit+ ;
float = '-'? (digit+ '.' digit* | '.' digit+) ;
string = '"' (any - '"')* '"' | "'" (any - "'")* "'" ; # TODO escapes