src/com/christofferklang/pyxl/parsing/PyxlExpressionParsing.java
private String parseQualifiedPyxlTagName(String requiredQualifiedName,
                                             PsiBuilder.Marker callExpressionMarker,
                                             PsiBuilder.Marker tagStartMarker) throws PyxlParsingException {
        final IElementType token = myBuilder.getTokenType();

        String fullQualifiedName = myBuilder.getTokenText();

        // Module qualifiers are straight up python identifiers followed by a dot
        if (token == PyxlTokenTypes.TAGNAME_MODULE) {
            if (callExpressionMarker == null) callExpressionMarker = myBuilder.mark();
            if (tagStartMarker == null) tagStartMarker = myBuilder.mark();
            PsiBuilder.Marker moduleExpression = myBuilder.mark();
            myBuilder.advanceLexer();
            moduleExpression.done(PyxlElementTypes.MODULE_REFERENCE);
            if (myBuilder.getTokenType() != PyTokenTypes.DOT) {
                throw new PyxlParsingException();
            } else {
                myBuilder.advanceLexer();
            }
            fullQualifiedName = fullQualifiedName + "." +
                    parseQualifiedPyxlTagName(null, callExpressionMarker, tagStartMarker);
        } else if (token == PyxlTokenTypes.TAGNAME) {
            // pyxl expands <p><c /></p> to x_p()(x_c());
            // so in order to get the same semantics as the corresponding python would have, we fake a call to the init
            // function of the pyxl tag class here.

            if (callExpressionMarker == null) callExpressionMarker = myBuilder.mark();
            if (tagStartMarker == null) tagStartMarker = myBuilder.mark();
            myBuilder.advanceLexer();
            tagStartMarker.done(PyxlElementTypes.TAG_REFERENCE);
            callExpressionMarker.done(PyElementTypes.CALL_EXPRESSION);
        } else if (token == PyxlTokenTypes.BUILT_IN_TAG) {
            myBuilder.advanceLexer();
        } else {
            throw new PyxlParsingException();
        }

        if (requiredQualifiedName != null && !requiredQualifiedName.equals(fullQualifiedName)) {
            throw new PyxlParsingException("expected starting tag " + requiredQualifiedName);
        }

        return fullQualifiedName;
    }
/**
     * Parses a pyxl tag name, including an optional list of module qualifiers.
     *
     * @return the full qualified name (e.g. "module1.module2.tag")
     * @throws PyxlParsingException if @requiredQualifiedName is non-null and doesn't match the parsed qualified name.
     */
Parses a pyxl tag name, including an optional list of module qualifiers.
@return the full qualified name
@throws PyxlParsingException if @requiredQualifiedName is non-null and doesn't match the parsed qualified name.
Parses a pyxl tag name including an optional list of module qualifiers . @return the full qualified name @throws PyxlParsingException if @requiredQualifiedName is non - null and doesn ' t match the parsed qualified name .
private String parseQualifiedPyxlTagName(String requiredQualifiedName,
                                             PsiBuilder.Marker callExpressionMarker,
                                             PsiBuilder.Marker tagStartMarker) throws PyxlParsingException {
        final IElementType token = myBuilder.getTokenType();
        String fullQualifiedName = myBuilder.getTokenText();
        if (token == PyxlTokenTypes.TAGNAME_MODULE) {
            if (callExpressionMarker == null) callExpressionMarker = myBuilder.mark();
            if (tagStartMarker == null) tagStartMarker = myBuilder.mark();
            PsiBuilder.Marker moduleExpression = myBuilder.mark();
            myBuilder.advanceLexer();
            moduleExpression.done(PyxlElementTypes.MODULE_REFERENCE);
            if (myBuilder.getTokenType() != PyTokenTypes.DOT) {
                throw new PyxlParsingException();
            } else {
                myBuilder.advanceLexer();
            }
            fullQualifiedName = fullQualifiedName + "." +
                    parseQualifiedPyxlTagName(null, callExpressionMarker, tagStartMarker);
        } else if (token == PyxlTokenTypes.TAGNAME) {
            if (callExpressionMarker == null) callExpressionMarker = myBuilder.mark();
            if (tagStartMarker == null) tagStartMarker = myBuilder.mark();
            myBuilder.advanceLexer();
            tagStartMarker.done(PyxlElementTypes.TAG_REFERENCE);
            callExpressionMarker.done(PyElementTypes.CALL_EXPRESSION);
        } else if (token == PyxlTokenTypes.BUILT_IN_TAG) {
            myBuilder.advanceLexer();
        } else {
            throw new PyxlParsingException();
        }
        if (requiredQualifiedName != null && !requiredQualifiedName.equals(fullQualifiedName)) {
            throw new PyxlParsingException("expected starting tag " + requiredQualifiedName);
        }
        return fullQualifiedName;
    }
private String parseQualifiedPyxlTagName ( String requiredQualifiedName , PsiBuilder . Marker callExpressionMarker , PsiBuilder . Marker tagStartMarker ) throws PyxlParsingException { final IElementType token = myBuilder . getTokenType ( ) ; String fullQualifiedName = myBuilder . getTokenText ( ) ; if ( token == PyxlTokenTypes . TAGNAME_MODULE ) { if ( callExpressionMarker == null ) callExpressionMarker = myBuilder . mark ( ) ; if ( tagStartMarker == null ) tagStartMarker = myBuilder . mark ( ) ; PsiBuilder . Marker moduleExpression = myBuilder . mark ( ) ; myBuilder . advanceLexer ( ) ; moduleExpression . done ( PyxlElementTypes . MODULE_REFERENCE ) ; if ( myBuilder . getTokenType ( ) != PyTokenTypes . DOT ) { throw new PyxlParsingException ( ) ; } else { myBuilder . advanceLexer ( ) ; } fullQualifiedName = fullQualifiedName + "." + parseQualifiedPyxlTagName ( null , callExpressionMarker , tagStartMarker ) ; } else if ( token == PyxlTokenTypes . TAGNAME ) { if ( callExpressionMarker == null ) callExpressionMarker = myBuilder . mark ( ) ; if ( tagStartMarker == null ) tagStartMarker = myBuilder . mark ( ) ; myBuilder . advanceLexer ( ) ; tagStartMarker . done ( PyxlElementTypes . TAG_REFERENCE ) ; callExpressionMarker . done ( PyElementTypes . CALL_EXPRESSION ) ; } else if ( token == PyxlTokenTypes . BUILT_IN_TAG ) { myBuilder . advanceLexer ( ) ; } else { throw new PyxlParsingException ( ) ; } if ( requiredQualifiedName != null && ! requiredQualifiedName . equals ( fullQualifiedName ) ) { throw new PyxlParsingException ( "expected starting tag " + requiredQualifiedName ) ; } return fullQualifiedName ; }
Parses a pyxl tag name, including an optional list of module qualifiers.
Parses a pyxl tag name including an optional list of module qualifiers .
// Module qualifiers are straight up python identifiers followed by a dot // pyxl expands <p><c /></p> to x_p()(x_c()); // so in order to get the same semantics as the corresponding python would have, we fake a call to the init // function of the pyxl tag class here.