Skip to content

Commit 86bee21

Browse files
author
Maarten Staa
committed
Handle more logical operators.
1 parent 99dcaa7 commit 86bee21

File tree

3 files changed

+150
-1
lines changed

3 files changed

+150
-1
lines changed

src/lexer/attribute.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = {
3939
case "~":
4040
case "<":
4141
case ">":
42+
case "!":
4243
return this.consume_TOKEN();
4344
case "[":
4445
listDepth++;
@@ -67,7 +68,7 @@ module.exports = {
6768
break;
6869
}
6970
}
70-
return this.tok.T_STRING;
71+
return this.T_STRING();
7172
} else if (this.is_NUM()) {
7273
return this.consume_NUM();
7374
}

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

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,150 @@ Program {
12691269
],
12701270
"kind": "attrgroup",
12711271
},
1272+
AttrGroup {
1273+
"attrs": Array [
1274+
Attribute {
1275+
"args": Array [
1276+
Bin {
1277+
"kind": "bin",
1278+
"left": StaticLookup {
1279+
"kind": "staticlookup",
1280+
"offset": Identifier {
1281+
"kind": "identifier",
1282+
"name": "FOO",
1283+
},
1284+
"what": Name {
1285+
"kind": "name",
1286+
"name": "Att3",
1287+
"resolution": "uqn",
1288+
},
1289+
},
1290+
"right": StaticLookup {
1291+
"kind": "staticlookup",
1292+
"offset": Identifier {
1293+
"kind": "identifier",
1294+
"name": "BAR",
1295+
},
1296+
"what": Name {
1297+
"kind": "name",
1298+
"name": "Att3",
1299+
"resolution": "uqn",
1300+
},
1301+
},
1302+
"type": "or",
1303+
},
1304+
],
1305+
"kind": "attribute",
1306+
"name": "Att3",
1307+
},
1308+
],
1309+
"kind": "attrgroup",
1310+
},
1311+
AttrGroup {
1312+
"attrs": Array [
1313+
Attribute {
1314+
"args": Array [
1315+
Bin {
1316+
"kind": "bin",
1317+
"left": StaticLookup {
1318+
"kind": "staticlookup",
1319+
"offset": Identifier {
1320+
"kind": "identifier",
1321+
"name": "FOO",
1322+
},
1323+
"what": Name {
1324+
"kind": "name",
1325+
"name": "Att4",
1326+
"resolution": "uqn",
1327+
},
1328+
},
1329+
"right": StaticLookup {
1330+
"kind": "staticlookup",
1331+
"offset": Identifier {
1332+
"kind": "identifier",
1333+
"name": "BAR",
1334+
},
1335+
"what": Name {
1336+
"kind": "name",
1337+
"name": "Att4",
1338+
"resolution": "uqn",
1339+
},
1340+
},
1341+
"type": "and",
1342+
},
1343+
],
1344+
"kind": "attribute",
1345+
"name": "Att4",
1346+
},
1347+
],
1348+
"kind": "attrgroup",
1349+
},
1350+
AttrGroup {
1351+
"attrs": Array [
1352+
Attribute {
1353+
"args": Array [
1354+
Bin {
1355+
"kind": "bin",
1356+
"left": StaticLookup {
1357+
"kind": "staticlookup",
1358+
"offset": Identifier {
1359+
"kind": "identifier",
1360+
"name": "FOO",
1361+
},
1362+
"what": Name {
1363+
"kind": "name",
1364+
"name": "Att5",
1365+
"resolution": "uqn",
1366+
},
1367+
},
1368+
"right": StaticLookup {
1369+
"kind": "staticlookup",
1370+
"offset": Identifier {
1371+
"kind": "identifier",
1372+
"name": "BAR",
1373+
},
1374+
"what": Name {
1375+
"kind": "name",
1376+
"name": "Att5",
1377+
"resolution": "uqn",
1378+
},
1379+
},
1380+
"type": "xor",
1381+
},
1382+
],
1383+
"kind": "attribute",
1384+
"name": "Att5",
1385+
},
1386+
],
1387+
"kind": "attrgroup",
1388+
},
1389+
AttrGroup {
1390+
"attrs": Array [
1391+
Attribute {
1392+
"args": Array [
1393+
Unary {
1394+
"kind": "unary",
1395+
"type": "!",
1396+
"what": StaticLookup {
1397+
"kind": "staticlookup",
1398+
"offset": Identifier {
1399+
"kind": "identifier",
1400+
"name": "FOO",
1401+
},
1402+
"what": Name {
1403+
"kind": "name",
1404+
"name": "Att6",
1405+
"resolution": "uqn",
1406+
},
1407+
},
1408+
},
1409+
],
1410+
"kind": "attribute",
1411+
"name": "Att6",
1412+
},
1413+
],
1414+
"kind": "attrgroup",
1415+
},
12721416
],
12731417
"body": Array [],
12741418
"extends": null,

test/snapshot/attributes.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ describe("Parse Attributes", () => {
9898
`
9999
#[Att1(Att1::FOO || Att1::BAR)]
100100
#[Att2(Att2::FOO && Att2::BAR)]
101+
#[Att3(Att3::FOO or Att3::BAR)]
102+
#[Att4(Att4::FOO and Att4::BAR)]
103+
#[Att5(Att5::FOO xor Att5::BAR)]
104+
#[Att6(!Att6::FOO)]
101105
class A {}
102106
`,
103107
{ parser: { extractDoc: true } }

0 commit comments

Comments
 (0)