"use strict";
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of Genie
//
// Copyright 2020 The Board of Trustees of the Leland Stanford Junior University
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: Giovanni Campagna <gcampagn@cs.stanford.edu>
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const thingtalk_1 = require("thingtalk");
const C = __importStar(require("../ast_manip"));
async function default_1($runtime, $ttUtils, $options, $locale, $grammar, $loader) {
    $grammar.declareSymbol("forward_get_do_command");
    $grammar.addRule("forward_get_do_command", [new $runtime.Choice(["get", "take", "retrieve"]), new $runtime.NonTerminal("if_filtered_table", undefined), new $runtime.Choice(["and then", "then"]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 1, "implicitParamPassingType"])], (($0, table, $1, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", [new $runtime.NonTerminal("complete_get_command", undefined), new $runtime.Choice(["and then", "then", ","]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 0, "implicitParamPassingType"])], ((table, $0, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", ["after", new $runtime.Choice(["you get", "taking", "getting", "retrieving"]), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 2, "implicitParamPassingType"])], (($0, $1, table, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", [new $runtime.Choice(["get", "take", "retrieve"]), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.Choice(["and then", "then"]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 1, "implicitParamPassingType"])], (($0, table, $1, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", [new $runtime.Choice(["get", "take", "retrieve"]), new $runtime.NonTerminal("projection_Any", undefined), new $runtime.Choice(["and then", "then"]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 1, "projectionType"])], (($0, table, $1, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", ["after", new $runtime.Choice(["you get", "taking", "getting", "retrieving"]), new $runtime.NonTerminal("projection_Any", undefined), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 2, "projectionType"])], (($0, $1, table, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", [new $runtime.Choice(["get", "take", "retrieve"]), new $runtime.NonTerminal("if_filtered_table", undefined), new $runtime.Choice(["and then", "then"]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefFunctionName", 1, "functionName"])], (($0, table, $1, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", [new $runtime.NonTerminal("complete_get_command", undefined), new $runtime.Choice(["and then", "then", ","]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefFunctionName", 0, "functionName"])], ((table, $0, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", ["after", new $runtime.Choice(["you get", "taking", "getting", "retrieving"]), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.NonTerminal("action_coref_same_sentence", ["corefFunctionName", 2, "functionName"])], (($0, $1, table, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_get_do_command", [new $runtime.Choice(["get", "take", "retrieve"]), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.Choice(["and then", "then"]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefFunctionName", 1, "functionName"])], (($0, table, $1, action) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    if (!$options.flags.turking) {
        $grammar.addRule("forward_get_do_command", [new $runtime.NonTerminal("forward_get_do_command", undefined), new $runtime.Choice(["with the same", "with identical", "using the same"]), new $runtime.NonTerminal("out_param_Any", ["functionName", 0, "functionName"])], ((command, $0, joinArg) => C.addSameNameParameterPassing($loader, command, joinArg)), C.expressionKeyFn, {});
    }
    $grammar.declareSymbol("backward_get_do_command");
    $grammar.addRule("backward_get_do_command", [new $runtime.NonTerminal("action_coref_same_sentence", undefined), "after", new $runtime.Choice(["getting", "taking", "you get", "you retrieve"]), new $runtime.NonTerminal("with_filtered_table", ["implicitParamPassingType", 0, "corefType"])], ((action, $0, $1, table) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("backward_get_do_command", [new $runtime.NonTerminal("action_coref_same_sentence", undefined), "after", new $runtime.Choice(["getting", "taking", "you get", "you retrieve"]), new $runtime.NonTerminal("projection_Any", ["projectionType", 0, "corefType"])], ((action, $0, $1, table) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.addRule("backward_get_do_command", [new $runtime.NonTerminal("action_coref_same_sentence", undefined), "after", new $runtime.Choice(["getting", "taking", "you get", "you retrieve"]), new $runtime.NonTerminal("with_filtered_table", ["functionName", 0, "corefFunctionName"])], ((action, $0, $1, table) => C.addParameterPassing(table, action)), C.expressionKeyFn, {});
    $grammar.declareSymbol("forward_when_do_rule");
    $grammar.addRule("forward_when_do_rule", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("complete_action", undefined)], ((stream, action) => C.makeChainExpression(stream, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_when_do_rule", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("complete_action", undefined), "if", new $runtime.NonTerminal("if_filter", ["functionName", 0, "functionName"])], ((stream, action, $0, filter) => {
        const newStream = C.addFilter(stream, filter);
        if (!newStream)
            return null;
        return C.makeChainExpression(newStream, action);
    }), C.expressionKeyFn, {});
    $grammar.addRule("forward_when_do_rule", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 0, "implicitParamPassingType"])], ((stream, action) => C.addParameterPassing(stream, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_when_do_rule", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("action_coref_same_sentence", ["corefFunctionName", 0, "functionName"])], ((stream, action) => C.addParameterPassing(stream, action)), C.expressionKeyFn, {});
    $grammar.addRule("forward_when_do_rule", [new $runtime.Choice(["monitor", "watch", "check for new"]), new $runtime.NonTerminal("with_filtered_table", ["is_monitorable", (true)]), new $runtime.Choice(["and then", "then"]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 1, "implicitParamPassingType"])], (($0, table, $1, action) => {
        const stream = C.tableToStream(table);
        if (!stream)
            return null;
        return C.addParameterPassing(stream, action);
    }), C.expressionKeyFn, {});
    $grammar.addRule("forward_when_do_rule", [new $runtime.Choice(["monitor", "watch"]), new $runtime.NonTerminal("projection_Any", ["is_monitorable", (true)]), new $runtime.Choice(["and then", "then"]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefType", 1, "projectionType"])], (($0, table, $1, action) => {
        const stream = C.tableToStream(table);
        if (!stream)
            return null;
        return C.addParameterPassing(stream, action);
    }), C.expressionKeyFn, {});
    $grammar.addRule("forward_when_do_rule", [new $runtime.Choice(["monitor", "watch", "check for new"]), new $runtime.NonTerminal("with_filtered_table", ["is_monitorable", (true)]), new $runtime.Choice(["and then", "then"]), new $runtime.NonTerminal("action_coref_same_sentence", ["corefFunctionName", 1, "functionName"])], (($0, table, $1, action) => {
        const stream = C.tableToStream(table);
        if (!stream)
            return null;
        return C.addParameterPassing(stream, action);
    }), C.expressionKeyFn, {});
    if (!$options.flags.turking) {
        $grammar.addRule("forward_when_do_rule", [new $runtime.NonTerminal("forward_when_do_rule", undefined), new $runtime.Choice(["with the same", "with identical", "using the same"]), new $runtime.NonTerminal("out_param_Any", ["functionName", 0, "functionName"])], ((rule, $0, joinArg) => C.addSameNameParameterPassing($loader, rule, joinArg)), C.expressionKeyFn, {});
    }
    $grammar.declareSymbol("backward_when_do_rule");
    $grammar.addRule("backward_when_do_rule", [new $runtime.NonTerminal("complete_action", undefined), new $runtime.NonTerminal("stream", undefined)], ((action, stream) => C.makeChainExpression(stream, action)), C.expressionKeyFn, {});
    $grammar.addRule("backward_when_do_rule", [new $runtime.NonTerminal("action_coref_same_sentence", undefined), new $runtime.NonTerminal("stream", ["implicitParamPassingType", 0, "corefType"])], ((action, stream) => C.addParameterPassing(stream, action)), C.expressionKeyFn, {});
    $grammar.addRule("backward_when_do_rule", [new $runtime.NonTerminal("action_coref_same_sentence", undefined), new $runtime.NonTerminal("stream", ["functionName", 0, "corefFunctionName"])], ((action, stream) => C.addParameterPassing(stream, action)), C.expressionKeyFn, {});
    $grammar.addRule("backward_when_do_rule", [new $runtime.NonTerminal("action_coref_same_sentence", undefined), "after checking for new", new $runtime.NonTerminal("complete_table", ["implicitParamPassingType", 0, "corefType"])], ((action, $0, table) => {
        const stream = C.tableToStream(table);
        if (!stream)
            return null;
        return C.addParameterPassing(stream, action);
    }), C.expressionKeyFn, {});
    $grammar.addRule("backward_when_do_rule", [new $runtime.NonTerminal("action_coref_same_sentence", undefined), "after checking for new", new $runtime.NonTerminal("complete_table", ["functionName", 0, "corefFunctionName"])], ((action, $0, table) => {
        const stream = C.tableToStream(table);
        if (!stream)
            return null;
        return C.addParameterPassing(stream, action);
    }), C.expressionKeyFn, {});
    $grammar.declareSymbol("when_get_stream");
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("complete_get_command", undefined)], ((stream, table) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("imperative_verb_for_search", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], ((stream, $0, table) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], ((stream, $0, table) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("imperative_verb_for_search", undefined), new $runtime.Choice(["", "what is"]), new $runtime.NonTerminal("projection_Any", undefined)], ((stream, $0, $1, table) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.Choice(["", "what is"]), new $runtime.NonTerminal("projection_Any", undefined)], ((stream, $0, $1, table) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("complete_get_command", undefined), new $runtime.NonTerminal("stream", undefined)], ((table, stream) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("imperative_verb_for_search", undefined), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.NonTerminal("stream", undefined)], (($0, table, stream) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.NonTerminal("stream", undefined)], (($0, table, stream) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.NonTerminal("stream", undefined)], (($0, table, stream) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("imperative_verb_for_search", undefined), new $runtime.NonTerminal("projection_Any", undefined), new $runtime.NonTerminal("stream", undefined)], (($0, table, stream) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("projection_Any", undefined), new $runtime.NonTerminal("stream", undefined)], (($0, table, stream) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.NonTerminal("projection_Any", undefined), new $runtime.NonTerminal("stream", undefined)], (($0, table, stream) => C.combineStreamQuery($loader, stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("get_command_coref_same_sentence", undefined)], ((stream, table) => C.addParameterPassing(stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("imperative_verb_for_search", undefined), new $runtime.NonTerminal("query_coref_same_sentence", undefined)], ((stream, $0, table) => C.addParameterPassing(stream, table)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_stream", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("query_coref_same_sentence", undefined)], ((stream, $0, table) => C.addParameterPassing(stream, table)), C.expressionKeyFn, {});
    $grammar.declareSymbol("when_get_do_rule");
    $grammar.addRule("when_get_do_rule", [new $runtime.NonTerminal("stream", undefined), new $runtime.NonTerminal("forward_get_do_command", undefined)], ((stream, command) => C.combineStreamCommand(stream, command)), C.expressionKeyFn, {});
    $grammar.addRule("when_get_do_rule", [new $runtime.NonTerminal("forward_get_do_command", undefined), new $runtime.NonTerminal("stream", undefined)], ((command, stream) => C.combineStreamCommand(stream, command)), C.expressionKeyFn, {});
    $grammar.declareSymbol("timer_rule");
    $grammar.addRule("timer_rule", [new $runtime.NonTerminal("timer", undefined), new $runtime.NonTerminal("complete_get_command", undefined)], ((timer, table) => C.makeChainExpression(timer, table)), C.expressionKeyFn, {});
    $grammar.addRule("timer_rule", [new $runtime.NonTerminal("timer", undefined), new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], ((timer, $0, table) => C.makeChainExpression(timer, table)), C.expressionKeyFn, {});
    $grammar.addRule("timer_rule", [new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.NonTerminal("timer", undefined)], (($0, table, timer) => C.makeChainExpression(timer, table)), C.expressionKeyFn, {});
    $grammar.addRule("timer_rule", [new $runtime.NonTerminal("timer", undefined), new $runtime.Choice(["tell me", "give me", "show me", "present", "retrieve", "pull up"]), new $runtime.NonTerminal("with_filtered_table", undefined)], ((timer, $0, table) => C.makeChainExpression(timer, table)), C.expressionKeyFn, {});
    $grammar.addRule("timer_rule", [new $runtime.Choice(["tell me", "give me", "show me", "present", "retrieve", "pull up"]), new $runtime.NonTerminal("with_filtered_table", undefined), new $runtime.NonTerminal("timer", undefined)], (($0, table, timer) => C.makeChainExpression(timer, table)), C.expressionKeyFn, {});
    $grammar.addRule("timer_rule", [new $runtime.NonTerminal("timer", undefined), new $runtime.NonTerminal("complete_action", undefined)], ((timer, action) => C.makeChainExpression(timer, action)), C.expressionKeyFn, {});
    $grammar.addRule("timer_rule", [new $runtime.NonTerminal("generic_preamble_for_action", undefined), new $runtime.NonTerminal("complete_action", undefined), new $runtime.NonTerminal("timer", undefined)], (($0, action, timer) => C.makeChainExpression(timer, action)), C.expressionKeyFn, {});
    if (!$options.flags.primonly) {
        $grammar.addRule("timer_rule", [new $runtime.NonTerminal("timer", undefined), new $runtime.NonTerminal("forward_get_do_command", undefined)], ((timer, command) => C.makeChainExpression(timer, command)), C.expressionKeyFn, {});
    }
    if (!$options.flags.primonly) {
        $grammar.addRule("timer_rule", [new $runtime.NonTerminal("forward_get_do_command", undefined), new $runtime.NonTerminal("timer", undefined)], ((command, timer) => C.makeChainExpression(timer, command)), C.expressionKeyFn, {});
    }
    $grammar.declareSymbol("generic_preamble_for_answer");
    $grammar.addRule("generic_preamble_for_answer", ["i am looking for"], (($0) => "i am looking for"), undefined, { identity: (true) });
    $grammar.addRule("generic_preamble_for_answer", ["i would like"], (($0) => "i would like"), undefined, { identity: (true) });
    $grammar.addRule("generic_preamble_for_answer", ["i want"], (($0) => "i want"), undefined, { identity: (true) });
    $grammar.addRule("generic_preamble_for_answer", ["i need"], (($0) => "i need"), undefined, { identity: (true) });
    $grammar.declareSymbol("generic_preamble_for_action");
    $grammar.addRule("generic_preamble_for_action", ["i am looking to"], (($0) => "i am looking to"), undefined, { identity: (true) });
    $grammar.addRule("generic_preamble_for_action", ["i would like to"], (($0) => "i would like to"), undefined, { identity: (true) });
    $grammar.addRule("generic_preamble_for_action", ["i want to"], (($0) => "i want to"), undefined, { identity: (true) });
    $grammar.addRule("generic_preamble_for_action", ["i need to"], (($0) => "i need to"), undefined, { identity: (true) });
    $grammar.addRule("generic_preamble_for_action", ["please"], (($0) => "please"), undefined, { identity: (true) });
    $grammar.declareSymbol("generic_verb_for_search");
    $grammar.addRule("generic_verb_for_search", ["search for"], (($0) => "search for"), undefined, { identity: (true) });
    $grammar.addRule("generic_verb_for_search", ["search"], (($0) => "search"), undefined, { identity: (true) });
    $grammar.addRule("generic_verb_for_search", ["find"], (($0) => "find"), undefined, { identity: (true) });
    $grammar.addRule("generic_verb_for_search", ["get"], (($0) => "get"), undefined, { identity: (true) });
    $grammar.addRule("generic_verb_for_search", ["retrieve"], (($0) => "retrieve"), undefined, { identity: (true) });
    $grammar.declareSymbol("imperative_verb_for_search");
    $grammar.addRule("imperative_verb_for_search", ["show me"], (($0) => "show me"), undefined, { identity: (true) });
    $grammar.addRule("imperative_verb_for_search", ["tell me"], (($0) => "tell me"), undefined, { identity: (true) });
    $grammar.addRule("imperative_verb_for_search", ["give me"], (($0) => "give me"), undefined, { identity: (true) });
    $grammar.addRule("imperative_verb_for_search", ["find me"], (($0) => "find me"), undefined, { identity: (true) });
    $grammar.declareSymbol("generic_search_preamble");
    $grammar.addRule("generic_search_preamble", ["search"], (($0) => "search"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["find"], (($0) => "find"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["get"], (($0) => "get"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["show me"], (($0) => "show me"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["give me"], (($0) => "give me"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["find me"], (($0) => "find me"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i want"], (($0) => "i want"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i need"], (($0) => "i need"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i am looking for"], (($0) => "i am looking for"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i am looking for a particular"], (($0) => "i am looking for a particular"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i am looking for a certain"], (($0) => "i am looking for a certain"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i would like"], (($0) => "i would like"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i need"], (($0) => "i need"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i need some information about"], (($0) => "i need some information about"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i would like information about"], (($0) => "i would like information about"), undefined, { identity: (true) });
    $grammar.addRule("generic_search_preamble", ["i would like to hear about"], (($0) => "i would like to hear about"), undefined, { identity: (true) });
    $grammar.declareSymbol("generic_lookup_preamble");
    $grammar.addRule("generic_lookup_preamble", ["show me"], (($0) => "show me"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["tell me"], (($0) => "tell me"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["give me"], (($0) => "give me"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["find me"], (($0) => "find me"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["search"], (($0) => "search"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["find"], (($0) => "find"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["i want to know"], (($0) => "i want to know"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["i need to know"], (($0) => "i need to know"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["i am looking for"], (($0) => "i am looking for"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["i would like to know"], (($0) => "i would like to know"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["i would like"], (($0) => "i would like"), undefined, { identity: (true) });
    $grammar.addRule("generic_lookup_preamble", ["i need"], (($0) => "i need"), undefined, { identity: (true) });
    $grammar.declareSymbol("generic_article");
    $grammar.addRule("generic_article", ["a"], (($0) => "a"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["an"], (($0) => "an"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["the"], (($0) => "the"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["some"], (($0) => "some"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["any"], (($0) => "any"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["all"], (($0) => "all"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["all the"], (($0) => "all the"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["every"], (($0) => "every"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["a list of"], (($0) => "a list of"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["a list of all"], (($0) => "a list of all"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["the list of"], (($0) => "the list of"), undefined, { identity: (true) });
    $grammar.addRule("generic_article", ["the list of all"], (($0) => "the list of all"), undefined, { identity: (true) });
    $grammar.declareSymbol("search_command");
    $grammar.addRule("search_command", [new $runtime.NonTerminal("complete_get_command", undefined)], ((table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", ["get", new $runtime.NonTerminal("generic_article", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, $1, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.NonTerminal("generic_article", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, $1, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("generic_article", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, $1, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_preamble_for_action", undefined), new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("generic_article", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, $1, $2, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.Choice(["please", ""]), new $runtime.Choice(["list", "enumerate"]), new $runtime.NonTerminal("with_filtered_table", ["is_list", (true)])], (($0, $1, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_preamble_for_answer", undefined), new $runtime.NonTerminal("generic_article", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, $1, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("generic_article", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, $1, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_preamble_for_action", undefined), new $runtime.NonTerminal("generic_verb_for_search", undefined), new $runtime.NonTerminal("generic_article", undefined), new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, $1, $2, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_preamble_for_answer", undefined), "the", new $runtime.NonTerminal("with_arg_min_max_table", undefined)], (($0, $1, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_verb_for_search", undefined), "the", new $runtime.NonTerminal("with_arg_min_max_table", undefined)], (($0, $1, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_lookup_preamble", undefined), new $runtime.NonTerminal("projection_Any", undefined)], (($0, proj) => C.sayProjection($loader, proj)), C.expressionKeyFn, { weight: (0.45) });
    $grammar.addRule("search_command", [new $runtime.Choice(["show me", "tell me"]), "what is", new $runtime.NonTerminal("projection_Any", undefined)], (($0, $1, proj) => C.sayProjection($loader, proj)), C.expressionKeyFn, { weight: (0.45) });
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_lookup_preamble", undefined), new $runtime.NonTerminal("pair_projection", undefined)], (($0, proj) => C.sayProjection($loader, proj)), C.expressionKeyFn, { weight: (0.1) });
    $grammar.addRule("search_command", [new $runtime.NonTerminal("generic_lookup_preamble", undefined), new $runtime.NonTerminal("command_projection_table", undefined)], (($0, proj) => C.sayProjection($loader, proj)), C.expressionKeyFn, {});
    $grammar.addRule("search_command", [new $runtime.Choice(["show me", "tell me"]), "what is the", new $runtime.NonTerminal("command_projection_table", undefined)], (($0, $1, proj) => C.sayProjection($loader, proj)), C.expressionKeyFn, {});
    $grammar.declareSymbol("complete_question");
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("verb_filtered_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("one_be_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("one_have_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("one_verb_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("two_be_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("two_have_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("two_verb_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.Choice(["are", "is"]), new $runtime.Choice(["the", ""]), new $runtime.NonTerminal("with_filtered_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.Choice(["are", "is"]), new $runtime.Choice(["the", ""]), new $runtime.NonTerminal("one_with_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.Choice(["are", "is"]), new $runtime.Choice(["the", ""]), new $runtime.NonTerminal("one_which_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.Choice(["are", "is"]), new $runtime.Choice(["the", ""]), new $runtime.NonTerminal("one_clean_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.Choice(["are", "is"]), new $runtime.Choice(["the", ""]), new $runtime.NonTerminal("two_with_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.Choice(["are", "is"]), new $runtime.Choice(["the", ""]), new $runtime.NonTerminal("two_which_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.Choice(["are", "is"]), new $runtime.Choice(["the", ""]), new $runtime.NonTerminal("two_clean_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["is", "are"]), "there", new $runtime.Choice(["any", ""]), new $runtime.NonTerminal("with_filtered_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["is", "are"]), "there", new $runtime.Choice(["any", ""]), new $runtime.NonTerminal("one_with_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["is", "are"]), "there", new $runtime.Choice(["any", ""]), new $runtime.NonTerminal("one_which_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["is", "are"]), "there", new $runtime.Choice(["any", ""]), new $runtime.NonTerminal("one_clean_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["is", "are"]), "there", new $runtime.Choice(["any", ""]), new $runtime.NonTerminal("two_with_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["is", "are"]), "there", new $runtime.Choice(["any", ""]), new $runtime.NonTerminal("two_which_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["is", "are"]), "there", new $runtime.Choice(["any", ""]), new $runtime.NonTerminal("two_clean_filter_table", undefined), "?"], (($0, $1, $2, table, $3) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.Choice(["are", "is"]), new $runtime.Choice(["the", ""]), new $runtime.NonTerminal("with_filtered_table_join", undefined)], (($0, $1, $2, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("have_filtered_table_join", undefined)], (($0, table) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["what", "which"]), "is the", new $runtime.NonTerminal("with_arg_min_max_table", undefined), "?"], (($0, $1, table, $2) => table), C.expressionKeyFn, {});
    $grammar.addRule("complete_question", [new $runtime.Choice(["which", "what"]), new $runtime.NonTerminal("have_arg_min_max_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who", "which person", "which individual"]), new $runtime.NonTerminal("who_verb_filtered_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who", "which person", "which individual"]), new $runtime.NonTerminal("who_one_be_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who", "which person", "which individual"]), new $runtime.NonTerminal("who_one_have_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who", "which person", "which individual"]), new $runtime.NonTerminal("who_one_verb_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who", "which person", "which individual"]), new $runtime.NonTerminal("who_two_be_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who", "which person", "which individual"]), new $runtime.NonTerminal("who_two_have_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who", "which person", "which individual"]), new $runtime.NonTerminal("who_two_verb_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who is the person", "who is the one", "who is the individual"]), new $runtime.NonTerminal("who_with_filtered_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who is the person", "who is the one", "who is the individual"]), new $runtime.NonTerminal("who_one_with_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who is the person", "who is the one", "who is the individual"]), new $runtime.NonTerminal("who_one_which_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who is the person", "who is the one", "who is the individual"]), new $runtime.NonTerminal("who_one_clean_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who is the person", "who is the one", "who is the individual"]), new $runtime.NonTerminal("who_two_with_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who is the person", "who is the one", "who is the individual"]), new $runtime.NonTerminal("who_two_which_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", [new $runtime.Choice(["who is the person", "who is the one", "who is the individual"]), new $runtime.NonTerminal("who_two_clean_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("complete_question", ["whose", new $runtime.NonTerminal("whose_filtered_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if ($options.flags.turking) {
        $grammar.addRule("complete_question", ["who", new $runtime.NonTerminal("who_verb_filtered_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if ($options.flags.turking) {
        $grammar.addRule("complete_question", ["who", new $runtime.NonTerminal("who_one_be_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if ($options.flags.turking) {
        $grammar.addRule("complete_question", ["who", new $runtime.NonTerminal("who_one_have_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if ($options.flags.turking) {
        $grammar.addRule("complete_question", ["who", new $runtime.NonTerminal("who_one_verb_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if ($options.flags.turking) {
        $grammar.addRule("complete_question", ["who", new $runtime.NonTerminal("who_two_be_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if ($options.flags.turking) {
        $grammar.addRule("complete_question", ["who", new $runtime.NonTerminal("who_two_have_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if ($options.flags.turking) {
        $grammar.addRule("complete_question", ["who", new $runtime.NonTerminal("who_two_verb_filter_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    if ($options.flags.turking) {
        $grammar.addRule("complete_question", ["whose", new $runtime.NonTerminal("whose_filtered_table", undefined), "?"], (($0, table, $1) => table), C.expressionKeyFn, {});
    }
    $grammar.addRule("complete_question", [new $runtime.NonTerminal("compute_question", undefined)], (($0) => { return $0; }), C.expressionKeyFn, { identity: (true) });
    $grammar.addRule("complete_question", [new $runtime.NonTerminal("where_question", undefined)], (($0) => { return $0; }), C.expressionKeyFn, { identity: (true) });
    $grammar.declareSymbol("projection_question");
    $grammar.addRule("projection_question", ["what is", new $runtime.NonTerminal("projection_Any", undefined), "?"], (($0, proj, $1) => {
        if (proj instanceof thingtalk_1.Ast.ProjectionExpression && proj.schema.getArgType(proj.args[0]) instanceof thingtalk_1.Type.Array)
            return null;
        return C.sayProjection($loader, proj);
    }), C.expressionKeyFn, {});
    $grammar.addRule("projection_question", ["what is", new $runtime.NonTerminal("pair_projection", undefined), "?"], (($0, proj, $1) => {
        if (proj instanceof thingtalk_1.Ast.ProjectionExpression && proj.schema.getArgType(proj.args[0]) instanceof thingtalk_1.Type.Array)
            return null;
        return C.sayProjection($loader, proj);
    }), C.expressionKeyFn, { weight: (0.1) });
    $grammar.addRule("projection_question", ["who is", new $runtime.NonTerminal("projection_Any", ["projectionType", ((new thingtalk_1.Type.Entity('tt:username')))]), "?"], (($0, proj, $1) => {
        if (proj instanceof thingtalk_1.Ast.ProjectionExpression && proj.schema.getArgType(proj.args[0]) instanceof thingtalk_1.Type.Array)
            return null;
        return C.sayProjection($loader, proj);
    }), C.expressionKeyFn, {});
    $grammar.addRule("projection_question", ["who is", new $runtime.NonTerminal("projection_Any", ["projectionType", ((new thingtalk_1.Type.Entity('tt:email_address')))]), "?"], (($0, proj, $1) => {
        if (proj instanceof thingtalk_1.Ast.ProjectionExpression && proj.schema.getArgType(proj.args[0]) instanceof thingtalk_1.Type.Array)
            return null;
        return C.sayProjection($loader, proj);
    }), C.expressionKeyFn, {});
    $grammar.addRule("projection_question", ["what are", new $runtime.NonTerminal("projection_Any", undefined), "?"], (($0, proj, $1) => {
        if (proj instanceof thingtalk_1.Ast.ProjectionExpression && !(proj.schema.getArgType(proj.args[0]) instanceof thingtalk_1.Type.Array))
            return null;
        return C.sayProjection($loader, proj);
    }), C.expressionKeyFn, {});
    $grammar.addRule("projection_question", ["what are", new $runtime.NonTerminal("pair_projection", undefined), "?"], (($0, proj, $1) => {
        if (proj instanceof thingtalk_1.Ast.ProjectionExpression && !(proj.schema.getArgType(proj.args[0]) instanceof thingtalk_1.Type.Array))
            return null;
        return C.sayProjection($loader, proj);
    }), C.expressionKeyFn, { weight: (0.1) });
    $grammar.addRule("projection_question", ["who are", new $runtime.NonTerminal("projection_Any", ["projectionType", ((new thingtalk_1.Type.Entity('tt:username')))]), "?"], (($0, proj, $1) => {
        if (proj instanceof thingtalk_1.Ast.ProjectionExpression && !(proj.schema.getArgType(proj.args[0]) instanceof thingtalk_1.Type.Array))
            return null;
        return C.sayProjection($loader, proj);
    }), C.expressionKeyFn, {});
    $grammar.addRule("projection_question", ["who are", new $runtime.NonTerminal("projection_Any", ["projectionType", ((new thingtalk_1.Type.Entity('tt:email_address')))]), "?"], (($0, proj, $1) => {
        if (proj instanceof thingtalk_1.Ast.ProjectionExpression && !(proj.schema.getArgType(proj.args[0]) instanceof thingtalk_1.Type.Array))
            return null;
        return C.sayProjection($loader, proj);
    }), C.expressionKeyFn, {});
    $grammar.addRule("projection_question", [new $runtime.Choice(["what", "which"]), new $runtime.NonTerminal("verb_projection_Any", undefined), "?"], (($0, proj, $1) => C.sayProjection($loader, proj)), C.expressionKeyFn, {});
    $grammar.addRule("projection_question", [new $runtime.NonTerminal("question_projection_table", undefined), "?"], ((proj, $0) => C.sayProjection($loader, proj)), C.expressionKeyFn, {});
    if ($options.flags.turking) {
        $grammar.addRule("projection_question", ["where is the", new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, table) => C.sayProjection($loader, C.makeSingleFieldProjection($loader, 'table', thingtalk_1.Type.Location, table, 'geo'))), C.expressionKeyFn, {});
    }
    if (!$options.flags.turking) {
        $grammar.addRule("projection_question", ["where", new $runtime.Choice(["is", "are"]), new $runtime.Choice(["", "the"]), new $runtime.NonTerminal("with_filtered_table", undefined)], (($0, $1, $2, table) => C.sayProjection($loader, C.makeSingleFieldProjection($loader, 'table', thingtalk_1.Type.Location, table, 'geo'))), C.expressionKeyFn, {});
    }
    $grammar.addRule("projection_question", [new $runtime.NonTerminal("boolean_projection", undefined), "?"], ((proj, $0) => C.sayProjection($loader, proj)), C.expressionKeyFn, {});
    $grammar.declareSymbol("explicit_when_condition");
    $grammar.addRule("explicit_when_condition", [new $runtime.Choice(["if", "when"]), new $runtime.NonTerminal("if_filter", undefined), "in", new $runtime.NonTerminal("complete_table", ["is_monitorable", (true)])], (($0, filter, $1, table) => {
        if (C.hasGetPredicate(filter.ast))
            return null;
        if (!table.schema.is_monitorable)
            return null;
        if ($loader.flags.turking && table.schema.is_list)
            return null;
        const withFilter = C.addFilter(table, filter, { ifFilter: true });
        if (!withFilter)
            return null;
        return C.tableToStream(withFilter);
    }), C.expressionKeyFn, {});
    $grammar.addRule("explicit_when_condition", [new $runtime.Choice(["if", "when"]), new $runtime.NonTerminal("edge_filter", undefined), "in", new $runtime.NonTerminal("complete_table", ["is_monitorable", (true)])], (($0, filter, $1, table) => {
        if (C.hasGetPredicate(filter.ast))
            return null;
        if (!table.schema.is_monitorable || table.schema.is_list)
            return null;
        const withFilter = C.addFilter(table, filter, { ifFilter: true });
        if (!withFilter)
            return null;
        return C.tableToStream(withFilter);
    }), C.expressionKeyFn, {});
    $grammar.declareSymbol("when_command");
    $grammar.addRule("when_command", ["notify me", new $runtime.NonTerminal("stream", undefined)], (($0, stream) => stream), C.expressionKeyFn, {});
    $grammar.addRule("when_command", [new $runtime.Choice(["alert me", "inform me", "let me know", "i get notified", "i get alerted"]), new $runtime.NonTerminal("stream", undefined)], (($0, stream) => stream), C.expressionKeyFn, {});
    $grammar.addRule("when_command", ["send me", new $runtime.Choice(["a message", "an alert", "a notification", "a pop up notification", "a popup notification"]), new $runtime.NonTerminal("stream", undefined)], (($0, $1, stream) => stream), C.expressionKeyFn, {});
    if (!$options.flags.turking) {
        $grammar.addRule("when_command", [new $runtime.Choice(["let me know", "notify me"]), new $runtime.Choice(["of", "about"]), new $runtime.Choice(["changes", "updates"]), "in", new $runtime.NonTerminal("projection_Any", ["is_monitorable", (true)])], (($0, $1, $2, $3, proj) => C.tableToStream(proj)), C.expressionKeyFn, {});
    }
    if (!$options.flags.nofilter) {
        $grammar.addRule("when_command", [new $runtime.Choice(["alert me", "tell me", "notify me", "let me know"]), new $runtime.NonTerminal("explicit_when_condition", undefined)], (($0, stream) => stream), C.expressionKeyFn, {});
    }
    if (!$options.flags.primonly) {
        $grammar.addRule("when_command", [new $runtime.NonTerminal("when_get_stream", undefined)], (($0) => { return $0; }), C.expressionKeyFn, { identity: (true) });
        $grammar.addRule("when_command", [new $runtime.NonTerminal("forward_when_do_rule", undefined)], (($0) => { return $0; }), C.expressionKeyFn, { identity: (true) });
        $grammar.addRule("when_command", [new $runtime.NonTerminal("backward_when_do_rule", undefined)], (($0) => { return $0; }), C.expressionKeyFn, { identity: (true) });
        if (!$options.flags.turking) {
            $grammar.addRule("when_command", [new $runtime.Choice(["auto", "automatically", "continuously"]), new $runtime.NonTerminal("action_replace_param_with_stream", undefined)], (($0, stmt) => stmt), C.expressionKeyFn, {});
        }
        if ($options.flags.turking) {
            $grammar.addRule("when_command", ["automatically", new $runtime.NonTerminal("action_replace_param_with_stream", undefined)], (($0, stmt) => stmt), C.expressionKeyFn, {});
        }
    }
    if ($options.flags.triple_commands) {
        $grammar.addRule("when_command", [new $runtime.NonTerminal("when_get_do_rule", undefined)], (($0) => { return $0; }), C.expressionKeyFn, { identity: (true) });
    }
    $grammar.declareSymbol("monitor_command");
    $grammar.addRule("monitor_command", [new $runtime.Choice(["monitor", "watch"]), new $runtime.NonTerminal("with_filtered_table", ["is_monitorable", (true)])], (($0, table) => C.tableToStream(table)), C.expressionKeyFn, {});
    $grammar.addRule("monitor_command", [new $runtime.Choice(["monitor", "watch"]), new $runtime.NonTerminal("projection_Any", ["is_monitorable", (true)])], (($0, table) => C.tableToStream(table)), C.expressionKeyFn, {});
    $grammar.addRule("monitor_command", [new $runtime.Choice(["let me know", "notify me"]), new $runtime.Choice(["of", "about"]), new $runtime.Choice(["changes", "updates"]), "in", new $runtime.NonTerminal("if_filtered_table", ["is_monitorable", (true)])], (($0, $1, $2, $3, table) => C.tableToStream(table)), C.expressionKeyFn, {});
    if (!$options.flags.nofilter) {
        $grammar.addRule("monitor_command", [new $runtime.Choice(["monitor", "watch"]), new $runtime.NonTerminal("complete_table", ["is_monitorable", (true)]), "and", new $runtime.Choice(["alert me", "notify me", "inform me", "warn me"]), new $runtime.Choice(["if", "when"]), new $runtime.NonTerminal("if_filter", ["functionName", 1, "functionName"])], (($0, table, $1, $2, $3, filter) => {
            if (C.hasGetPredicate(filter.ast))
                return null;
            if (table.schema.is_list || !table.schema.is_monitorable)
                return null;
            const withFilter = C.addFilter(table, filter);
            if (!withFilter)
                return null;
            return C.tableToStream(withFilter);
        }), C.expressionKeyFn, {});
        $grammar.addRule("monitor_command", [new $runtime.Choice(["monitor", "watch"]), new $runtime.NonTerminal("complete_table", ["is_monitorable", (true)]), "and", new $runtime.Choice(["alert me", "notify me", "inform me", "warn me"]), new $runtime.Choice(["if", "when"]), new $runtime.NonTerminal("if_filter", ["functionName", (null)])], (($0, table, $1, $2, $3, filter) => {
            if (C.hasGetPredicate(filter.ast))
                return null;
            if (table.schema.is_list || !table.schema.is_monitorable)
                return null;
            const withFilter = C.addFilter(table, filter);
            if (!withFilter)
                return null;
            return C.tableToStream(withFilter);
        }), C.expressionKeyFn, {});
    }
    $grammar.declareSymbol("complete_action");
    $grammar.addRule("complete_action", [new $runtime.NonTerminal("thingpedia_complete_action", undefined)], (($0) => { return $0; }), C.expressionKeyFn, { identity: (true) });
    $grammar.addRule("complete_action", [new $runtime.NonTerminal("action_replace_param_with_table", undefined)], (($0) => { return $0; }), C.expressionKeyFn, { identity: (true) });
    $grammar.addRule("complete_action", [new $runtime.NonTerminal("complete_action", undefined), new $runtime.NonTerminal("preposition_input_param", ["functionName", 0, "functionName"])], ((command, param) => C.addActionInputParam($loader, command, param)), C.expressionKeyFn, {});
    $grammar.addRule("complete_action", [new $runtime.NonTerminal("complete_action", undefined), new $runtime.Choice(["with", "having"]), new $runtime.NonTerminal("npp_input_param", ["functionName", 0, "functionName"])], ((command, $0, param) => C.addActionInputParam($loader, command, param)), C.expressionKeyFn, {});
    $grammar.declareSymbol("say_command");
    if ($loader.standardSchemas.say) {
        $grammar.declareSymbol("timer_rule");
        $grammar.addRule("timer_rule", ["send me a reminder", new $runtime.NonTerminal("timer", undefined)], (($0, stream) => C.makeChainExpression(stream, C.builtinSayAction($loader))), C.expressionKeyFn, {});
        $grammar.addRule("timer_rule", ["send me", new $runtime.Choice(["a message", "an alert", "a notification", "a reminder", "a popup notification"]), new $runtime.NonTerminal("timer", undefined), new $runtime.Choice(["saying", "with the text"]), new $runtime.NonTerminal("constant_String", undefined)], (($0, $1, stream, $2, constant) => C.makeChainExpression(stream, C.builtinSayAction($loader, constant))), C.expressionKeyFn, {});
        $grammar.declareSymbol("when_command");
        if (!$options.flags.turking) {
            $grammar.addRule("when_command", ["alert me", new $runtime.NonTerminal("stream", undefined), new $runtime.Choice(["saying", "with the text"]), new $runtime.NonTerminal("constant_String", undefined)], (($0, stream, $1, constant) => C.makeChainExpression(stream, C.builtinSayAction($loader, constant))), C.expressionKeyFn, {});
            $grammar.addRule("when_command", ["show", new $runtime.Choice(["the notification", "the message", "a popup notification that says", "a popup containing"]), new $runtime.NonTerminal("constant_String", undefined), new $runtime.NonTerminal("stream", undefined)], (($0, $1, constant, stream) => C.makeChainExpression(stream, C.builtinSayAction($loader, constant))), C.expressionKeyFn, {});
        }
        $grammar.declareSymbol("say_command");
        $grammar.addRule("say_command", ["say", new $runtime.NonTerminal("constant_String", undefined)], (($0, c) => C.builtinSayAction($loader, c)), C.expressionKeyFn, {});
        $grammar.addRule("say_command", ["send me a message saying", new $runtime.NonTerminal("constant_String", undefined)], (($0, c) => C.builtinSayAction($loader, c)), C.expressionKeyFn, {});
        $grammar.addRule("say_command", ["show a popup that says", new $runtime.NonTerminal("constant_String", undefined)], (($0, c) => C.builtinSayAction($loader, c)), C.expressionKeyFn, {});
    }
}
exports.default = default_1;
;
//# sourceMappingURL=commands.genie.js.map