usethesource / rascal-syntax-highlighting Goto Github PK
View Code? Open in Web Editor NEWTM Bundle for syntax highlighting Rascal code
License: BSD 2-Clause "Simplified" License
TM Bundle for syntax highlighting Rascal code
License: BSD 2-Clause "Simplified" License
Currently all elements between two brackets []
are treated naïvely as lexical character set, which results in issues with highlighting list literals. Particularly, we must ensure that only things between brackets inside lexical
or syntax
scopes are treated as character sets, and those outside are treated as list literals.
Note that removing the support for lexical character sets ruins the highlighting of the rest of the programs since \"
and "/", and other similar characters can appear freely in character set expressions.
Examples of mis-highlighted terms:
// comment 1
n = 1; // comment 2
l = [1, // comment 3: non highlighted
2,
3];
list[int] n
private MuExp translateStringLiteral(s: (StringLiteral) `<PreStringChars pre> <Expression expression> <StringTail tail>`) {
preIndent = computeIndent(pre);
return muBlock( [ muCallPrim3("template_open", translatePreChars(pre), pre@\loc),
*translateExpInStringLiteral(preIndent, expression),
*translateTail(preIndent, tail),
muCallPrim3("template_close", [], tail@\loc)
] );
}
loc working = |scheme://normal/as/it/should/be|;
loc broken = |scheme://with-dashes-in-authority/breaks/it|;
The following tutorial http://www.apeth.com/nonblog/stories/textmatebundle.html provides many useful suggestions on how to highlight entities in a correct way. Recheck grammar and see if it is possible to align it with the recommendations provided by the tutorial.
Currently, URL literals, e.g. |http://google.com|
are not highlighted as they optimally should be.
It is not possible to just use begin: |
end: |
since operators like ||
exist and concrete and abstract syntax uses them, so one should be careful in the way they are recognized.
The best approach would be to follow the URL grammar, albeit it's a bit complex since it can contain interpolations as well as having various different parts.
This is a question rather than an issue.
At the moment we are working on new infrastructure for our Rascal documentation that is based on Asciidoctor (see http://asciidoctor.org). Asciidoctor supports highlighting in various ways (see http://asciidoctor.org/docs/user-manual/#source-code-blocks). Now the question is: can we convert the nice Textmate rules under development by @ahmadsalim to input for any of the supported systems by Asciidoctor:
I would prefer to have less Ruby/Python and more Javascript in the solution we will adopt.
Any thoughts?
I discovered the issue while I was doing something else.
First of all there is a small bug in the grammar which was unnoticed:
Which is that in the regex:
rule we should replace
begin: "/(?!/|*)"
with
begin: "/(?!/|\\*)"
Without fixing this issue the Atom highlighter breaks on certain files, but the TM/Sublime highlighter is also wrong.
Fixing this issue brings another issue with regards to division being accidentally seen as regex literals by the highlighter.
Most files contain a license header, and a lot of standard functions contain documentation tags.
The body of them should be marked as comments.
@license{
BSD-2 License
}
module A
@doc{
Textile markup for the documentation
}
@javaClass{org.rascalmpl.library.X}
public java str doStuff(int x);
they should be marked as comments instead of normal text
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.