emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

syntax identification (Request for Help)


From: Phillip Lord
Subject: syntax identification (Request for Help)
Date: Tue, 04 Aug 2015 17:49:23 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)


I am trying to improve the syntax identification of omn-mode.el (in
elpa). The omn syntax uses URLs everywhere which are identified like so:
<http://www.gnu.org>

Within this syntax, although they are URLs they have little other
meaning actually, they are IRIs -- identifiers, rather than locations.
IRIs are difficult to identify by regular expression. So I treat them
syntactically as strings with this (st is the syntax table).

    (modify-syntax-entry ?\< "|" st)
    (modify-syntax-entry ?\> "|" st)


Strings are nice because I also do this....

    (modify-syntax-entry ?\# "<" st)
    (modify-syntax-entry ?\n ">" st)

that is # is the start of comment character but NOT inside a IRI where
it's actually quite common. Identifying IRIs as strings also solves this
problem since comment characters inside strings are not comment
characters -- Emacs gives me this for free.

This fails, however, in two ways. Firstly while <url> is correctly
identified so is <url<, >url< and >url>. And, secondly "<" and ">" can
also be used along to mean (guess what!) greater than or less than in an
expression like so:

     xsd:integer[>= 0 , <= 18]


Unfortunately, everthing between ">" and "<" gets identified as a
string.

Stefan added comments to omn-mode saying "We could use a
syntax-propertize-function to do more carefully.". Would anyone be
willing to help explain to me how this works and help me? I found the
manual a bit confusing.

I am willing to use space characters to differentiate. IRIs are complex
(they have very few rules) but cannot contain spaces. The "facet" (i.e.
[>= 0]) bit above can contain spaces, and while they do not need to
contain spaces, I am willing to use this to differentiate between them
and an IRI as an acceptable compromise.

Any help gratefully recieved.

Phil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]