File tree Expand file tree Collapse file tree 5 files changed +56
-0
lines changed
Expand file tree Collapse file tree 5 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -223,4 +223,33 @@ export class Printer implements Visitor {
223223 node . expression . accept ( this . increment ( ) ) ;
224224 this . display ( ") " ) ;
225225 }
226+
227+ visitDefineSyntax ( node : Atomic . DefineSyntax ) {
228+ // this.indent();
229+ this . display ( "( define-syntax " ) ;
230+ node . name . accept ( this . increment ( ) ) ;
231+ this . display ( " " ) ;
232+ node . transformer . accept ( this . increment ( ) ) ;
233+ this . display ( ") " ) ;
234+ }
235+
236+ visitSyntaxRules ( node : Atomic . SyntaxRules ) {
237+ // this.indent();
238+ this . display ( "( syntax-rules " ) ;
239+ this . display ( "( " ) ;
240+ node . literals . forEach ( literal => {
241+ literal . accept ( this . increment ( ) ) ;
242+ this . display ( " " ) ;
243+ } ) ;
244+ this . display ( ") " ) ;
245+ node . rules . forEach ( rule => {
246+ this . display ( "\n" ) ;
247+ this . display ( "( " ) ;
248+ rule [ 0 ] . accept ( this . increment ( ) ) ;
249+ this . display ( " " ) ;
250+ rule [ 1 ] . accept ( this . increment ( ) ) ;
251+ this . display ( ") " ) ;
252+ } ) ;
253+ this . display ( ") " ) ;
254+ }
226255}
Original file line number Diff line number Diff line change @@ -226,4 +226,13 @@ export class Redefiner implements Visitor {
226226
227227 return new Extended . Delay ( location , newBody ) ;
228228 }
229+
230+ // there are no redefinitions in the following nodes.
231+ visitDefineSyntax ( node : Atomic . DefineSyntax ) {
232+ return node ;
233+ }
234+
235+ visitSyntaxRules ( node : Atomic . SyntaxRules ) {
236+ return node ;
237+ }
229238}
Original file line number Diff line number Diff line change @@ -255,4 +255,13 @@ export class Simplifier implements Visitor {
255255 const makePromise = new Atomic . Identifier ( location , "make-promise" ) ;
256256 return new Atomic . Application ( location , makePromise , [ delayedLambda ] ) ;
257257 }
258+
259+ // these nodes are already in their simplest form
260+ visitDefineSyntax ( node : Atomic . DefineSyntax ) {
261+ return node ;
262+ }
263+
264+ visitSyntaxRules ( node : Atomic . SyntaxRules ) {
265+ return node ;
266+ }
258267}
Original file line number Diff line number Diff line change @@ -410,4 +410,10 @@ export class Transpiler implements Visitor {
410410 visitDelay ( node : Extended . Delay ) : [ es . ArrowFunctionExpression ] {
411411 throw new Error ( "The AST should be simplified!" ) ;
412412 }
413+ visitDefineSyntax ( node : Atomic . DefineSyntax ) {
414+ throw new Error ( "This should not be called!" ) ;
415+ }
416+ visitSyntaxRules ( node : Atomic . SyntaxRules ) {
417+ throw new Error ( "This should not be called!" ) ;
418+ }
413419}
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ export interface Visitor {
3232
3333 visitVector ( node : Atomic . Vector ) : any ;
3434
35+ visitSyntaxRules ( node : Atomic . SyntaxRules ) : any ;
36+ visitDefineSyntax ( node : Atomic . DefineSyntax ) : any ;
37+
3538 // Extended AST
3639 visitFunctionDefinition ( node : Extended . FunctionDefinition ) : any ;
3740 visitLet ( node : Extended . Let ) : any ;
You can’t perform that action at this time.
0 commit comments