From: Edgar Friendly <thelema314@gmail.com>
To: caml-list <caml-list@yquem.inria.fr>
Subject: GtkSourceView2.0 syntax highlighting
Date: Tue, 29 May 2007 14:04:52 -0500 [thread overview]
Message-ID: <465C7954.1060208@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2596 bytes --]
The upcoming version of GtkSourceView, the library used by many Gnome
text editors for syntax highlighting, supports new and more powerful
language parsing. I volunteer to update the language definition for
Ocaml, and would like some feedback from the community regarding useful
things to highlight.
The following are currently matched:
====================================
* Comments (* *), and within them, email addresses, net addresses and
TODO/FIXME/XXX
* Decimal, Octal, Hex, Binary and Floating point literals
* Labeled and Optional function arguments
* Polymorphic variants and normal Variant constructors
* Module paths (as a prefix to anything)
* Strings and Character Literals, with all escape codes allowed within
them sub-matched
The reasonably large list of keywords has been broken into four
sections. (I encourage comments on this division.)
1) booleans
true false
2) flow control & common keywords
and assert begin do done downto else
end for fun function if in
let match rec then to try val
when while with
3) types, objects & modules
as class constraint exception external
functor include inherit initializer method module
mutable new object of open private struct
sig type virtual
4) function-like keywords
asr land lazy lor lsl lsr lxor
mod or
Things not matched currently
============================
* Line number directives (probably never seen in actual code)
* Record constructors - { record with label:value; label:value }
* Object duplication - {< var = value; var = value >}
* List literals - [ elem1; elem2; elem3 ]
* Array literals - [| elem1; elem2; elem3 |]
* Tuples - elem1, elem2, elem3 (hard to parse - no parentheses needed,
only commas)
* Array access and modification - arr.(i), arr.(i) <- 5
* String access and modification - str.[i], str[i] <- 'w'
* Coercion - ( expr :> type ), (expr : type1 :> type2)
* Method calls - obj#method args
* There's a ton of character-sequence keywords, are there any that
should be handled as a keyword, or should they be handled only in the
above cases where they're used?
!= # & && ' ( ) * + , -
-. -> . .. : :: := :> ; ;; <
<- = > >] >} ? ?? [ [< [> [|
] _ ` { {< | |] } ~
* What about camlp4 keywords? New keywords in the new camlp4?
parser << <: >> $ $$ $:
Thanks for your comments. Attached is a compressed version of my
current language definition in the XML format required by gtksourceview.
E.
[-- Attachment #2: ocaml2.lang.gz --]
[-- Type: application/x-gzip, Size: 1411 bytes --]
next reply other threads:[~2007-05-29 19:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-29 19:04 Edgar Friendly [this message]
2007-05-29 19:47 ` [Caml-list] " Richard Jones
2007-05-29 21:31 ` Edgar Friendly
2007-05-29 21:36 ` Robert Roessler
2007-05-30 5:30 ` Edgar Friendly
2007-05-30 1:02 ` skaller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=465C7954.1060208@gmail.com \
--to=thelema314@gmail.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox