Examples of PreProcessorException


Examples of org.apache.axis2.corba.exceptions.PreProcessorException

        this.systemIncludePaths = systemIncludePaths;
        this.parentPath = parentPath;
        this.currentFile = parentPath + File.separator + idlFilename;
        InputStream idlStream = getInputStream(parentPath, idlFilename);
        if (idlFilename == null)
            throw new PreProcessorException("Cannot find the file "
                    + parentPath + File.separator + idlFilename);

        idlContent = readIdl(idlStream, 0);
        contentLength = idlContent.length();
    }
View Full Code Here

Examples of org.apache.axis2.corba.exceptions.PreProcessorException

        String lastLine = null;
        while (true) {
            try {
                line = lineNumberReader.readLine();
            } catch (IOException e) {
                throw new PreProcessorException("Error while reading next line"
                        + getLineNoString(lineNumberReader), e);
            }
            if (line == null) {
                break;
            } else if (line.startsWith("#")) {
                line = line.trim();
            }

            if (lastLine != null) {
                line = lastLine + " " + line;
                lastLine = null;
            }

            if (!ifdefValue.empty()
                    && !((Boolean) ifdefValue.peek()).booleanValue()
                    && !line.startsWith("#")) {
                continue;
            } else if (line.startsWith("#") && line.endsWith("\\")) {
                lastLine = line.substring(0, line.lastIndexOf("\\"));
                continue;
            } else if (line.startsWith("#include") && validLine) {
                if (depth < MAX_DEPTH) {
                    String inc = line.replaceAll("#include", "").trim();
                    addComment(buffer, line);
                    InputStream incis = resolveInclude(inc,
                            getLineNoString(lineNumberReader));
                    buffer.append(readIdl(incis, depth + 1));
                    addComment(buffer, "end of " + line);
                } else {
                    throw new PreProcessorException("More than " + MAX_DEPTH
                            + " nested #includes are not allowed"
                            + getLineNoString(lineNumberReader));
                }
            } else if (line.startsWith("#define")) {
                String def = line.replaceAll("#define", "").trim();
                def = def.replaceAll("\"", "");
                StringTokenizer tok = new StringTokenizer(def, " ");
                if (tok.countTokens() == 1) {
                    def = tok.nextToken();
                    if (defs.containsKey(def))
                        throw new PreProcessorException("Variable " + def
                                + " is already defined"
                                + getLineNoString(lineNumberReader));
                    defs.put(def, null);
                } else if (tok.countTokens() == 2) {
                    defs.put(tok.nextToken(), tok.nextToken());
                }
                addComment(buffer, line);
            } else if (line.startsWith("#undef")) {
                String def = line.replaceAll("#undef", "").trim();
                def = def.replaceAll("\"", "");
                if (defs.containsKey(def)) {
                    defs.remove(def);
                } else {
                    throw new PreProcessorException("Undifined variable " + def
                            + getLineNoString(lineNumberReader));
                }
                addComment(buffer, line);
            } else if (line.startsWith("#ifdef")) {
                String def = line.replaceAll("#ifdef", "").trim();
                def = def.replaceAll("\"", "");
                if (defs.containsKey(def)) {
                    ifdefValue.push(Boolean.TRUE);
                } else {
                    validLine = false;
                    ifdefValue.push(Boolean.FALSE);
                }
                elseNotValid = false;
                addComment(buffer, line);
            } else if (line.startsWith("#ifndef")) {
                String def = line.replaceAll("#ifndef", "").trim();
                def = def.replaceAll("\"", "");
                if (defs.containsKey(def)) {
                    validLine = false;
                    ifdefValue.push(Boolean.FALSE);
                } else {
                    ifdefValue.push(Boolean.TRUE);
                }
                elseNotValid = false;
                addComment(buffer, line);
            } else if (line.startsWith("#else")) {
                if (elseNotValid)
                    throw new PreProcessorException("Invalid #else preprocessor directive" + getLineNoString(lineNumberReader));
                   
                // invert last element
                boolean lastval = ((Boolean) ifdefValue.peek()).booleanValue();
                ifdefValue.setElementAt(new Boolean(!lastval), ifdefValue.size() - 1);
                validLine = isAllTrue(ifdefValue);
                elseNotValid = true;
                addComment(buffer, line);
            } else if (line.startsWith("#endif")) {
                if (ifdefValue.empty())
                    throw new PreProcessorException("Invalid #endif preprocessor directive" + getLineNoString(lineNumberReader));
                ifdefValue.pop();
                validLine = isAllTrue(ifdefValue);
                elseNotValid = false;
                addComment(buffer, line);
            } else if (line.startsWith("#")) {
                // TODO: log
                System.out
                        .println("Ignoring unsupported preprocessor directive "
                                + line + getLineNoString(lineNumberReader));
            } else if (validLine) {
                buffer.append(line);
                buffer.append('\n');
                // System.out.println(line);
            }
        }

        if (!ifdefValue.empty()) {
            throw new PreProcessorException(
                    "One or more #ifdef/#ifndef preprocessor directives are not properly closed" + getLineNoString(lineNumberReader));
        }

        try {
            lineNumberReader.close();
View Full Code Here

Examples of org.apache.axis2.corba.exceptions.PreProcessorException

                        currentFile = incFile.getAbsolutePath();
                        return new FileInputStream(incFile);
                    }
                }

                throw new PreProcessorException("Unable to resolve include "
                        + include + lineNoString);

            } else if (include.startsWith("<") && include.startsWith(">")) {
                include = include.replaceAll("<", "");
                include = include.replaceAll(">", "");

                for (int i = 0; i < systemIncludePaths.length; i++) {
                    if (systemIncludePaths[i].endsWith(File.separator)) {
                        incFile = new File(systemIncludePaths[i] + include);
                    } else {
                        incFile = new File(systemIncludePaths[i]
                                + File.separator + include);
                    }
                    if (incFile.exists()) {
                        currentFile = incFile.getAbsolutePath();
                        return new FileInputStream(incFile);
                    }
                }
                throw new PreProcessorException("Unable to resolve include "
                        + include + lineNoString);
            } else {
                throw new PreProcessorException(
                        "Include name must be enclosed in '< >' or '\" \"'"
                                + lineNoString);
            }
        } catch (FileNotFoundException e) {
            throw new PreProcessorException("Unable to resolve include "
                    + include + lineNoString, e);
        }
    }
View Full Code Here

Examples of org.apache.axis2.corba.exceptions.PreProcessorException

                    }
                }
                return null;
            }
        } catch (IOException e) {
            throw new PreProcessorException("Unable to pre-process file " + parent
                    + File.separator + filename, e);
        }
    }
View Full Code Here

Examples of org.apache.axis2.corba.exceptions.PreProcessorException

        this.systemIncludePaths = systemIncludePaths;
        this.parentPath = parentPath;
        this.currentFile = parentPath + File.separator + idlFilename;
        InputStream idlStream = getInputStream(parentPath, idlFilename);
        if (idlFilename == null)
            throw new PreProcessorException("Cannot find the file "
                    + parentPath + File.separator + idlFilename);

        idlContent = readIdl(idlStream, 0);
        contentLength = idlContent.length();
    }
View Full Code Here

Examples of org.apache.axis2.corba.exceptions.PreProcessorException

        String lastLine = null;
        while (true) {
            try {
                line = lineNumberReader.readLine();
            } catch (IOException e) {
                throw new PreProcessorException("Error while reading next line"
                        + getLineNoString(lineNumberReader), e);
            }
            if (line == null) {
                break;
            } else if (line.startsWith("#")) {
                line = line.trim();
            }

            if (lastLine != null) {
                line = lastLine + " " + line;
                lastLine = null;
            }

            if (!ifdefValue.empty()
                    && !((Boolean) ifdefValue.peek()).booleanValue()
                    && !line.startsWith("#")) {
                continue;
            } else if (line.startsWith("#") && line.endsWith("\\")) {
                lastLine = line.substring(0, line.lastIndexOf("\\"));
                continue;
            } else if (line.startsWith("#include") && validLine) {
                if (depth < MAX_DEPTH) {
                    String inc = line.replaceAll("#include", "").trim();
                    addComment(buffer, line);
                    InputStream incis = resolveInclude(inc,
                            getLineNoString(lineNumberReader));
                    buffer.append(readIdl(incis, depth + 1));
                    addComment(buffer, "end of " + line);
                } else {
                    throw new PreProcessorException("More than " + MAX_DEPTH
                            + " nested #includes are not allowed"
                            + getLineNoString(lineNumberReader));
                }
            } else if (line.startsWith("#define")) {
                String def = line.replaceAll("#define", "").trim();
                def = def.replaceAll("\"", "");
                StringTokenizer tok = new StringTokenizer(def, " ");
                if (tok.countTokens() == 1) {
                    def = tok.nextToken();
                    if (defs.containsKey(def))
                        throw new PreProcessorException("Variable " + def
                                + " is already defined"
                                + getLineNoString(lineNumberReader));
                    defs.put(def, null);
                } else if (tok.countTokens() == 2) {
                    defs.put(tok.nextToken(), tok.nextToken());
                }
                addComment(buffer, line);
            } else if (line.startsWith("#undef")) {
                String def = line.replaceAll("#undef", "").trim();
                def = def.replaceAll("\"", "");
                if (defs.containsKey(def)) {
                    defs.remove(def);
                } else {
                    throw new PreProcessorException("Undifined variable " + def
                            + getLineNoString(lineNumberReader));
                }
                addComment(buffer, line);
            } else if (line.startsWith("#ifdef")) {
                String def = line.replaceAll("#ifdef", "").trim();
                def = def.replaceAll("\"", "");
                if (defs.containsKey(def)) {
                    ifdefValue.push(Boolean.TRUE);
                } else {
                    validLine = false;
                    ifdefValue.push(Boolean.FALSE);
                }
                elseNotValid = false;
                addComment(buffer, line);
            } else if (line.startsWith("#ifndef")) {
                String def = line.replaceAll("#ifndef", "").trim();
                def = def.replaceAll("\"", "");
                if (defs.containsKey(def)) {
                    validLine = false;
                    ifdefValue.push(Boolean.FALSE);
                } else {
                    ifdefValue.push(Boolean.TRUE);
                }
                elseNotValid = false;
                addComment(buffer, line);
            } else if (line.startsWith("#else")) {
                if (elseNotValid)
                    throw new PreProcessorException("Invalid #else preprocessor directive" + getLineNoString(lineNumberReader));
                   
                // invert last element
                boolean lastval = ((Boolean) ifdefValue.peek()).booleanValue();
                ifdefValue.setElementAt(new Boolean(!lastval), ifdefValue.size() - 1);
                validLine = isAllTrue(ifdefValue);
                elseNotValid = true;
                addComment(buffer, line);
            } else if (line.startsWith("#endif")) {
                if (ifdefValue.empty())
                    throw new PreProcessorException("Invalid #endif preprocessor directive" + getLineNoString(lineNumberReader));
                ifdefValue.pop();
                validLine = isAllTrue(ifdefValue);
                elseNotValid = false;
                addComment(buffer, line);
            } else if (line.startsWith("#")) {
                // TODO: log
                System.out
                        .println("Ignoring unsupported preprocessor directive "
                                + line + getLineNoString(lineNumberReader));
            } else if (validLine) {
                buffer.append(line);
                buffer.append('\n');
                // System.out.println(line);
            }
        }

        if (!ifdefValue.empty()) {
            throw new PreProcessorException(
                    "One or more #ifdef/#ifndef preprocessor directives are not properly closed" + getLineNoString(lineNumberReader));
        }

        try {
            lineNumberReader.close();
View Full Code Here

Examples of org.apache.axis2.corba.exceptions.PreProcessorException

                        currentFile = incFile.getAbsolutePath();
                        return new FileInputStream(incFile);
                    }
                }

                throw new PreProcessorException("Unable to resolve include "
                        + include + lineNoString);

            } else if (include.startsWith("<") && include.endsWith(">")) {
                include = include.replaceAll("<", "");
                include = include.replaceAll(">", "");

                for (int i = 0; i < systemIncludePaths.length; i++) {
                    if (systemIncludePaths[i].endsWith(File.separator)) {
                        incFile = new File(systemIncludePaths[i] + include);
                    } else {
                        incFile = new File(systemIncludePaths[i]
                                + File.separator + include);
                    }
                    if (incFile.exists()) {
                        currentFile = incFile.getAbsolutePath();
                        return new FileInputStream(incFile);
                    }
                }
                throw new PreProcessorException("Unable to resolve include "
                        + include + lineNoString);
            } else {
                throw new PreProcessorException(
                        "Include name must be enclosed in '< >' or '\" \"'"
                                + lineNoString);
            }
        } catch (FileNotFoundException e) {
            throw new PreProcessorException("Unable to resolve include "
                    + include + lineNoString, e);
        }
    }
View Full Code Here

Examples of org.apache.axis2.corba.exceptions.PreProcessorException

                    }
                }
                return null;
            }
        } catch (IOException e) {
            throw new PreProcessorException("Unable to pre-process file " + parent
                    + File.separator + filename, e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.