Rosetta Code:Village Pump/Syntax highlighting: Difference between revisions

removed old, long and deprecated parts of the ocaml highlighting issues discussions
(removed old, long and deprecated parts of the ocaml highlighting issues discussions)
Line 488:
 
* A syntax highlighting issue with single quotes can be seen here: [[Bitmap/Bézier_curves/Quadratic#Haskell]] and there: [[Conway's_Game_of_Life#Haskell]]
 
 
== OCaml syntax highlighting issues, '''bis''' ==
Line 496 ⟶ 497:
== OCaml syntax highlighting issues ==
 
:: Thanks a lot, BenBE, for the corrections! [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
Here are bugs in the ocaml syntax highlighting
 
* This problem also occurs with fields of structures:
<blockquote>
<lang ocaml>type t = { x:int; y:int } ;;
let v = {x=2; y=3} ;;
print_int (v.x + v.y) ;;</lang>
</blockquote>
:* I disabled OOP Language Handling for OCaml for now. I guess there's some issue in how the magic is done inside the parser that needs to be tweaked ... But otherwise having v.x and v.y marked x and y as methods\fields is desired. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: About OOP method are accessed with the character '#' like this "my_obj#my_method param1 param2", but ocaml programmers don't use OO a lot ([[Go_Fish/OCaml]] is the only example on RC). Now if fields are not highlighted I don't feel this as annoying. [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
* there is also something that I consider as an issue, when a function or a constructor follows a module name, these two different entities are colored in the same way, example (from [[Determine_if_Only_One_Instance_is_Running#OCaml|there]]):
<blockquote>
<lang ocaml>Unix.sleep (* function *)
Unix.O_CREAT (* constructor *)
Unix.LargeFile (* a sub-module *)
(ref 3).contents (* the field of a structure *)</lang>
also I don't find it very uniform to colorise elements that follow a module name, and not when the module is opened:
<lang ocaml>open Unix
(* equivalent elements, but here with different colors *)
sleep
O_CREAT
open LargeFile
{ contents = 3 }</lang>
so I think GeSHi should not colorise names after a dot.
This would by the way fix the bug with float operations.
</blockquote>
:* Hard to be done right without contextual parsing (which GeSHi 1.0.X currently doesn't). Should be a bit better with the OOLang handling currently being disabled. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* when one open a module, we can open also open a module inside another module
<blockquote>
<lang ocaml>open Ode
open Ode.LowLevel (* LowLevel is a module inside the module Ode *)</lang>
</blockquote>
:* Need contextual parsing, cf. above. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* Modules that are not part of the standard library are not colorised, ''IMHO'' this is not very uniform and relevant. In editors with ocaml syntax-highlight, all modules are highlighted. (modules from the standard lib have a link to the doc, please keep this feature)
** (identifiers (identifiers to values (often called variables) and identifiers to functions) have the first letter lower case or an underscore)
** a name that starts with an upper-case letter is a module name or a constructor (they are capitalised)
<blockquote>
we can make the difference between a module name and a constructor when it's followed by a dot it's a module name (maybe I'm wrong, but I can't find an example of a constructor followed by a dot)
<lang ocaml>Unix.sleep (* module *)
Some "text" (* a constructor *)</lang>
when there is no dot after it but the keyword <code>open</code> before it, it is a module name:
<lang ocaml>open Unix</lang>
we can also open a submodule:
<lang ocaml>open ExtString.String (* both modules ExtString and String should have the same color *)</lang>
there can be any depth:
<lang ocaml>open M1.M2.M3.M4.M5.M6.M7.M8</lang>
we can also recognize a module name if there is the keyword <code>module</code> before it:
<lang ocaml>module Attrib</lang>
in all other cases it is a constructor.
</blockquote>
:* Could be done, but produces quite messy language files and mostly isn't worth the drawbacks. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* I think constructors should be highlighted too (with another color than modules), (in editors constructors are highlighted).
(see previous paragraph to see when a capitalised word is a module or a constructor)
:* hmmm, I'd like to keep contextual highlighting as much out of the language file as possible. The 1.1.X developement branch can do contextual highlighting\parsing, but this won't work together with the stable 1.0.X branch this site is using. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* [http://caml.inria.fr/pub/docs/manual-ocaml/libref/index_modules.html Modules from the standard library] are not treated the same, some are highlighted with a link to the doc, and some other are not:
<blockquote>
<lang ocaml>Arg
Arith_status
Array
Array1 (* * *)
Array2 (* * *)
Array3 (* * *)
ArrayLabels
Big_int
Bigarray
Buffer
Callback
CamlinternalLazy (* TODO *)
CamlinternalMod (* TODO *)
CamlinternalOO
Char
Complex
Condition
Dbm
Digest
Dynlink
Event
Filename
Format
Gc
Genarray (* * *)
Genlex
Graphics
GraphicsX11
Hashtbl
Int32
Int64
LargeFile (* !!! *)
Lazy
Lexing
List
ListLabels
Make (* !!! *)
Map
Marshal
MoreLabels
Mutex
Nativeint
Num
Obj
Oo
Parsing
Pervasives
Printexc
Printf
Queue
Random
Scanf
Scanning (* * *)
Scanf
Set
MoreLabels
Sort
Stack
State (* * *)
Random
StdLabels
Str
Stream
String
StringLabels
Sys
Thread
ThreadUnix
Tk
Unix (* TODO *)
UnixLabels (* TODO *)
Weak (* TODO *)</lang>
Those tagged with TODO should be added (in particular Unix in priority), the other could be omited, those with a star are modules inside another module for example Array1, Array2, Array3 and Genarray are inside Bigarray, for a root module named Foo the url is <nowiki>http://caml.inria.fr/pub/docs/manual-ocaml/libref/</nowiki>'''Foo'''.html for a module Bar inside Foo the url is <nowiki>http://caml.inria.fr/pub/docs/manual-ocaml/libref/</nowiki>'''Foo'''.'''Bar'''.html
the tags !!! are for modules which url can not be resolved because for example for the module name LargeFile, there are LargeFile modules inside several root modules in Pervasives, in Unix, and in UnixLabels.
</blockquote>
:* I've added some Modules for now. For the star-ed Modules I'd need to have the Parent Module name or the Doc-Link that I should be generating. As each Group requires some overhead I'd suggest linking only those with at least 2 or 3 Submodules in it (e.g. Array) and simply highlighting (without Link) the others. Could you compile me that list? --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: Here are the full links of the star'ed modules:
Line 642 ⟶ 505:
Scanning => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Scanf.Scanning.html
State => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Random.State.html
:: [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
 
* not a bug nor an issue, but a suggestion: maybe we could highlight the core OCaml types:
 
<blockquote>
* this type is currently linked to the url 1, which is wrong, the wright url is [2]
<lang ocaml>list
<lang ocaml>file_descr
array
[1] http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#TYPEfile_descr
int
[2] http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#TYPEfile_descr
float (* !!! *)
</lang>
bool
 
char
 
string
* I think that some links could be modified:
unit
<lang ocaml>
int32
int64
nativeint
<fun>
in_channel
out_channel
file_descr
exn</lang>
* I have keep in_channel and out_channel in the list because I think we should use the same color.
* float is a type in contexts where ocaml expects a type and a function in contexts where ocaml expects a function. So we could keep it as a function, or convert it to a type. I'm not sure which is best, but in RC context it seems it is most often the function.</blockquote>
:* Added them, left float as function. Left <fun> alone as this requires some special treatment. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: I think that some links could be modified:
file_descr => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#TYPEfile_descr
int32 => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Int32.html
int64 => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Int64.html
nativeint => http://caml.inria.fr/pub/docs/manual-ocaml/libref/Nativeint.html
</lang>
:: [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
* not a bug nor an issue, but a suggestion: maybe we could highlight labels (names with a tild before it):
<blockquote><lang ocaml>let my_compare ~left ~right =
(* ... *)</lang>
 
I propose this style (<code>font-weight:bold; color:#339933;</code>):
<span style="font-weight: bold; color: #339933;">~left</span>
</blockquote>
:* Included in the language file, but needs a CSS Addition for class re1 (ocaml only) on RC. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* not a bug nor an issue, but a suggestion: maybe we could highlight polymorphic variants (names with a backtick before it):
<blockquote><lang ocaml>`left (* constructor of a polymorphic variant *)
Left (* constructor of a non-polymorphic variant *)</lang>
''IMHO'' these two kinds of constructors should be highlighted with the same color.
 
I suggest this style (<code>font-weight:bold; color:#993399;</code>):
<span style="font-weight: bold; color: #993399;">Left</span>
<span style="font-weight: bold; color: #993399;">`left</span>
(if the highlight for names following a dot is removed as suggested above, because this is the same color)
</blockquote>
:* Included in language file but needs a CSS Addition for class re2 (ocaml only) on RC. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
 
* This bug is not related to the OCaml syntax (but affects ocaml syntax), GeSHi doesn't handle nested comments (see [[Comments]])
<blockquote><lang ocaml>(* This a comment
(* containing nested comment *)
*)</lang>
just a suggestion, maybe an easy way to handle this would be to match <code>*) ... *)</code>?
</blockquote>
:* Fixed. Now uses recursive regular expressions for comments with fallback for simple string search. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: This is very nice, thanks!
:: On the [[Comments]] page we can see other languages that use nested comments, here is the list that I can see:
* Clean
* D with /+ +/
* Haskell
* Mathematica
* Modula-3
* Pop11
* Seed7
* Standard ML
* Ursala
:: Also some that are not nested, but where I can see some bug:
* "perl6", see: [[Comments#Perl_6]]
* There is a bug with phpdoc in PHP: [[Comments#PHP]]
* multiline comments are not handled with Rebol: [[Comments#REBOL]]
:: [[User:Blue Prawn|Blue Prawn]] 23:04, 28 February 2010 (UTC)
 
* The parser brackets ('''[<''' and '''>]''') should be completely highlighted:
Line 723 ⟶ 530:
</blockquote>
:* Tweaked in language file but needs CSS class sy0 to be set for this to show. --[[User:BenBE|BenBE]] 00:29, 18 February 2010 (UTC)
:: Unfortunately this sy0 CSS class is the same than when '''<''' appears alone (the ''lower than'' opperator), and here the '''[''' is CSS'ed in the same way than when it appears alone too. A different class for when they appear un pairs would be better ('''[<''' and '''>]'''). [[User:Blue Prawn|Blue Prawn]] 19:54, 18 August 2011 (UTC)
 
 
 
== Comments highlighting issues ==
 
* On the [[Comments]] page we can see some languages that use nested comments, here is the list that I can see:
 
** [[Comments#Haskell]]
** [[Comments#Lua]]
** [[Comments#Modula-3]]
** [[Comments#Perl_6]]
** [[Comments#PHP]]
** [[Comments#REBOL]]
 
 
-- [[User:Blue Prawn|Blue Prawn]] 21:29, 22 January 2010 (UTC)
 
==Regression in Tcl Syntax Highlighting==