Skip to content

Commit

Permalink
removed shorthand_property_identifier and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
azizghuloum committed Nov 26, 2024
1 parent c05eb31 commit abbf53c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions examples/object-pattern-2.ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## `object-pattern-2.ts`

### Status: `DONE`

### Input Program

```typescript
using_syntax_rules(
[foo, {_, foo, _}, "matched"]
).rewrite({x: 1, foo, y: 2, z: 3})
```

### Output Program

```typescript
"matched";
```

2 changes: 0 additions & 2 deletions src/AST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { LL } from "./llhelpers";
export type atom_tag =
| "identifier"
| "property_identifier"
| "shorthand_property_identifier"
| "number"
| "regex_pattern"
| "type_identifier"
Expand All @@ -16,7 +15,6 @@ export const id_tags: { [k in atom_tag]: boolean } = {
identifier: true,
type_identifier: true,
property_identifier: true,
shorthand_property_identifier: true,
jsx_text: false,
number: false,
string: false,
Expand Down
3 changes: 2 additions & 1 deletion src/parser-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ function absurdly(node: Parser.SyntaxNode): AST {
case "regex_pattern":
case "identifier":
case "type_identifier":
case "shorthand_property_identifier":
case "property_identifier":
case "ERROR": {
return { type: "atom", tag: node.type, content: node.text };
}
case "shorthand_property_identifier":
return { type: "atom", tag: "identifier", content: node.text };
case node.text: {
return { type: "atom", tag: "other", content: node.text };
}
Expand Down
3 changes: 3 additions & 0 deletions tests/object-pattern-2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using_syntax_rules(
[foo, {_, foo, _}, "matched"]
).rewrite({x: 1, foo, y: 2, z: 3})

0 comments on commit abbf53c

Please sign in to comment.