comparison mercurial/fileset.py @ 25815:e71e5629e006

parser: separate actions for primary expression and prefix operator This will allow us to define both a primary expression, ":", and a prefix operator, ":y". The ambiguity will be resolved by the next patch. Prefix actions in elements table are adjusted as follows: original prefix primary prefix ----------------- -------- ----------------- ("group", 1, ")") -> n/a ("group", 1, ")") ("negate", 19) -> n/a ("negate", 19) ("symbol",) -> "symbol" n/a
author Yuya Nishihara <yuya@tcha.org>
date Sun, 05 Jul 2015 12:02:13 +0900
parents 272ff3680bf3
children 23c4589fc678 e194ada8d45f
comparison
equal deleted inserted replaced
25814:dc1a49264628 25815:e71e5629e006
8 import re 8 import re
9 import parser, error, util, merge 9 import parser, error, util, merge
10 from i18n import _ 10 from i18n import _
11 11
12 elements = { 12 elements = {
13 # token-type: binding-strength, prefix, infix, suffix 13 # token-type: binding-strength, primary, prefix, infix, suffix
14 "(": (20, ("group", 1, ")"), ("func", 1, ")"), None), 14 "(": (20, None, ("group", 1, ")"), ("func", 1, ")"), None),
15 "-": (5, ("negate", 19), ("minus", 5), None), 15 "-": (5, None, ("negate", 19), ("minus", 5), None),
16 "not": (10, ("not", 10), None, None), 16 "not": (10, None, ("not", 10), None, None),
17 "!": (10, ("not", 10), None, None), 17 "!": (10, None, ("not", 10), None, None),
18 "and": (5, None, ("and", 5), None), 18 "and": (5, None, None, ("and", 5), None),
19 "&": (5, None, ("and", 5), None), 19 "&": (5, None, None, ("and", 5), None),
20 "or": (4, None, ("or", 4), None), 20 "or": (4, None, None, ("or", 4), None),
21 "|": (4, None, ("or", 4), None), 21 "|": (4, None, None, ("or", 4), None),
22 "+": (4, None, ("or", 4), None), 22 "+": (4, None, None, ("or", 4), None),
23 ",": (2, None, ("list", 2), None), 23 ",": (2, None, None, ("list", 2), None),
24 ")": (0, None, None, None), 24 ")": (0, None, None, None, None),
25 "symbol": (0, ("symbol",), None, None), 25 "symbol": (0, "symbol", None, None, None),
26 "string": (0, ("string",), None, None), 26 "string": (0, "string", None, None, None),
27 "end": (0, None, None, None), 27 "end": (0, None, None, None, None),
28 } 28 }
29 29
30 keywords = set(['and', 'or', 'not']) 30 keywords = set(['and', 'or', 'not'])
31 31
32 globchars = ".*{}[]?/\\_" 32 globchars = ".*{}[]?/\\_"