"use strict";
// -*- mode: js; indent-tabs-mode: nil; js-basic-offset: 4 -*-
//
// This file is part of Genie
//
// Copyright 2019-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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const thingtalk_1 = require("thingtalk");
const C = __importStar(require("../ast_manip"));
async function default_1($runtime, $ttUtils, $options, $locale, $grammar, $loader) {
    $grammar.declareSymbol("constant_Number");
    if (!$options.flags.inference) {
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Number", ["zero"], (($0) => new thingtalk_1.Ast.Value.Number(0)), C.entityOrNumberValueKeyFn, {});
            $grammar.addRule("constant_Number", ["one"], (($0) => new thingtalk_1.Ast.Value.Number(1)), C.entityOrNumberValueKeyFn, {});
        }
    }
    $grammar.declareSymbol("constant_date_point");
    $grammar.addRule("constant_date_point", ["now"], (($0) => C.makeDate(null, '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_date_point", ["today"], (($0) => C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'day'), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_date_point", ["yesterday"], (($0) => C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'day'), '-', new thingtalk_1.Ast.Value.Measure(1, 'day'))), C.valueKeyFn, {});
    if (!$options.flags.turking) {
        if ($options.flags.future_dates) {
            $grammar.addRule("constant_date_point", ["tomorrow"], (($0) => C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'day'), '+', null)), C.valueKeyFn, {});
            $grammar.addRule("constant_date_point", ["the end of the day"], (($0) => C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'day'), '+', null)), C.valueKeyFn, {});
            $grammar.addRule("constant_date_point", ["the end of the week"], (($0) => C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'week'), '+', null)), C.valueKeyFn, {});
            $grammar.addRule("constant_date_point", ["the end of the month"], (($0) => C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'mon'), '+', null)), C.valueKeyFn, {});
            $grammar.addRule("constant_date_point", ["the end of the year"], (($0) => C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'year'), '+', null)), C.valueKeyFn, {});
        }
    }
    $grammar.declareSymbol("constant_date_range");
    $grammar.addRule("constant_date_range", ["this week"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'week'), '+', null), C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'week'), '+', null)]), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["this month"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'mon'), '+', null), C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'mon'), '+', null)]), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["this year"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'year'), '+', null), C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'year'), '+', null)]), C.valueArrayKeyFn, {});
    if (!$options.flags.turking) {
        $grammar.addRule("constant_date_range", ["last week"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'week'), '-', new thingtalk_1.Ast.Value.Measure(1, 'week')), C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'week'), '+', null)]), C.valueArrayKeyFn, {});
        $grammar.addRule("constant_date_range", ["last month"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'mon'), '-', new thingtalk_1.Ast.Value.Measure(1, 'mon')), C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'mon'), '+', null)]), C.valueArrayKeyFn, {});
        $grammar.addRule("constant_date_range", ["last year"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'year'), '-', new thingtalk_1.Ast.Value.Measure(1, 'year')), C.makeDate(new thingtalk_1.Ast.DateEdge('start_of', 'year'), '+', null)]), C.valueArrayKeyFn, {});
        if ($options.flags.future_dates) {
            $grammar.addRule("constant_date_range", ["next week"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'week'), '+', null), C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'week'), '+', new thingtalk_1.Ast.Value.Measure(1, 'week'))]), C.valueArrayKeyFn, {});
            $grammar.addRule("constant_date_range", ["next month"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'mon'), '+', null), C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'mon'), '+', new thingtalk_1.Ast.Value.Measure(1, 'mon'))]), C.valueArrayKeyFn, {});
            $grammar.addRule("constant_date_range", ["next year"], (($0) => [C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'year'), '+', null), C.makeDate(new thingtalk_1.Ast.DateEdge('end_of', 'year'), '+', new thingtalk_1.Ast.Value.Measure(1, 'year'))]), C.valueArrayKeyFn, {});
        }
        $grammar.addRule("constant_date_range", [new $runtime.NonTerminal("constant_Number", undefined)], ((year) => {
            if (year.value <= 0)
                return null;
            return [
                C.makeDate(new Date(C.fixTwoYearNumber(year.value), 0), '+', null),
                C.makeDate(new Date(C.fixTwoYearNumber(year.value), 0), '+', new thingtalk_1.Ast.Value.Measure(1, 'year'))
            ];
        }), C.valueArrayKeyFn, {});
        $grammar.addRule("constant_date_range", [new $runtime.NonTerminal("constant_Number", undefined), "s"], ((year, $0) => {
            if (year.value <= 0)
                return null;
            return [
                C.makeDate(new Date(C.fixTwoYearNumber(year.value), 0), '+', null),
                C.makeDate(new Date(C.fixTwoYearNumber(year.value), 0), '+', new thingtalk_1.Ast.Value.Measure(10, 'year'))
            ];
        }), C.valueArrayKeyFn, {});
    }
    $grammar.addRule("constant_date_range", ["jan"], (($0) => C.makeMonthDateRange(null, 1)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["january"], (($0) => C.makeMonthDateRange(null, 1)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["jan", "january"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 1)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["feb"], (($0) => C.makeMonthDateRange(null, 2)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["february"], (($0) => C.makeMonthDateRange(null, 2)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["feb", "february"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 2)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["mar"], (($0) => C.makeMonthDateRange(null, 3)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["march"], (($0) => C.makeMonthDateRange(null, 3)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["mar", "march"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 3)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["apr"], (($0) => C.makeMonthDateRange(null, 4)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["april"], (($0) => C.makeMonthDateRange(null, 4)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["apr", "april"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 4)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["may"], (($0) => C.makeMonthDateRange(null, 5)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["may of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, year) => C.makeMonthDateRange(year.value, 5)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["jun"], (($0) => C.makeMonthDateRange(null, 6)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["june"], (($0) => C.makeMonthDateRange(null, 6)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["jun", "june"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 6)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["jul"], (($0) => C.makeMonthDateRange(null, 7)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["july"], (($0) => C.makeMonthDateRange(null, 7)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["jul", "july"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 7)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["aug"], (($0) => C.makeMonthDateRange(null, 8)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["august"], (($0) => C.makeMonthDateRange(null, 8)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["aug", "august"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 8)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["sep"], (($0) => C.makeMonthDateRange(null, 9)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["sept"], (($0) => C.makeMonthDateRange(null, 9)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["september"], (($0) => C.makeMonthDateRange(null, 9)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["sep", "sept", "september"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 9)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["oct"], (($0) => C.makeMonthDateRange(null, 10)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["october"], (($0) => C.makeMonthDateRange(null, 10)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["oct", "october"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 10)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["nov"], (($0) => C.makeMonthDateRange(null, 11)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["november"], (($0) => C.makeMonthDateRange(null, 11)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["nov", "november"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 11)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["dec"], (($0) => C.makeMonthDateRange(null, 12)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", ["december"], (($0) => C.makeMonthDateRange(null, 12)), C.valueArrayKeyFn, {});
    $grammar.addRule("constant_date_range", [new $runtime.Choice(["dec", "december"]), "of", new $runtime.NonTerminal("constant_Number", undefined)], (($0, $1, year) => C.makeMonthDateRange(year.value, 12)), C.valueArrayKeyFn, {});
    $grammar.declareSymbol("constant_day_of_week");
    $grammar.addRule("constant_day_of_week", ["mon"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('monday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["monday"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('monday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["last", new $runtime.Choice(["mon", "monday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('monday', null), '-', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["next", new $runtime.Choice(["mon", "monday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('monday', null), '+', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["tue"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('tuesday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["tuesday"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('tuesday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["last", new $runtime.Choice(["tue", "tuesday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('tuesday', null), '-', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["next", new $runtime.Choice(["tue", "tuesday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('tuesday', null), '+', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["wed"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('wednesday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["wednesday"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('wednesday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["last", new $runtime.Choice(["wed", "wednesday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('wednesday', null), '-', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["next", new $runtime.Choice(["wed", "wednesday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('wednesday', null), '+', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["thu"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('thursday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["thursday"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('thursday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["last", new $runtime.Choice(["thu", "thursday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('thursday', null), '-', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["next", new $runtime.Choice(["thu", "thursday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('thursday', null), '+', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["fri"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('friday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["friday"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('friday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["last", new $runtime.Choice(["fri", "friday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('friday', null), '-', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["next", new $runtime.Choice(["fri", "friday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('friday', null), '+', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["sat"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('saturday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["saturday"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('saturday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["last", new $runtime.Choice(["sat", "saturday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('saturday', null), '-', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["next", new $runtime.Choice(["sat", "saturday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('saturday', null), '+', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["sun"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('sunday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["sunday"], (($0) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('sunday', null), '+', null)), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["last", new $runtime.Choice(["sun", "sunday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('sunday', null), '-', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.addRule("constant_day_of_week", ["next", new $runtime.Choice(["sun", "sunday"])], (($0, $1) => C.makeDate(new thingtalk_1.Ast.WeekDayDate('sunday', null), '+', new thingtalk_1.Ast.Value.Measure(1, 'week'))), C.valueKeyFn, {});
    $grammar.declareSymbol("constant_Date");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Date", [new $runtime.NonTerminal("constant_date_point", undefined)], (($0) => { return $0; }), C.valueKeyFn, { identity: (true) });
        $grammar.addRule("constant_Date", [new $runtime.NonTerminal("constant_day_of_week", undefined)], (($0) => { return $0; }), C.valueKeyFn, { identity: (true) });
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Date", [new $runtime.NonTerminal("constant_Measure_ms", undefined), "ago"], ((duration, $0) => C.makeDate(null, '-', duration)), C.valueKeyFn, {});
            $grammar.addRule("constant_Date", [new $runtime.NonTerminal("constant_Measure_ms", undefined), "before", new $runtime.NonTerminal("constant_date_point", undefined)], ((duration, $0, pt) => C.makeDate(pt, '-', duration)), C.valueKeyFn, {});
            if ($options.flags.future_dates) {
                $grammar.addRule("constant_Date", [new $runtime.NonTerminal("constant_Measure_ms", undefined), "from now"], ((duration, $0) => C.makeDate(null, '+', duration)), C.valueKeyFn, {});
                $grammar.addRule("constant_Date", [new $runtime.NonTerminal("constant_Measure_ms", undefined), "after", new $runtime.NonTerminal("constant_date_point", undefined)], ((duration, $0, pt) => C.makeDate(pt, '+', duration)), C.valueKeyFn, {});
            }
        }
    }
    $grammar.declareSymbol("constant_Measure_ms");
    if (!$options.flags.inference) {
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "ms"], ((num, $0) => C.addUnit('ms', num)), C.valueKeyFn, {});
        }
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "milliseconds"], ((num, $0) => C.addUnit('ms', num)), C.valueKeyFn, {});
        }
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "s"], ((num, $0) => C.addUnit('s', num)), C.valueKeyFn, {});
        }
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "seconds"], ((num, $0) => C.addUnit('s', num)), C.valueKeyFn, {});
        }
        $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "min"], ((num, $0) => C.addUnit('min', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "minutes"], ((num, $0) => C.addUnit('min', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "h"], ((num, $0) => C.addUnit('h', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "hours"], ((num, $0) => C.addUnit('h', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "days"], ((num, $0) => C.addUnit('day', num)), C.valueKeyFn, {});
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "weeks"], ((num, $0) => C.addUnit('week', num)), C.valueKeyFn, {});
        }
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "months"], ((num, $0) => C.addUnit('mon', num)), C.valueKeyFn, {});
        }
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_ms", [new $runtime.NonTerminal("constant_Number", undefined), "years"], ((num, $0) => C.addUnit('year', num)), C.valueKeyFn, {});
        }
    }
    $grammar.declareSymbol("constant_Measure_byte");
    if (!$options.flags.inference) {
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "byte"], ((num, $0) => C.addUnit('byte', num)), C.valueKeyFn, {});
        }
        $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "kb"], ((num, $0) => C.addUnit('KB', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "mb"], ((num, $0) => C.addUnit('MB', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "gb"], ((num, $0) => C.addUnit('GB', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "tb"], ((num, $0) => C.addUnit('TB', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "kilobytes"], ((num, $0) => C.addUnit('KB', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "megabytes"], ((num, $0) => C.addUnit('MB', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "gigabytes"], ((num, $0) => C.addUnit('GB', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_byte", [new $runtime.NonTerminal("constant_Number", undefined), "terabytes"], ((num, $0) => C.addUnit('TB', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_kg");
    if (!$options.flags.inference) {
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_kg", [new $runtime.NonTerminal("constant_Number", undefined), "grams"], ((num, $0) => C.addUnit('g', num)), C.valueKeyFn, {});
        }
        $grammar.addRule("constant_Measure_kg", [new $runtime.NonTerminal("constant_Number", undefined), "kilograms"], ((num, $0) => C.addUnit('kg', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_kg", [new $runtime.NonTerminal("constant_Number", undefined), "kg"], ((num, $0) => C.addUnit('kg', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_kg", [new $runtime.NonTerminal("constant_Number", undefined), "pounds"], ((num, $0) => C.addUnit('lb', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_kg", [new $runtime.NonTerminal("constant_Number", undefined), "lbs"], ((num, $0) => C.addUnit('lb', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_kg", [new $runtime.NonTerminal("constant_Number", undefined), "ounces"], ((num, $0) => C.addUnit('oz', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_kg", [new $runtime.NonTerminal("constant_Number", undefined), "oz"], ((num, $0) => C.addUnit('oz', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_C");
    if (!$options.flags.inference) {
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_C", [new $runtime.NonTerminal("constant_Number", undefined), "c"], ((num, $0) => C.addUnit('C', num)), C.valueKeyFn, {});
            $grammar.addRule("constant_Measure_C", [new $runtime.NonTerminal("constant_Number", undefined), "centigrade"], ((num, $0) => C.addUnit('C', num)), C.valueKeyFn, {});
        }
        $grammar.addRule("constant_Measure_C", [new $runtime.NonTerminal("constant_Number", undefined), "f"], ((num, $0) => C.addUnit('F', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_C", [new $runtime.NonTerminal("constant_Number", undefined), "fahrenheit"], ((num, $0) => C.addUnit('F', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_C", [new $runtime.NonTerminal("constant_Number", undefined), "degrees"], ((num, $0) => C.addUnit('defaultTemperature', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_m");
    if (!$options.flags.inference) {
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "m"], ((num, $0) => C.addUnit('m', num)), C.valueKeyFn, {});
        }
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "meters"], ((num, $0) => C.addUnit('m', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "km"], ((num, $0) => C.addUnit('km', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "kilometers"], ((num, $0) => C.addUnit('km', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "mi"], ((num, $0) => C.addUnit('mi', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "miles"], ((num, $0) => C.addUnit('mi', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "ft"], ((num, $0) => C.addUnit('ft', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "in"], ((num, $0) => C.addUnit('in', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "inches"], ((num, $0) => C.addUnit('in', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m", [new $runtime.NonTerminal("constant_Number", undefined), "cm"], ((num, $0) => C.addUnit('cm', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_m2");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Measure_m2", [new $runtime.NonTerminal("constant_Number", undefined), "square meters"], ((num, $0) => C.addUnit('m2', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m2", [new $runtime.NonTerminal("constant_Number", undefined), "square km"], ((num, $0) => C.addUnit('km2', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m2", [new $runtime.NonTerminal("constant_Number", undefined), "square kilometers"], ((num, $0) => C.addUnit('km2', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m2", [new $runtime.NonTerminal("constant_Number", undefined), "square ft"], ((num, $0) => C.addUnit('ft2', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m2", [new $runtime.NonTerminal("constant_Number", undefined), "square feet"], ((num, $0) => C.addUnit('ft2', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_m3");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "cubic meters"], ((num, $0) => C.addUnit('m3', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "cubic km"], ((num, $0) => C.addUnit('km3', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "cubic kilometers"], ((num, $0) => C.addUnit('km3', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "cubic ft"], ((num, $0) => C.addUnit('ft3', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "cubic feet"], ((num, $0) => C.addUnit('ft3', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "liter"], ((num, $0) => C.addUnit('l', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "l"], ((num, $0) => C.addUnit('l', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "cl"], ((num, $0) => C.addUnit('cl', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "hl"], ((num, $0) => C.addUnit('hl', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "ml"], ((num, $0) => C.addUnit('ml', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "floz"], ((num, $0) => C.addUnit('floz', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "gallon"], ((num, $0) => C.addUnit('gal', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "quart"], ((num, $0) => C.addUnit('qt', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "pint"], ((num, $0) => C.addUnit('pint', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "cup"], ((num, $0) => C.addUnit('cup', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "teaspoon"], ((num, $0) => C.addUnit('tsp', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_m3", [new $runtime.NonTerminal("constant_Number", undefined), "tablespoon"], ((num, $0) => C.addUnit('tbsp', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_mps");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Measure_mps", [new $runtime.NonTerminal("constant_Number", undefined), "mph"], ((num, $0) => C.addUnit('mph', num)), C.valueKeyFn, {});
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Measure_mps", [new $runtime.NonTerminal("constant_Number", undefined), "m/s"], ((num, $0) => C.addUnit('mps', num)), C.valueKeyFn, {});
        }
        $grammar.addRule("constant_Measure_mps", [new $runtime.NonTerminal("constant_Number", undefined), "kph"], ((num, $0) => C.addUnit('kmph', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_mps", [new $runtime.NonTerminal("constant_Number", undefined), "miles per hour"], ((num, $0) => C.addUnit('mph', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_mps", [new $runtime.NonTerminal("constant_Number", undefined), "kilometers per hour"], ((num, $0) => C.addUnit('kmph', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_mps", [new $runtime.NonTerminal("constant_Number", undefined), "km/h"], ((num, $0) => C.addUnit('kmph', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_W");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Measure_W", [new $runtime.NonTerminal("constant_Number", undefined), "w"], ((num, $0) => C.addUnit('W', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_W", [new $runtime.NonTerminal("constant_Number", undefined), "watt"], ((num, $0) => C.addUnit('W', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_W", [new $runtime.NonTerminal("constant_Number", undefined), "kw"], ((num, $0) => C.addUnit('kW', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_W", [new $runtime.NonTerminal("constant_Number", undefined), "kilowatt"], ((num, $0) => C.addUnit('W', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_lx");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Measure_lx", [new $runtime.NonTerminal("constant_Number", undefined), "lx"], ((num, $0) => C.addUnit('lx', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_lm");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Measure_lm", [new $runtime.NonTerminal("constant_Number", undefined), "lm"], ((num, $0) => C.addUnit('lm', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_dB");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Measure_dB", [new $runtime.NonTerminal("constant_Number", undefined), "db"], ((num, $0) => C.addUnit('dB', num)), C.valueKeyFn, {});
        $grammar.addRule("constant_Measure_dB", [new $runtime.NonTerminal("constant_Number", undefined), "decibels"], ((num, $0) => C.addUnit('dB', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Measure_dBm");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Measure_dBm", [new $runtime.NonTerminal("constant_Number", undefined), "dbm"], ((num, $0) => C.addUnit('dBm', num)), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_Location");
    if (!$options.flags.inference) {
        $grammar.addRule("constant_Location", ["here"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('current_location'))), C.valueKeyFn, {});
        if (!$options.flags.turking) {
            $grammar.addRule("constant_Location", ["where i am now"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('current_location'))), C.valueKeyFn, {});
        }
        $grammar.addRule("constant_Location", ["the area"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('current_location'))), C.valueKeyFn, {});
        $grammar.addRule("constant_Location", ["the city"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('current_location'))), C.valueKeyFn, {});
        $grammar.addRule("constant_Location", ["home"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('home'))), C.valueKeyFn, {});
        $grammar.addRule("constant_Location", ["my home"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('home'))), C.valueKeyFn, {});
        $grammar.addRule("constant_Location", ["my neighborhood"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('home'))), C.valueKeyFn, {});
        $grammar.addRule("constant_Location", ["work"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('work'))), C.valueKeyFn, {});
        $grammar.addRule("constant_Location", ["my office"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('work'))), C.valueKeyFn, {});
        $grammar.addRule("constant_Location", ["my workplace"], (($0) => new thingtalk_1.Ast.Value.Location(new thingtalk_1.Ast.Location.Relative('work'))), C.valueKeyFn, {});
    }
    $grammar.declareSymbol("constant_pairs");
    $grammar.addRule("constant_pairs", [new $runtime.NonTerminal("constant_Any", undefined), "and", new $runtime.NonTerminal("constant_Any", ["type", 0, "type"])], ((c1, $0, c2) => {
        assert_1.default(c1.getType().equals(c2.getType()));
        if (c1.equals(c2))
            return null;
        return [c1, c2];
    }), C.valueArrayKeyFn, {});
    $grammar.declareSymbol("constant_or_pairs");
    $grammar.addRule("constant_or_pairs", [new $runtime.NonTerminal("constant_Any", undefined), "or", new $runtime.NonTerminal("constant_Any", ["type", 0, "type"])], ((c1, $0, c2) => {
        assert_1.default(c1.getType().equals(c2.getType()));
        if (c1.equals(c2))
            return null;
        return [c1, c2];
    }), C.valueArrayKeyFn, {});
    $grammar.declareSymbol("constant_nor_pairs");
    $grammar.addRule("constant_nor_pairs", [new $runtime.NonTerminal("constant_Any", undefined), "nor", new $runtime.NonTerminal("constant_Any", ["type", 0, "type"])], ((c1, $0, c2) => {
        assert_1.default(c1.getType().equals(c2.getType()));
        if (c1.equals(c2))
            return null;
        return [c1, c2];
    }), C.valueArrayKeyFn, {});
    $grammar.declareSymbol("constant_String_ContextRef");
    if ($options.flags.screen_selection) {
        $grammar.addRule("constant_String_ContextRef", ["this"], (($0) => new thingtalk_1.Ast.Value.ContextRef('selection', thingtalk_1.Type.String)), C.valueKeyFn, {});
    }
    if ($options.flags.screen_selection) {
        $grammar.addRule("constant_String_ContextRef", ["the selection on the screen"], (($0) => new thingtalk_1.Ast.Value.ContextRef('selection', thingtalk_1.Type.String)), C.valueKeyFn, {});
    }
}
exports.default = default_1;
;
//# sourceMappingURL=constants.genie.js.map