Skip to content

Commit bfc5bb9

Browse files
committed
fix: Improve inplace/(post|pre) syntax
1 parent 530a8ad commit bfc5bb9

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/compiler/parser.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,10 @@ impl Parser {
17981798
"emit" => "sequence",
17991799
"children" =>
18001800
(value!([
1801+
(value!([
1802+
"emit" => "identifier",
1803+
"value" => "_"
1804+
])),
18011805
(value!([
18021806
"emit" => "value_token_touch",
18031807
"value" => "["
@@ -1814,10 +1818,6 @@ impl Parser {
18141818
"emit" => "value_token_touch",
18151819
"value" => "]"
18161820
])),
1817-
(value!([
1818-
"emit" => "identifier",
1819-
"value" => "_"
1820-
])),
18211821
(value!([
18221822
"emit" => "call",
18231823
"children" =>
@@ -2118,10 +2118,6 @@ impl Parser {
21182118
"emit" => "identifier",
21192119
"value" => "Variable"
21202120
])),
2121-
(value!([
2122-
"emit" => "identifier",
2123-
"value" => "_"
2124-
])),
21252121
(value!([
21262122
"emit" => "op_mod_kle",
21272123
"children" =>
@@ -5058,6 +5054,10 @@ impl Parser {
50585054
]))
50595055
]))
50605056
])),
5057+
(value!([
5058+
"emit" => "identifier",
5059+
"value" => "_"
5060+
])),
50615061
(value!([
50625062
"emit" => "value_instance",
50635063
"children" =>

src/compiler/tokay.tok

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The Tokay programming language
2-
# Copyright © 2023 by Jan Max Meyer, Phorward Software Technologies.
2+
# Copyright © 2024 by Jan Max Meyer, Phorward Software Technologies.
33
# Licensed under the MIT license. See LICENSE for more information.
44
#
55
# This Tokay program expresses Tokay's grammar in itself.
@@ -127,7 +127,7 @@ Ccl : @{
127127
# Statics, Variables, Loads
128128

129129
Subscript : @{
130-
'[' _ Expression ']' _ ast("item")
130+
_ '[' _ Expression ']' ast("item")
131131
}
132132

133133
Attribute : @{
@@ -147,7 +147,7 @@ Variable : @{
147147
}
148148

149149
Lvalue : @{
150-
Variable _ Subscript* ast("lvalue") # Lvalue currently doesn't allow attribute assignment!
150+
Variable Subscript* ast("lvalue") # Lvalue currently doesn't allow attribute assignment!
151151
}
152152

153153
Load : @{
@@ -284,7 +284,7 @@ Atomic : @{
284284
TokenModifier
285285
Keyword<'if'> _ Expect<Expression> ___ Expect<Statement> \
286286
(___ Keyword<'else'> _ ___ Expect<Statement>)? ast("op_if")
287-
Keyword<'for'> _ Expect<Lvalue> Keyword<Expect<'in'>> _ Expect<Expression> \
287+
Keyword<'for'> _ Expect<Lvalue> _ Keyword<Expect<'in'>> _ Expect<Expression> \
288288
___ Expect<Statement> ast("op_for")
289289
Keyword<'loop'> _ Expression ___ Block ast("op_loop")
290290
Keyword<'loop'> _ Expect<Block> ast("op_loop")

tests/list_add.tok

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ l
2525
l = ,
2626
i = 0
2727
l += i
28-
l, ++i
28+
l ++i
2929

3030
# iadd with mutable object
3131
l = ,

0 commit comments

Comments
 (0)