class ScenarioParser extends ExtendedParser {

    public final void readStatement() throws ParserException {
        String command = readAlphabetic();
        skipWhitespaces();
        
        if (command.equals("var")) {
            // Variable assignment
            String name = readAlphabetic();
            skipWhitespaces();
            check('=');
            skipWhitespaces();
            float value = readExpression();
            skipWhitespaces();
            check(';');
            super.variables.put(name, value);
        } else {
            // Function call
            ArrayList<Float> parameters = new ArrayList<>();
            check('(');
            while (true) {
                skipWhitespaces();
                parameters.add(readExpression());
                skipWhitespaces();
                if (peek() == ',') {
                    check(',');
                    skipWhitespaces();
                } else {
                    break;
                }
            }
            skipWhitespaces();
            check(')');
            skipWhitespaces();
            check(';');

            if (command.equals("delay")) {
                checkArgumentCount(parameters, 1);
                scenario.addPause(Math.round(parameters.get(0)));
            } else if (command.equals("setRepeat")) {
                checkArgumentCount(parameters, 1);
                scenario.setRepeat(Math.abs(parameters.get(0) - 1) < 0.000001);
            } else if (!commands.containsKey(command)) {
                die("Unknown command: " + command);
            } else {
                scenario.appendRunnable(commands.get(command).create(parameters));
            }
        }
    }

    public  ScenarioParser(String toParse);

}