Package net.mindengine.galen.parser

Examples of net.mindengine.galen.parser.SyntaxException


    }

    @Override
    public Spec processSpec(String specName, String paramsText, String contextPath) {
        if (paramsText == null || paramsText.isEmpty()) {
            throw new SyntaxException(UNKNOWN_LINE, "Missing parameters for spec");
        }
        else {
           
            String []arr = paramsText.split(",");
            List<String> childObjectList = new LinkedList<String>();
View Full Code Here


       
        StringCharReader reader = new StringCharReader(paramsText);
        String objectName = new ExpectWord().read(reader);
       
        if (objectName.isEmpty()) {
            throw new SyntaxException("Missing object name");
        }
       
       
        Integer errorRate = null;
       
        if (reader.hasMore()) {
            String theRest = reader.getTheRest();
            String errorRateText = theRest.replaceAll("\\s", "");
            if (CENTERED_ERROR_RATE_PATTERN.matcher(errorRateText).matches()) {
                errorRate = Integer.parseInt(errorRateText.replace("px", ""));
            }
            else throw new SyntaxException("Incorrect error rate syntax: \"" + theRest + "\"");
        }
        return init.init(specName, objectName, errorRate);
    }
View Full Code Here

    }

    @Override
    public Spec processSpec(String specName, String paramsText, String contextPath) {
        if (paramsText != null && !paramsText.isEmpty()) {
            throw new SyntaxException(UNKNOWN_LINE, "This spec doesn't take any parameters");
        }
        return specInit.init();
    }
View Full Code Here

        Browser browser = browserFactory.openBrowser();

        try {

            if (arguments.getUrl() == null || arguments.getUrl().isEmpty()) {
                throw new SyntaxException("--url parameter is not defined");
            }
            if (arguments.getPaths() == null || arguments.getPaths().size() == 0) {
                throw new SyntaxException("You should specify a spec file with which you want to make a page dump");
            }
            if (arguments.getExport() == null || arguments.getExport().isEmpty()) {
                throw new SyntaxException("--export parameter is not defined");
            }


            if (arguments.getScreenSize() != null) {
                browser.changeWindowSize(arguments.getScreenSize());
View Full Code Here

       
        Table table = null;
        if (!line.isEmpty()) {
            int indexOfFirstSpace = line.indexOf(' ');
            if (indexOfFirstSpace < 0) {
                throw new SyntaxException(getLine(), "Incorrect syntax.");
            }
            String firstWord = line.substring(0, indexOfFirstSpace).toLowerCase();
           
            if (!firstWord.equals("using")) {
                throw new SyntaxException(getLine(), "Unknown statement: " + firstWord);
            }
           
            String leftover = line.substring(indexOfFirstSpace);
               
            String[] tableNames = leftover.split(",");
            for (String tableName : tableNames) {
                String trimmedTableName = tableName.trim();
                if (!trimmedTableName.isEmpty()) {
                    Table contextTable = (Table) context.getValue(trimmedTableName);
                    if (contextTable == null) {
                        throw new SyntaxException(getLine(), format("Table with name \"%s\" does not exist", trimmedTableName));
                    }
                   
                    if (table == null) {
                        table = contextTable;
                    }
                    else {
                        try {
                            table.mergeWith(contextTable);
                        }
                        catch (Exception ex) {
                            throw new SyntaxException(getLine(), format("Cannot merge table \"%s\". Perhaps it has different amount of columns", trimmedTableName));
                        }
                    }
                }
            }
           
            try {
                table.mergeWith(tableFromChild);
            }
            catch (Exception ex) {
                throw new SyntaxException(getLine(), format("Cannot merge in-built table. It probably has different amount of columns then in \"%s\"", line));
            }
           
        }
        else {
            table = tableFromChild;
View Full Code Here

                TableRowNode row = (TableRowNode)childNode;
                try {
                    table.addRow(row.build(context));
                }
                catch (SyntaxException e) {
                    throw new SyntaxException(row.getLine(), e.getMessage());
                }
               
            }
        }
        return table;
View Full Code Here

    @Override
    public List<String> build(VarsContext context) {
        String rowText = getArguments().trim();
       
        if (!rowText.startsWith("|")) {
            throw new SyntaxException(getLine(), "Incorrect format. Should start with '|'");
        }
        if (!rowText.endsWith("|")) {
            throw new SyntaxException(getLine(), "Incorrect format. Should end with '|'");
        }
       
        String[] rawCells = rowText.split("\\|");
       
        List<String> cells = new LinkedList<String>();
        if (rawCells.length > 1) {
            for (int i=1; i<rawCells.length; i++) {
                cells.add(context.process(rawCells[i].trim()));
            }
        }
        else throw new SyntaxException(getLine(), "Incorrect row. Use '|' symbol to split values");
       
        return cells;
    }
View Full Code Here

        return cells;
    }

    @Override
    public Node<?> processNewNode(Line line) {
        throw new SyntaxException(line, "Wrong nesting");
    }
View Full Code Here

        super(line);
    }

    @Override
    public Node<?> processNewNode(Line line) {
        throw new SyntaxException(line, "Incorrect nesting");
    }
View Full Code Here

    public static TextOperation find(String operation) {
        if (_operations.containsKey(operation)) {
            return _operations.get(operation);
        }
        else throw new SyntaxException("Unsupported text operation: " + operation);
    }
View Full Code Here

TOP

Related Classes of net.mindengine.galen.parser.SyntaxException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.