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

Fix OCaml language support #608

Merged
merged 1 commit into from
Oct 19, 2014
Merged

Conversation

polazarus
Copy link
Contributor

The major concern with the state of OCaml in Highlight.js is about the apostrophe '. They are very used in OCaml : they are allowed in identifiers (my_var'), and are used to prefix "generic" types (type variable, e.g. in 'a list type of a generic list). Yet the existing language description, totally ignore it (except for character literals) and as a result the first use of ' messes up the highlighting of the rest of the code (in particular interfaces).

The proposed modification provides various improvements:

  • character support (as char rather than string)
  • type variable ('a)
  • polymorphic variant tag ([ A | B ])
  • module name/variant constructor (module List or constructor Some a)
  • support ' in identifier
  • add support for literals () [] [||]
  • better support for numbers (OCaml ≠ C)
  • remove unrelated rules (from F# maybe?)
  • add new keywords (method!, open! etc.)
  • cleanup built-in types
  • add some tests

A step backward: remove very incomplete type definition. It would not have been easy to really support that and in terms of highlighting I don't think it's worth it.

The complete test suite sucessfully run including the language detection.

Cheers, M

Various improvements:

- character support
- type variable
- polymorphic variant tag
- module name/variant constructor
- support ' in identifier
- add support for literals () [] [||]
- better support for numbers
- remove unrelated rules (from F# maybe?)
- add new ! keywords
- cleanup built-in types

A step backward: remove very incomplete type definition matching

Add tests B)
@isagalaev isagalaev merged commit 59650aa into highlightjs:master Oct 19, 2014
@isagalaev
Copy link
Member

This is a very comprehensive work, thank you! Merged.

@polazarus polazarus deleted the fix-ocaml branch October 19, 2014 13:00
@polazarus
Copy link
Contributor Author

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants