Skip to content

Commit 226ced5

Browse files
committed
split ast node definitions by concern
1 parent 6643ac4 commit 226ced5

3 files changed

Lines changed: 341 additions & 339 deletions

File tree

vibes/ast.go

Lines changed: 0 additions & 339 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ func (p *Program) Pos() Position {
2525
return p.Statements[0].Pos()
2626
}
2727

28-
type FunctionStmt struct {
29-
Name string
30-
Params []Param
31-
ReturnTy *TypeExpr
32-
Body []Statement
33-
IsClassMethod bool
34-
Exported bool
35-
Private bool
36-
position Position
37-
}
38-
39-
func (s *FunctionStmt) stmtNode() {}
40-
func (s *FunctionStmt) Pos() Position { return s.position }
41-
4228
type Param struct {
4329
Name string
4430
Type *TypeExpr
@@ -76,328 +62,3 @@ type TypeExpr struct {
7662
Union []*TypeExpr
7763
position Position
7864
}
79-
80-
type ReturnStmt struct {
81-
Value Expression
82-
position Position
83-
}
84-
85-
func (s *ReturnStmt) stmtNode() {}
86-
func (s *ReturnStmt) Pos() Position { return s.position }
87-
88-
type RaiseStmt struct {
89-
Value Expression
90-
position Position
91-
}
92-
93-
func (s *RaiseStmt) stmtNode() {}
94-
func (s *RaiseStmt) Pos() Position { return s.position }
95-
96-
type AssignStmt struct {
97-
Target Expression
98-
Value Expression
99-
position Position
100-
}
101-
102-
func (s *AssignStmt) stmtNode() {}
103-
func (s *AssignStmt) Pos() Position { return s.position }
104-
105-
type ExprStmt struct {
106-
Expr Expression
107-
position Position
108-
}
109-
110-
func (s *ExprStmt) stmtNode() {}
111-
func (s *ExprStmt) Pos() Position { return s.position }
112-
113-
type IfStmt struct {
114-
Condition Expression
115-
Consequent []Statement
116-
ElseIf []*IfStmt
117-
Alternate []Statement
118-
position Position
119-
}
120-
121-
func (s *IfStmt) stmtNode() {}
122-
func (s *IfStmt) Pos() Position { return s.position }
123-
124-
type ForStmt struct {
125-
Iterator string
126-
Iterable Expression
127-
Body []Statement
128-
position Position
129-
}
130-
131-
func (s *ForStmt) stmtNode() {}
132-
func (s *ForStmt) Pos() Position { return s.position }
133-
134-
type WhileStmt struct {
135-
Condition Expression
136-
Body []Statement
137-
position Position
138-
}
139-
140-
func (s *WhileStmt) stmtNode() {}
141-
func (s *WhileStmt) Pos() Position { return s.position }
142-
143-
type UntilStmt struct {
144-
Condition Expression
145-
Body []Statement
146-
position Position
147-
}
148-
149-
func (s *UntilStmt) stmtNode() {}
150-
func (s *UntilStmt) Pos() Position { return s.position }
151-
152-
type BreakStmt struct {
153-
position Position
154-
}
155-
156-
func (s *BreakStmt) stmtNode() {}
157-
func (s *BreakStmt) Pos() Position { return s.position }
158-
159-
type NextStmt struct {
160-
position Position
161-
}
162-
163-
func (s *NextStmt) stmtNode() {}
164-
func (s *NextStmt) Pos() Position { return s.position }
165-
166-
type TryStmt struct {
167-
Body []Statement
168-
RescueTy *TypeExpr
169-
Rescue []Statement
170-
Ensure []Statement
171-
position Position
172-
}
173-
174-
func (s *TryStmt) stmtNode() {}
175-
func (s *TryStmt) Pos() Position { return s.position }
176-
177-
type Identifier struct {
178-
Name string
179-
position Position
180-
}
181-
182-
func (e *Identifier) exprNode() {}
183-
func (e *Identifier) Pos() Position { return e.position }
184-
185-
type IntegerLiteral struct {
186-
Value int64
187-
position Position
188-
}
189-
190-
func (e *IntegerLiteral) exprNode() {}
191-
func (e *IntegerLiteral) Pos() Position { return e.position }
192-
193-
type FloatLiteral struct {
194-
Value float64
195-
position Position
196-
}
197-
198-
func (e *FloatLiteral) exprNode() {}
199-
func (e *FloatLiteral) Pos() Position { return e.position }
200-
201-
type StringLiteral struct {
202-
Value string
203-
position Position
204-
}
205-
206-
func (e *StringLiteral) exprNode() {}
207-
func (e *StringLiteral) Pos() Position { return e.position }
208-
209-
type BoolLiteral struct {
210-
Value bool
211-
position Position
212-
}
213-
214-
func (e *BoolLiteral) exprNode() {}
215-
func (e *BoolLiteral) Pos() Position { return e.position }
216-
217-
type NilLiteral struct {
218-
position Position
219-
}
220-
221-
func (e *NilLiteral) exprNode() {}
222-
func (e *NilLiteral) Pos() Position { return e.position }
223-
224-
type SymbolLiteral struct {
225-
Name string
226-
position Position
227-
}
228-
229-
func (e *SymbolLiteral) exprNode() {}
230-
func (e *SymbolLiteral) Pos() Position { return e.position }
231-
232-
type ArrayLiteral struct {
233-
Elements []Expression
234-
position Position
235-
}
236-
237-
func (e *ArrayLiteral) exprNode() {}
238-
func (e *ArrayLiteral) Pos() Position { return e.position }
239-
240-
type HashPair struct {
241-
Key Expression
242-
Value Expression
243-
}
244-
245-
type HashLiteral struct {
246-
Pairs []HashPair
247-
position Position
248-
}
249-
250-
func (e *HashLiteral) exprNode() {}
251-
func (e *HashLiteral) Pos() Position { return e.position }
252-
253-
type CallExpr struct {
254-
Callee Expression
255-
Args []Expression
256-
KwArgs []KeywordArg
257-
Block *BlockLiteral
258-
position Position
259-
}
260-
261-
func (e *CallExpr) exprNode() {}
262-
func (e *CallExpr) Pos() Position { return e.position }
263-
264-
type KeywordArg struct {
265-
Name string
266-
Value Expression
267-
}
268-
269-
type MemberExpr struct {
270-
Object Expression
271-
Property string
272-
position Position
273-
}
274-
275-
func (e *MemberExpr) exprNode() {}
276-
func (e *MemberExpr) Pos() Position { return e.position }
277-
278-
type IndexExpr struct {
279-
Object Expression
280-
Index Expression
281-
position Position
282-
}
283-
284-
type IvarExpr struct {
285-
Name string
286-
position Position
287-
}
288-
289-
func (e *IvarExpr) exprNode() {}
290-
func (e *IvarExpr) Pos() Position { return e.position }
291-
292-
type ClassVarExpr struct {
293-
Name string
294-
position Position
295-
}
296-
297-
func (e *ClassVarExpr) exprNode() {}
298-
func (e *ClassVarExpr) Pos() Position { return e.position }
299-
300-
func (e *IndexExpr) exprNode() {}
301-
func (e *IndexExpr) Pos() Position { return e.position }
302-
303-
type UnaryExpr struct {
304-
Operator TokenType
305-
Right Expression
306-
position Position
307-
}
308-
309-
func (e *UnaryExpr) exprNode() {}
310-
func (e *UnaryExpr) Pos() Position { return e.position }
311-
312-
type BinaryExpr struct {
313-
Left Expression
314-
Operator TokenType
315-
Right Expression
316-
position Position
317-
}
318-
319-
func (e *BinaryExpr) exprNode() {}
320-
func (e *BinaryExpr) Pos() Position { return e.position }
321-
322-
type RangeExpr struct {
323-
Start Expression
324-
End Expression
325-
position Position
326-
}
327-
328-
func (e *RangeExpr) exprNode() {}
329-
func (e *RangeExpr) Pos() Position { return e.position }
330-
331-
type CaseWhenClause struct {
332-
Values []Expression
333-
Result Expression
334-
}
335-
336-
type CaseExpr struct {
337-
Target Expression
338-
Clauses []CaseWhenClause
339-
ElseExpr Expression
340-
position Position
341-
}
342-
343-
func (e *CaseExpr) exprNode() {}
344-
func (e *CaseExpr) Pos() Position { return e.position }
345-
346-
type BlockLiteral struct {
347-
Params []Param
348-
Body []Statement
349-
position Position
350-
}
351-
352-
func (b *BlockLiteral) exprNode() {}
353-
func (b *BlockLiteral) Pos() Position { return b.position }
354-
355-
type YieldExpr struct {
356-
Args []Expression
357-
position Position
358-
}
359-
360-
func (y *YieldExpr) exprNode() {}
361-
func (y *YieldExpr) Pos() Position { return y.position }
362-
363-
type PropertyDecl struct {
364-
Names []string
365-
Kind string // property/getter/setter
366-
position Position
367-
}
368-
369-
type ClassStmt struct {
370-
Name string
371-
Methods []*FunctionStmt
372-
ClassMethods []*FunctionStmt
373-
Properties []PropertyDecl
374-
Body []Statement
375-
position Position
376-
}
377-
378-
func (s *ClassStmt) stmtNode() {}
379-
func (s *ClassStmt) Pos() Position { return s.position }
380-
381-
type InterpolatedString struct {
382-
Parts []StringPart
383-
position Position
384-
}
385-
386-
type StringPart interface {
387-
isStringPart()
388-
}
389-
390-
type StringText struct {
391-
Text string
392-
}
393-
394-
func (StringText) isStringPart() {}
395-
396-
type StringExpr struct {
397-
Expr Expression
398-
}
399-
400-
func (StringExpr) isStringPart() {}
401-
402-
func (s *InterpolatedString) exprNode() {}
403-
func (s *InterpolatedString) Pos() Position { return s.position }

0 commit comments

Comments
 (0)