⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toplevelparser.java

📁 Jamon是一个Java文本模板引擎
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        m_root.addSubNode(aliases);        while(true)        {            soakWhitespace();            m_reader.markNodeEnd();            if (readChar('<'))            {                if (!checkToken("/%alias>"))                {                    addError(m_reader.getLocation(), BAD_ALIASES_CLOSE_TAG);                }                soakWhitespace();                return;            }            String name = readChar('/') ? "/" : readIdentifier(false);            if (name.length() == 0)            {                addError(m_reader.getCurrentNodeLocation(),                         "Alias name expected");                return;            }            soakWhitespace();            if (readChar('='))            {                readChar('>'); // support old-style syntax                soakWhitespace();                AbstractPathNode path = parsePath();                if (path.getPathElements().isEmpty())                {                    return;                }                aliases.addAlias(new AliasDefNode(                    m_reader.getCurrentNodeLocation(),                    name,                    path));                if (!readChar(';'))                {                    addError(m_reader.getLocation(), EXPECTING_SEMI);                }            }            else            {                addError(m_reader.getLocation(), EXPECTING_ARROW);            }        }    }    @Override protected void handleAbsMethodTag(Location p_tagLocation)        throws IOException    {        if (soakWhitespace())        {            String name = readIdentifier(true);            checkForTagClosure(p_tagLocation);            AbsMethodNode absMethodNode =                new AbsMethodNode(p_tagLocation, name);            m_root.addSubNode(absMethodNode);            while(true)            {                soakWhitespace();                m_reader.markNodeEnd();                if (readChar('<'))                {                    if (readChar('%'))                    {                        String tagName = readTagName();                        if ("args".equals(tagName))                        {                            try                            {                                absMethodNode.addArgsBlock(                                    new ArgsParser(                                        m_reader, m_errors,                                        m_reader.getCurrentNodeLocation())                                        .getArgsNode());                            }                            catch (ParserError e)                            {                                addError(e);                            }                        }                        else if ("frag".equals(tagName))                        {                            try                            {                                absMethodNode.addArgsBlock(                                    new FragmentArgsParser(                                        m_reader, m_errors,                                        m_reader.getCurrentNodeLocation())                                        .getFragmentArgsNode());                            }                            catch (ParserError e)                            {                                addError(e);                            }                        }                        else                        {                            addError(m_reader.getLocation(),                                     BAD_ABSMETH_CONTENT);                            return;                        }                    }                    else                    {                        if (!checkToken("/%absmeth>"))                        {                            addError(m_reader.getLocation(),                                     BAD_ABS_METHOD_CLOSE_TAG);                        }                        soakWhitespace();                        return;                    }                }                else                {                    addError(m_reader.getLocation(), BAD_ABSMETH_CONTENT);                    return;                }            }        }        else        {            addError(m_reader.getLocation(),                     "malformed <%absmeth methodName> tag");        }    }    @Override protected void handleParentArgsNode(Location p_tagLocation)            throws IOException    {        m_root.addSubNode(            new ParentArgsParser(m_reader, m_errors, p_tagLocation)                .getParentArgsNode());    }    @Override protected void handleParentMarkerTag(Location p_tagLocation)        throws IOException    {        if (checkForTagClosure(p_tagLocation))        {            m_root.addSubNode(new ParentMarkerNode(p_tagLocation));            soakWhitespace();        }    }    @Override protected void handleEof()    {        // end of file is a fine thing at the top level    }    @Override protected void handleEscapeTag(Location p_tagLocation)        throws IOException    {        soakWhitespace();        if (!readChar('#'))        {            addError(m_reader.getNextLocation(), "Expecting '#'");        }        else        {            soakWhitespace();            int c = m_reader.read();            if (Character.isLetter((char) c))            {                m_root.addSubNode(                    new EscapeDirectiveNode(p_tagLocation,                                            new String(new char[] {(char) c})));            }            else            {                addError(m_reader.getLocation(), "Expecting a letter");            }            soakWhitespace();            checkForTagClosure(p_tagLocation);        }        soakWhitespace();    }    @Override protected void handleGenericTag(Location p_tagLocation)        throws IOException    {        m_root.addSubNode(new GenericsParser(m_reader, m_errors, p_tagLocation)            .getGenericsNode());    }    @Override protected void handleAnnotationTag(Location p_tagLocation) throws IOException    {        if(soakWhitespace())        {            try            {                HashEndDetector detector = new HashEndDetector();                String annotations = readJava(p_tagLocation, detector);                AnnotationType annotationType;                if (detector.endedWithHash())                {                    annotationType = readAnnotationType();                    soakWhitespace();                    if (!(readChar('%') && readChar('>')))                    {                        throw new ParserError(p_tagLocation, MALFORMED_ANNOTATE_TAG_ERROR);                    }                }                else                {                    annotationType = AnnotationType.BOTH;                }                m_root.addSubNode(new AnnotationNode(p_tagLocation, annotations, annotationType));            }            catch (ParserError e)            {                addError(e);            }            soakWhitespace();        }        else        {            addError(p_tagLocation, MALFORMED_ANNOTATE_TAG_ERROR);        }    }    private AnnotationType readAnnotationType() throws IOException, ParserError    {        Location location = m_reader.getLocation();        if (readChar('p'))        {            if (checkToken("roxy"))            {                return AnnotationType.PROXY;            }        }        else if (readChar('i'))        {            if (checkToken("mpl"))            {                return AnnotationType.IMPL;            }        }        throw new ParserError(location, UNRECOGNIZED_ANNOTATION_TYPE_ERROR);    }    @Override protected boolean isTopLevel()    {        return true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -