"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const sound_1 = require("../models/sound");
exports.SOUND_GRAMMAR = `
    // TODO: Handle tokens like sfx0 and explicit args instead of just varName (like "Player CantMove up")
    // all of them are at https://www.puzzlescript.net/Documentation/sounds.html
    SoundItem = SoundItemInner lineTerminator+

    SoundItemInner
        = SoundItemEnum
        | SoundItemSfx
        | SoundItemMoveDirection
        | SoundItemMoveSimple
        | SoundItemNormal

    soundItemSimpleOptions
        = t_RESTART
        | t_UNDO
        | t_TITLESCREEN
        | t_STARTGAME
        | t_STARTLEVEL
        | t_ENDLEVEL
        | t_ENDGAME
        | t_SHOWMESSAGE
        | t_CLOSEMESSAGE

    SoundItemEnum = soundItemSimpleOptions integer
    SoundItemSfx = t_SFX integer
    SoundItemMoveDirection = lookupRuleVariableName t_MOVE soundItemActionMoveArg integer
    SoundItemMoveSimple = lookupRuleVariableName t_MOVE integer
    SoundItemNormal = lookupRuleVariableName SoundItemAction integer

    SoundItemAction
        = t_CREATE
        | t_DESTROY
        | t_CANTMOVE

    soundItemActionMoveArg
        = t_UP
        | t_DOWN
        | t_LEFT
        | t_RIGHT
        | t_HORIZONTAL
        | t_VERTICAL
`;
function getSoundSemantics(lookup) {
    return {
        SoundItem(_1, _whitespace) {
            return _1.parse();
        },
        SoundItemEnum(simpleEnum, soundCode) {
            return new sound_1.GameSoundSimpleEnum(this.source, simpleEnum.parse(), soundCode.parse());
        },
        SoundItemSfx(sfxName, soundCode) {
            const soundEffect = sfxName.parse();
            const sound = new sound_1.GameSoundSfx(this.source, soundEffect, soundCode.parse());
            lookup.addSoundEffect(soundEffect, sound);
            return sound;
        },
        SoundItemMoveSimple(sprite, _2, soundCode) {
            return new sound_1.GameSoundMoveSimple(this.source, sprite.parse(), soundCode.parse());
        },
        SoundItemMoveDirection(sprite, _move, directionEnum, soundCode) {
            return new sound_1.GameSoundMoveDirection(this.source, sprite.parse(), directionEnum.parse(), soundCode.parse());
        },
        SoundItemNormal(sprite, eventEnum, soundCode) {
            return new sound_1.GameSoundNormal(this.source, sprite.parse(), eventEnum.parse(), soundCode.parse());
        }
    };
}
exports.getSoundSemantics = getSoundSemantics;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic291bmRHcmFtbWFyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3BhcnNlci9zb3VuZEdyYW1tYXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFDQSwyQ0FPd0I7QUFLWCxRQUFBLGFBQWEsR0FBRzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Q0F5QzVCLENBQUE7QUFFRCxTQUFnQixpQkFBaUIsQ0FBQyxNQUFvQjtJQUNsRCxPQUFPO1FBQ0gsU0FBUyxDQUFpQixFQUF5QixFQUFFLFdBQStCO1lBQ2hGLE9BQU8sRUFBRSxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ3JCLENBQUM7UUFDRCxhQUFhLENBQWlCLFVBQThCLEVBQUUsU0FBNkI7WUFDdkYsT0FBTyxJQUFJLDJCQUFtQixDQUFDLElBQUksQ0FBQyxNQUFNLEVBQUUsVUFBVSxDQUFDLEtBQUssRUFBRSxFQUFFLFNBQVMsQ0FBQyxLQUFLLEVBQUUsQ0FBQyxDQUFBO1FBQ3RGLENBQUM7UUFDRCxZQUFZLENBQWlCLE9BQTJCLEVBQUUsU0FBNkI7WUFDbkYsTUFBTSxXQUFXLEdBQUcsT0FBTyxDQUFDLEtBQUssRUFBRSxDQUFBO1lBQ25DLE1BQU0sS0FBSyxHQUFHLElBQUksb0JBQVksQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLFdBQVcsRUFBRSxTQUFTLENBQUMsS0FBSyxFQUFFLENBQUMsQ0FBQTtZQUMzRSxNQUFNLENBQUMsY0FBYyxDQUFDLFdBQVcsRUFBRSxLQUFLLENB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