Unable to get basic language syntax to load

I’m trying to write a very simple syntax definition for a dialect of prolog and I’m using the auto-generated template as a starting point. Here’s what I have so far:

<?xml version="1.0" encoding="UTF-8"?>
<syntax name="asp">
    <meta>
        <name>Answer-Set Prolog</name>
        <type>script</type>
        <preferred-file-extension>lp</preferred-file-extension>
    </meta>

    <detectors>
        <extension priority="1.0">lp</extension>
    </detectors>

    <comments>
        <single>
            <expression>&percnt;</expression>
        </single>
        <multiline>
            <starts-with>
                <expression>&percnt;&ast;</expression>
            </starts-with>
            <ends-with>
                <expression>&ast;&percnt;</expression>
            </ends-with>
        </multiline>
    </comments>

    <brackets>
        <pair open="{" close="}" />
        <pair open="[" close="]" />
        <pair open="(" close=")" />
    </brackets>

    <surrounding-pairs>
        <pair open="{" close="}" />
        <pair open="[" close="]" />
        <pair open="(" close=")" />
        <pair open="&apos;" close="&apos;" />
        <pair open="&quot;" close="&quot;" />
    </surrounding-pairs>

    <scopes>
        <include syntax="self" collection="comments" />
        <include syntax="self" collection="keywords" />
    </scopes>

    <collections>
        <!-- Comments -->
        <collection name="comments">
            <scope name="asp.comment.block" spell-check="true">
                <starts-with>
                    <expression>&percnt;&ast;</expression>
                </starts-with>
                <ends-with>
                    <expression>&ast;&percnt;</expression>
                </ends-with>
            </scope>
            <scope name="asp.comment.single" spell-check="true">
                <starts-with>
                    <expression>&percnt;</expression>
                </starts-with>
            </scope>
        </collection>

        <!-- Keywords -->
        <collection name="keywords">
            <scope name="asp.keyword">
                <symbol type="keyword" />
                <strings>
                    <!-- Default Negation -->
                    <string>not</string>

                    <!-- Aggregates -->
                    <string>#sum</string>
                    <string>#count</string>
                    <string>#min</string>
                    <string>#max</string>

                    <!-- Optimizations -->
                    <string>#maximize</string>
                    <string>#minimize</string>

                    <!-- Directives -->
                    <string>#show</string>
                    <string>#const</string>
                </strings>
            </scope>
        </collection>
    </collections>
</syntax>

If I attempt to load the extension for testing I get the following error:

Answer-Set Prolog[11:40:06.533000] Error loading syntax “Answer-Set Prolog.xml”

The operation couldn’t be completed. (SKXMLDocumentErrorDomain error 111.)

Are there any suggestions for how to proceed? Is there a basic guide for syntax definition writing anywhere? All I really want is some basic highlighting of comments and keywords.

It sounds like you maybe already have seen the docs for syntaxes:

https://docs.nova.app/syntax-reference/

Most of what it sounds like you’ll want to know are in the Syntaxes and Scopes sections.

As for what you already have, I would try escaping the hash mark (#) in your keyword strings with a backslash. When my syntax failed, unescaped special characters were often the issue. (Note that even <string> elements are converted to regular expressions)

It would appear that your use of entities like &percnt; are not valid; Unlike HTML, XML itself does not define more than the five basic entities for quotes, apostrophes, ampersand, and the greater than / less than symbols.