Skip to content

Commit 99dcaa7

Browse files
author
Maarten Staa
committed
Handle more bitwise operators.
1 parent 3071125 commit 99dcaa7

File tree

3 files changed

+99
-4
lines changed

3 files changed

+99
-4
lines changed

src/lexer/attribute.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ module.exports = {
3636
case "+":
3737
case "*":
3838
case "%":
39+
case "~":
40+
case "<":
41+
case ">":
3942
return this.consume_TOKEN();
4043
case "[":
4144
listDepth++;

test/snapshot/__snapshots__/attributes.test.js.snap

Lines changed: 92 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ Program {
869869
},
870870
"what": Name {
871871
"kind": "name",
872-
"name": "Att2",
872+
"name": "Att3",
873873
"resolution": "uqn",
874874
},
875875
},
@@ -881,15 +881,104 @@ Program {
881881
},
882882
"what": Name {
883883
"kind": "name",
884-
"name": "Att2",
884+
"name": "Att3",
885885
"resolution": "uqn",
886886
},
887887
},
888888
"type": "^",
889889
},
890890
],
891891
"kind": "attribute",
892-
"name": "Att2",
892+
"name": "Att3",
893+
},
894+
],
895+
"kind": "attrgroup",
896+
},
897+
AttrGroup {
898+
"attrs": Array [
899+
Attribute {
900+
"args": Array [
901+
Unary {
902+
"kind": "unary",
903+
"type": "~",
904+
"what": StaticLookup {
905+
"kind": "staticlookup",
906+
"offset": Identifier {
907+
"kind": "identifier",
908+
"name": "BAR",
909+
},
910+
"what": Name {
911+
"kind": "name",
912+
"name": "Att4",
913+
"resolution": "uqn",
914+
},
915+
},
916+
},
917+
],
918+
"kind": "attribute",
919+
"name": "Att4",
920+
},
921+
],
922+
"kind": "attrgroup",
923+
},
924+
AttrGroup {
925+
"attrs": Array [
926+
Attribute {
927+
"args": Array [
928+
Bin {
929+
"kind": "bin",
930+
"left": StaticLookup {
931+
"kind": "staticlookup",
932+
"offset": Identifier {
933+
"kind": "identifier",
934+
"name": "BAR",
935+
},
936+
"what": Name {
937+
"kind": "name",
938+
"name": "Att5",
939+
"resolution": "uqn",
940+
},
941+
},
942+
"right": Number {
943+
"kind": "number",
944+
"value": "1",
945+
},
946+
"type": ">>",
947+
},
948+
],
949+
"kind": "attribute",
950+
"name": "Att5",
951+
},
952+
],
953+
"kind": "attrgroup",
954+
},
955+
AttrGroup {
956+
"attrs": Array [
957+
Attribute {
958+
"args": Array [
959+
Bin {
960+
"kind": "bin",
961+
"left": StaticLookup {
962+
"kind": "staticlookup",
963+
"offset": Identifier {
964+
"kind": "identifier",
965+
"name": "BAR",
966+
},
967+
"what": Name {
968+
"kind": "name",
969+
"name": "Att6",
970+
"resolution": "uqn",
971+
},
972+
},
973+
"right": Number {
974+
"kind": "number",
975+
"value": "1",
976+
},
977+
"type": "<<",
978+
},
979+
],
980+
"kind": "attribute",
981+
"name": "Att6",
893982
},
894983
],
895984
"kind": "attrgroup",

test/snapshot/attributes.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ describe("Parse Attributes", () => {
8282
`
8383
#[Att1(Att1::FOO | Att1::BAR)]
8484
#[Att2(Att2::FOO & Att2::BAR)]
85-
#[Att2(Att2::FOO ^ Att2::BAR)]
85+
#[Att3(Att3::FOO ^ Att3::BAR)]
86+
#[Att4(~ Att4::BAR)]
87+
#[Att5(Att5::BAR >> 1)]
88+
#[Att6(Att6::BAR << 1)]
8689
class A {}
8790
`,
8891
{ parser: { extractDoc: true } }

0 commit comments

Comments
 (0)