Skip to content

Commit 1e9fe62

Browse files
committed
Support / # and , in identifiers
1 parent 8e6516e commit 1e9fe62

8 files changed

Lines changed: 73 additions & 4 deletions

File tree

meta/src/meta/grammar.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
%token INT Int64 r'[-]?\d+'
4141
%token INT128 logic.Int128Value r'[-]?\d+i128'
4242
%token STRING String r'"(?:[^"\\]|\\.)*"'
43-
%token SYMBOL String r'[a-zA-Z_][a-zA-Z0-9_.-]*'
43+
%token SYMBOL String r'[a-zA-Z_][a-zA-Z0-9_./#,-]*'
4444
%token UINT128 logic.UInt128Value r'0x[0-9a-fA-F]+'
4545

4646
# Type declarations for rules

sdks/go/src/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ var (
145145
{"INT", regexp.MustCompile(`^[-]?\d+`), func(s string) TokenValue { return TokenValue{kind: kindInt64, i64: scanInt(s)} }},
146146
{"INT128", regexp.MustCompile(`^[-]?\d+i128`), func(s string) TokenValue { return TokenValue{kind: kindInt128, int128: scanInt128(s)} }},
147147
{"STRING", regexp.MustCompile(`^"(?:[^"\\]|\\.)*"`), func(s string) TokenValue { return TokenValue{kind: kindString, str: scanString(s)} }},
148-
{"SYMBOL", regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_.-]*`), func(s string) TokenValue { return TokenValue{kind: kindString, str: scanSymbol(s)} }},
148+
{"SYMBOL", regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_./#,-]*`), func(s string) TokenValue { return TokenValue{kind: kindString, str: scanSymbol(s)} }},
149149
{"UINT128", regexp.MustCompile(`^0x[0-9a-fA-F]+`), func(s string) TokenValue { return TokenValue{kind: kindUint128, uint128: scanUint128(s)} }},
150150
}
151151
)

sdks/julia/LogicalQueryProtocol.jl/src/parser.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const _TOKEN_SPECS = [
153153
("INT", r"[-]?\d+", scan_int),
154154
("INT128", r"[-]?\d+i128", scan_int128),
155155
("STRING", r"\"(?:[^\"\\]|\\.)*\"", scan_string),
156-
("SYMBOL", r"[a-zA-Z_][a-zA-Z0-9_.-]*", scan_symbol),
156+
("SYMBOL", r"[a-zA-Z_][a-zA-Z0-9_./#,-]*", scan_symbol),
157157
("UINT128", r"0x[0-9a-fA-F]+", scan_uint128),
158158
]
159159

sdks/python/src/lqp/gen/parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ def __repr__(self) -> str:
113113
("INT", re.compile(r"[-]?\d+"), lambda x: Lexer.scan_int(x)),
114114
("INT128", re.compile(r"[-]?\d+i128"), lambda x: Lexer.scan_int128(x)),
115115
("STRING", re.compile(r'"(?:[^"\\]|\\.)*"'), lambda x: Lexer.scan_string(x)),
116-
("SYMBOL", re.compile(r"[a-zA-Z_][a-zA-Z0-9_.-]*"), lambda x: Lexer.scan_symbol(x)),
116+
(
117+
"SYMBOL",
118+
re.compile(r"[a-zA-Z_][a-zA-Z0-9_./#,-]*"),
119+
lambda x: Lexer.scan_symbol(x),
120+
),
117121
("UINT128", re.compile(r"0x[0-9a-fA-F]+"), lambda x: Lexer.scan_uint128(x)),
118122
]
119123

tests/bin/special_chars_in_ids.bin

577 Bytes
Binary file not shown.

tests/lqp/special_chars_in_ids.lqp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
;; Test that identifiers can contain / # and , characters
2+
(transaction
3+
(epoch
4+
(writes
5+
(define
6+
(fragment :f1
7+
(def :my/relation
8+
([x::INT]
9+
(and
10+
(= x 1)
11+
(atom :other/rel x x))))
12+
(def :my#relation
13+
([x::INT y::INT]
14+
(and
15+
(atom :my/relation x)
16+
(= y x))))
17+
(def :my,relation
18+
([x::INT]
19+
(atom :my/relation x))))))
20+
(reads
21+
(output :my/relation :my/relation)
22+
(output :my#relation :my#relation)
23+
(output :my,relation :my,relation))))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(transaction
2+
(configure { :ivm.maintenance_level "off" :semantics_version 0})
3+
(epoch
4+
(writes
5+
(define
6+
(fragment
7+
:f1
8+
(def :my/relation ([x::INT] (and (= x 1) (atom :other/rel x x))))
9+
(def :my#relation ([x::INT y::INT] (and (atom :my/relation x) (= y x))))
10+
(def :my,relation ([x::INT] (atom :my/relation x))))))
11+
(reads
12+
(output :my/relation :my/relation)
13+
(output :my#relation :my#relation)
14+
(output :my,relation :my,relation))))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(transaction
2+
(configure { :ivm.maintenance_level "off" :semantics_version 0})
3+
(epoch
4+
(writes
5+
(define
6+
(fragment
7+
:f1
8+
(def
9+
0x15c3d261e9b87ddca0f3e13e054457bd
10+
([x::INT] (and (= x 1) (atom 0x91b51012f825fc7c589f890a3b18cfd4 x x))))
11+
(def
12+
0x1e9de369d8c3c11ff417a9c0c86e7ebe
13+
([x::INT y::INT] (and (atom 0x15c3d261e9b87ddca0f3e13e054457bd x) (= y x))))
14+
(def
15+
0xcdd1079222948b600fa246777af00460
16+
([x::INT] (atom 0x15c3d261e9b87ddca0f3e13e054457bd x))))))
17+
(reads
18+
(output :my/relation 0x15c3d261e9b87ddca0f3e13e054457bd)
19+
(output :my#relation 0x1e9de369d8c3c11ff417a9c0c86e7ebe)
20+
(output :my,relation 0xcdd1079222948b600fa246777af00460))))
21+
22+
;; Debug information
23+
;; -----------------------
24+
;; Original names
25+
;; ID `0x1e9de369d8c3c11ff417a9c0c86e7ebe` -> `my#relation`
26+
;; ID `0xcdd1079222948b600fa246777af00460` -> `my,relation`
27+
;; ID `0x15c3d261e9b87ddca0f3e13e054457bd` -> `my/relation`
28+
;; ID `0x91b51012f825fc7c589f890a3b18cfd4` -> `other/rel`

0 commit comments

Comments
 (0)