This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Grouping extends Expression { | |
| constructor(expression) { | |
| super() | |
| this.expression = expression | |
| } | |
| handle(visitor) { | |
| return visitor.visitGroupingExpression(this) | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Unary extends Expression { | |
| constructor(operator, right) { | |
| super() | |
| this.operator = operator | |
| this.right = right | |
| } | |
| handle(visitor) { | |
| return visitor.visitUnaryExpression(this) | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Literal extends Expression { | |
| constructor(value) { | |
| super() | |
| this.value = value | |
| } | |
| handle(visitor) { | |
| return visitor.visitLiteralExpression(this) | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Binary extends Expression { | |
| constructor(left, operator, right) { | |
| super() | |
| this.left = left | |
| this.operator = operator | |
| this.right = right | |
| } | |
| handle(visitor) { | |
| return visitor.visitBinaryExpression(this) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Expression { | |
| handle(visitor) {} | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Visitor { | |
| visitBinaryExpression(binary) {} | |
| visitUnaryExpression(unary) {} | |
| visitLiteralExpression(literal) {} | |
| visitGroupingExpression(grouping) {} | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | expression => binary | unary | grouping | literal | |
| literal => "true" | "false" | number | string | "null" | |
| grouping => "(" expression ")" | |
| binary => expression operator expression | |
| unary => ( "-" | "!" ) expression | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | (* 12 (- 10 20)) | 
NewerOlder