1
0
mirror of https://github.com/danog/liquid.git synced 2025-01-22 22:51:13 +01:00

Allow - in identifiers

This commit is contained in:
Oliver Steele 2017-06-28 15:33:04 -04:00
parent 910d4b25cb
commit af8c48608e
2 changed files with 80 additions and 73 deletions

View File

@ -22,10 +22,10 @@ var _expression_actions []byte = []byte{
var _expression_key_offsets []byte = []byte{
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 12, 37, 40, 41, 42,
44, 45, 48, 50, 53, 54, 55, 63,
72, 81, 90, 99, 108, 117, 126, 135,
144, 154, 163, 172, 181, 190, 199, 208,
217,
44, 45, 48, 50, 53, 54, 55, 64,
74, 84, 94, 104, 114, 124, 134, 144,
154, 165, 175, 185, 195, 205, 215, 225,
235,
}
var _expression_trans_keys []byte = []byte{
@ -35,38 +35,40 @@ var _expression_trans_keys []byte = []byte{
105, 111, 116, 9, 13, 48, 57, 60,
62, 65, 90, 98, 122, 32, 9, 13,
61, 34, 97, 108, 39, 46, 48, 57,
48, 57, 46, 48, 57, 61, 61, 58,
95, 48, 57, 65, 90, 97, 122, 58,
48, 57, 46, 48, 57, 61, 61, 45,
58, 95, 48, 57, 65, 90, 97, 122,
45, 58, 95, 110, 48, 57, 65, 90,
97, 122, 45, 58, 95, 100, 48, 57,
65, 90, 97, 122, 45, 58, 95, 111,
48, 57, 65, 90, 97, 122, 45, 58,
95, 110, 48, 57, 65, 90, 97, 122,
58, 95, 100, 48, 57, 65, 90, 97,
122, 58, 95, 111, 48, 57, 65, 90,
97, 122, 58, 95, 110, 48, 57, 65,
90, 97, 122, 58, 95, 116, 48, 57,
65, 90, 97, 122, 58, 95, 97, 48,
57, 65, 90, 98, 122, 58, 95, 105,
48, 57, 65, 90, 97, 122, 58, 95,
110, 48, 57, 65, 90, 97, 122, 58,
95, 115, 48, 57, 65, 90, 97, 122,
58, 95, 97, 111, 48, 57, 65, 90,
98, 122, 58, 95, 108, 48, 57, 65,
90, 97, 122, 58, 95, 115, 48, 57,
65, 90, 97, 122, 58, 95, 101, 48,
57, 65, 90, 97, 122, 58, 95, 114,
48, 57, 65, 90, 97, 122, 58, 95,
110, 48, 57, 65, 90, 97, 122, 58,
95, 114, 48, 57, 65, 90, 97, 122,
45, 58, 95, 116, 48, 57, 65, 90,
97, 122, 45, 58, 95, 97, 48, 57,
65, 90, 98, 122, 45, 58, 95, 105,
48, 57, 65, 90, 97, 122, 45, 58,
95, 110, 48, 57, 65, 90, 97, 122,
45, 58, 95, 115, 48, 57, 65, 90,
97, 122, 45, 58, 95, 97, 111, 48,
57, 65, 90, 98, 122, 45, 58, 95,
108, 48, 57, 65, 90, 97, 122, 45,
58, 95, 115, 48, 57, 65, 90, 97,
122, 45, 58, 95, 101, 48, 57, 65,
90, 97, 122, 45, 58, 95, 114, 48,
57, 65, 90, 97, 122, 45, 58, 95,
110, 48, 57, 65, 90, 97, 122, 45,
58, 95, 114, 48, 57, 65, 90, 97,
122, 58, 95, 117, 48, 57, 65, 90,
97, 122,
122, 45, 58, 95, 114, 48, 57, 65,
90, 97, 122, 45, 58, 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, 15, 1, 1, 1, 2,
1, 1, 0, 1, 1, 1, 2, 3,
3, 3, 3, 3, 3, 3, 3, 3,
4, 3, 3, 3, 3, 3, 3, 3,
3,
1, 1, 0, 1, 1, 1, 3, 4,
4, 4, 4, 4, 4, 4, 4, 4,
5, 4, 4, 4, 4, 4, 4, 4,
4,
}
var _expression_range_lengths []byte = []byte{
@ -81,10 +83,10 @@ var _expression_range_lengths []byte = []byte{
var _expression_index_offsets []byte = []byte{
0, 2, 4, 6, 8, 10, 12, 14,
16, 18, 20, 22, 43, 46, 48, 50,
53, 55, 58, 60, 63, 65, 67, 73,
80, 87, 94, 101, 108, 115, 122, 129,
136, 144, 151, 158, 165, 172, 179, 186,
193,
53, 55, 58, 60, 63, 65, 67, 74,
82, 90, 98, 106, 114, 122, 130, 138,
146, 155, 163, 171, 179, 187, 195, 203,
211,
}
var _expression_indicies []byte = []byte{
@ -96,24 +98,26 @@ var _expression_indicies []byte = []byte{
24, 24, 13, 14, 14, 31, 33, 32,
2, 1, 34, 35, 32, 2, 11, 36,
21, 32, 12, 37, 12, 21, 38, 39,
32, 40, 32, 41, 24, 24, 24, 24,
37, 41, 24, 43, 24, 24, 24, 42,
41, 24, 44, 24, 24, 24, 42, 41,
24, 45, 24, 24, 24, 42, 41, 24,
46, 24, 24, 24, 42, 41, 24, 47,
24, 24, 24, 42, 41, 24, 48, 24,
24, 24, 42, 41, 24, 49, 24, 24,
24, 42, 41, 24, 50, 24, 24, 24,
42, 41, 24, 51, 24, 24, 24, 42,
41, 24, 52, 53, 24, 24, 24, 42,
41, 24, 54, 24, 24, 24, 42, 41,
24, 55, 24, 24, 24, 42, 41, 24,
56, 24, 24, 24, 42, 41, 24, 57,
24, 24, 24, 42, 41, 24, 58, 24,
24, 24, 42, 41, 24, 59, 24, 24,
24, 42, 41, 24, 60, 24, 24, 24,
42, 41, 24, 55, 24, 24, 24, 42,
32, 40, 32, 24, 41, 24, 24, 24,
24, 37, 24, 41, 24, 43, 24, 24,
24, 42, 24, 41, 24, 44, 24, 24,
24, 42, 24, 41, 24, 45, 24, 24,
24, 42, 24, 41, 24, 46, 24, 24,
24, 42, 24, 41, 24, 47, 24, 24,
24, 42, 24, 41, 24, 48, 24, 24,
24, 42, 24, 41, 24, 49, 24, 24,
24, 42, 24, 41, 24, 50, 24, 24,
24, 42, 24, 41, 24, 51, 24, 24,
24, 42, 24, 41, 24, 52, 53, 24,
24, 24, 42, 24, 41, 24, 54, 24,
24, 24, 42, 24, 41, 24, 55, 24,
24, 24, 42, 24, 41, 24, 56, 24,
24, 24, 42, 24, 41, 24, 57, 24,
24, 24, 42, 24, 41, 24, 58, 24,
24, 24, 42, 24, 41, 24, 59, 24,
24, 24, 42, 24, 41, 24, 60, 24,
24, 24, 42, 24, 41, 24, 55, 24,
24, 24, 42,
}
var _expression_trans_targs []byte = []byte{
@ -192,7 +196,7 @@ func newLexer(data []byte) *lexer {
pe: len(data),
}
//line scanner.go:196
//line scanner.go:200
{
lex.cs = expression_start
lex.ts = 0
@ -209,7 +213,7 @@ func (lex *lexer) Lex(out *yySymType) int {
tok := 0
//line scanner.go:213
//line scanner.go:217
{
var _klen int
var _trans int
@ -229,7 +233,7 @@ _resume:
//line NONE:1
lex.ts = ( lex.p)
//line scanner.go:233
//line scanner.go:237
}
}
@ -310,33 +314,33 @@ _eof_trans:
//line scanner.rl:40
lex.act = 6;
case 5:
//line scanner.rl:91
//line scanner.rl:94
lex.act = 10;
case 6:
//line scanner.rl:92
//line scanner.rl:95
lex.act = 11;
case 7:
//line scanner.rl:93
//line scanner.rl:96
lex.act = 12;
case 8:
//line scanner.rl:94
//line scanner.rl:97
lex.act = 13;
case 9:
//line scanner.rl:95
//line scanner.rl:98
lex.act = 14;
case 10:
//line scanner.rl:45
lex.act = 16;
case 11:
//line scanner.rl:99
//line scanner.rl:102
lex.act = 18;
case 12:
//line scanner.rl:82
//line scanner.rl:85
lex.te = ( lex.p)+1
{ tok = ASSIGN; ( lex.p)++; goto _out
}
case 13:
//line scanner.rl:83
//line scanner.rl:86
lex.te = ( lex.p)+1
{ tok = LOOP; ( lex.p)++; goto _out
}
@ -351,12 +355,12 @@ _eof_trans:
}
case 15:
//line scanner.rl:88
//line scanner.rl:91
lex.te = ( lex.p)+1
{ tok = EQ; ( lex.p)++; goto _out
}
case 16:
//line scanner.rl:89
//line scanner.rl:92
lex.te = ( lex.p)+1
{ tok = NEQ; ( lex.p)++; goto _out
}
@ -366,12 +370,12 @@ _eof_trans:
{ tok = RELATION; out.name = lex.token(); ( lex.p)++; goto _out
}
case 18:
//line scanner.rl:96
//line scanner.rl:99
lex.te = ( lex.p)+1
{ tok = KEYWORD; out.name = string(lex.data[lex.ts:lex.te-1]); ( lex.p)++; goto _out
}
case 19:
//line scanner.rl:99
//line scanner.rl:102
lex.te = ( lex.p)+1
{ tok = int(lex.data[lex.ts]); ( lex.p)++; goto _out
}
@ -400,18 +404,18 @@ _eof_trans:
}
case 22:
//line scanner.rl:98
//line scanner.rl:101
lex.te = ( lex.p)
( lex.p)--
case 23:
//line scanner.rl:99
//line scanner.rl:102
lex.te = ( lex.p)
( lex.p)--
{ tok = int(lex.data[lex.ts]); ( lex.p)++; goto _out
}
case 24:
//line scanner.rl:99
//line scanner.rl:102
( lex.p) = ( lex.te) - 1
{ tok = int(lex.data[lex.ts]); ( lex.p)++; goto _out
}
@ -472,7 +476,7 @@ _eof_trans:
}
}
//line scanner.go:476
//line scanner.go:480
}
}
@ -486,7 +490,7 @@ _again:
//line NONE:1
lex.ts = 0
//line scanner.go:490
//line scanner.go:494
}
}
@ -505,7 +509,7 @@ _again:
_out: {}
}
//line scanner.rl:103
//line scanner.rl:106
return tok

View File

@ -73,7 +73,10 @@ func (lex *lexer) Lex(out *yySymType) int {
}
action Relation { tok = RELATION; out.name = lex.token(); fbreak; }
ident = (alpha | '_') . (alnum | '_')* ;
# TODO this allows medial '-' because some themes allow it in properties.
# Is this a general feature of Liquid identifiers, or is it limited to
# property names?
ident = (alpha | '_') . (alnum | '_' | '-')* ;
int = '-'? digit+ ;
float = '-'? (digit+ '.' digit* | '.' digit+) ;
string = '"' (any - '"')* '"' | "'" (any - "'")* "'" ; # TODO escapes