|
From: Lucas D. <ld...@in...> - 2009-10-04 18:07:56
|
I'll try to remember the issue, it was a while ago I thought about it...
here's a bit of code (looking like typical code, but not doing anything
particularly interesting):
fun f a b l =
let
val x = a + b
val y = a * b
in
x |> (fold
(fn x2 => y + x2)
l)
|> (fn x2 => case l
of [] => 100
| (h::t) => x2 + (length l))
end
this defines a function "f" which has 3 arguments.
some tricky things for indenting/colouring:
"let-in-end" has two indented parts, the "in" should not be indented,
nor should the "let and "end".
there are infix operators/keywords, like "|>", which should line up.
functions often have lots of compound arguments, so indentation of
arguments to a function is needed (e.g. fold the two arguments of fold).
Pretty much anything except for keywords are functions.
indentation is always ended by the corresponding "end" or close bracket.
lots of slightly special cases for indenting, like "case".
I think these things that I couldn't figure out, but for which a grammar
would work out without too much difficulty.
Any suggestions would of course be very welcome :)
best,
lucas
Shlomy Reinstein wrote:
> Lucas,
>
> Aside from trying to use a grammar for the purpose of indentation and
> syntax highlighting - can you say what is missing in the current mode
> language to fully support the languages you use?
>
> Shlomy
>
> On Fri, Oct 2, 2009 at 9:06 PM, Shlomy Reinstein <sre...@gm...> wrote:
>>> In the meantime, is there is a way to write a mode purely in java,
>>> without going through the compilation machinery of a mode file, so that
>>> I might have a look at writing my own special syntax highlighter and
>>> indentation? I guess I'm wondering what events the syntax highlighter
>>> has to respond to, and similarly for indentation, and what functions I
>>> might be able to re-use to simply tell jedit what colour to use for what
>>> chunks of text...
>>>
>>> as I write this, I'm starting to think this might be a lot of work...
>>>
>>> any suggestions and comments would be very welcome,
>>>
>>> best,
>>> lucas
>>>
>>> --
>>> The University of Edinburgh is a charitable body, registered in
>>> Scotland, with registration number SC005336.
>>>
>>>
>> You can start by reading the documentation of edit modes. That's what
>> a mode file defines, and instead of writing a mode file you can set
>> the objects at run-time. It's probably not what you want, anyway,
>> because it's just filling in the mode file properties dynamically in
>> java.
>>
>> To apply the mode rules, see the TokenMarker class. It has a method
>> for marking tokens in a line. This is the starting point, but as you
>> think, it's an awful lot of work.
>>
>> ... and thanks for mentioning the parser you used. I recall that
>> looking for a C++ parser, I encountered something named "The Harmonia
>> project", which is hosted by a university, and as far as I understand
>> is a self-adjustable parser, that can listen to changes anywhere in
>> the parsed text and do the minimal things to adapt the parse tree and
>> associated actions. But I never went into detail to understand how it
>> works.
>>
>
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
|