Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quoted atom parsed as errors in prolog #156

Open
piccolbo opened this issue Oct 14, 2022 · 8 comments
Open

quoted atom parsed as errors in prolog #156

piccolbo opened this issue Oct 14, 2022 · 8 comments

Comments

@piccolbo
Copy link

Hi, reporting here per suggestion on pandoc user list. I was told this is the upstream dep and replicated the error in skylighting (as far as I understand it, first time user, brew install)

echo  'afact("Fact").' | skylighting --syntax prolog -f latex

<preamble omitted>
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{afact(}\OtherTok{"}\ErrorTok{Fact}\OtherTok{"}\NormalTok{)}\KeywordTok{.}
\end{Highlighting}
\end{Shaded}

You can see the \ErrorTok command in there. Similar story with html output (span class="er")

</style></head><body><div class="sourceCode"><pre class="sourceCode"><code class="sourceCode"><span id="1"><a href="#1" aria-hidden="true" tabindex="-1"></a>afact(<span class="ot">&quot;</span><span class="er">Fact</span><span class="ot">&quot;</span>)<span class="kw">.</span></span></code></pre></div></body></html>

I am told that skylighting relies on data shared or derived from the kate editor. I could not reproduce the problem in Kate on Mac OS, or at least I can say the quote atoms appear in green and not bold red. Not sure which style Kate is using by default. I am a complete Prolog noob, but that looks fine to me and SWI Prolog accepts it. Thanks

Antonio

@jgm
Copy link
Owner

jgm commented Oct 14, 2022

I don't know much Prolog. Is the "Fact" just supposed to be a string?

@jgm
Copy link
Owner

jgm commented Oct 14, 2022

Looking at prolog.xml, I'm baffled. It seems that the dq context just emits a syntax error whenever it sees something that looks like an identifier. Why?

@piccolbo
Copy link
Author

Well, it's two of us then. But yes, from what I understand it is perfectly fine. To test this assumption, I created a file containing afact("Fact").. Opened it with swipl (SWI prolog) and performed a query afact(X) and the reply was X = "Fact".. You may have seen Prolog used with bare atoms, without quotes. skylighting works with those. The quotes are always permissible and mandatory when the atom contains a space or starts with an uppercase letter (which would qualify it as a variable).

@piccolbo
Copy link
Author

So you are looking at this

	    <context name="dq" lineEndContext="#stay" attribute="&quot;double-quoted&quot;" noIndentationBasedFolding="true" >
<!-- 	    <context name="double-quoted" lineEndContext="#stay" attribute="&quot;double-quoted&quot;" > -->
		<IncludeRules context="quoted_1st"/>
		<RegExpr String="(&quot;&quot;|&esc_oct_iso;|&esc_hex_iso;|\\&any;|[^&quot;\\]+)$"
			context="syntax_error_dq" attribute="Syntax Error" />
		<Detect2Chars char="&quot;" char1="&quot;" context="#stay" attribute="escaped (!use background)" />
		<DetectChar char="&quot;" context="#pop#pop" endRegion="quoted" attribute="&quot;double-quoted&quot;" />
		<IncludeRules context="quoted_last"/>
	    </context>

I don't fully understand, but it seems to emit a syntax error for everything that's double quoted. "Fact" is actually a type of atom, not an identifier. There is a context name atomic but not one for atom. It would be nice to see the original in Kate.

@jgm
Copy link
Owner

jgm commented Oct 14, 2022

This is the xml syntax definition that is being used in Kate.
It's possible that there is some error in our implementation, but I'm not sure what it would be.

@piccolbo
Copy link
Author

Thanks, I don't think an intelligent person should go through 1000 lines of xml to try and fix this, I just switched it off for now. For a grammar that may be 10 lines of BNF.

@jgm
Copy link
Owner

jgm commented Oct 14, 2022

I emailed the author - if we're lucky we may get some help understanding what it is supposed to do.

@jgm
Copy link
Owner

jgm commented Jul 21, 2023

See comment #170 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants