// Generated from ./src/domain/grammar/StepGrammar.g4 by ANTLR 4.7.1
// jshint ignore: start
var antlr4 = require('antlr4/index');
import StepAST from "../../domain/StepAST";
import { STEP_OPERATOR } from "../../domain/StepOperator";
import Action from "../../domain/Action";

// This class defines a complete generic visitor for a parse tree produced by StepGrammarParser.

function StepGrammarVisitor() {
	antlr4.tree.ParseTreeVisitor.call(this);
	return this;
}

let builder;

exports.setBuilder = function setBuilder(newBuilder) {
  builder = newBuilder;
}

StepGrammarVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype);
StepGrammarVisitor.prototype.constructor = StepGrammarVisitor;

// Visit a parse tree produced by StepGrammarParser#action.
StepGrammarVisitor.prototype.visitAction = function(ctx) {
  return new StepAST(new Action(ctx.getText()));
};

// Visit a parse tree produced by StepGrammarParser#string.
StepGrammarVisitor.prototype.visitString = function(ctx) {
  return this.visitChildren(ctx);
};


// Visit a parse tree produced by StepGrammarParser#check.
StepGrammarVisitor.prototype.visitCheck = function(ctx) {
  return this.visitChildren(ctx);
};


// Visit a parse tree produced by StepGrammarParser#par_step.
StepGrammarVisitor.prototype.visitPar_step = function(ctx) {
  return this.visitStep(ctx.step());
};


// Visit a parse tree produced by StepGrammarParser#and_step.
StepGrammarVisitor.prototype.visitAnd_step = function(ctx, left) {
  return new StepAST(STEP_OPERATOR.and, left, this.visitStep(ctx.step()));
};


// Visit a parse tree produced by StepGrammarParser#or_step.
StepGrammarVisitor.prototype.visitOr_step = function(ctx, left) {
  return new StepAST(STEP_OPERATOR.or, left, this.visitStep(ctx.step()));
};


// Visit a parse tree produced by StepGrammarParser#arrow_step.
StepGrammarVisitor.prototype.visitArrow_step = function(ctx, left) {
  return new StepAST(STEP_OPERATOR.arrow, left, this.visitStep(ctx.step()));
};


// Visit a parse tree produced by StepGrammarParser#sequence_step.
StepGrammarVisitor.prototype.visitSequence_step = function(ctx, left) {
  return new StepAST(STEP_OPERATOR.seq, left, this.visitStep(ctx.step()));
};

// Visit a parse tree produced by StepGrammarParser#step.
StepGrammarVisitor.prototype.visitStep = function(ctx) {
  if (ctx.action()) {
    return this.visitAction(ctx.action());
  } else if (ctx.sequence_step()) {
    return this.visitSequence_step(ctx.sequence_step(), this.visitStep(ctx.step()))
  } else if  (ctx.and_step()) {
    return this.visitAnd_step(ctx.and_step(), this.visitStep(ctx.step()));
  } else if (ctx.or_step()) {
    return this.visitOr_step(ctx.or_step(), this.visitStep(ctx.step()));
  } else if (ctx.arrow_step()) {
    return this.visitArrow_step(ctx.arrow_step(), this.visitStep(ctx.step()));
  } else if (ctx.par_step()) {
    return this.visitPar_step(ctx.par_step());
  } 
};


// Visit a parse tree produced by StepGrammarParser#main.
StepGrammarVisitor.prototype.visitMain = function(ctx) {
  return this.visitStep(ctx.step())
};



exports.StepGrammarVisitor = StepGrammarVisitor;