Skip to content
Permalink
Browse files

Fix(pony): highlighting errors and remove two modes (#1979)

Fixes a few highlighting bugs such as keyword lists not having spaces at
the end causing the last keyword of one line and the first keyword of
the next to be combined. Also fixed highlighting of `iso` in class
definitions and function heads without bodies in traits and interfaces.

This also removes the FUNCTION and CLASS modes until there is a more
clear benefit to using them. In a couple cases such as an interface
with multiple function heads without an `=>` indicating a body they
broke the highlighting of the second function head.
  • Loading branch information...
gregcline authored and marcoscaceres committed Feb 24, 2019
1 parent 5290313 commit dbe4ffad839ea166af89dfbd27b7e7e232bd162b
@@ -274,3 +274,4 @@ Contributors:
- Alejandro Isaza <al@isaza.ca>
- Laurent Voullemier <laurent.voullemier@gmail.com>
- Sean T. Allen <sean@monkeysnatchbanana.com>
- Greg Cline <gregrcline@gmail.com>
@@ -5,6 +5,7 @@ New languages:
New styles:

Improvements:
- Pony: Fixed keywords without spaces at line ends, highlighting of `iso` in class definitions, and function heads without bodies in traits and interfaces. Removed FUNCTION and CLASS modes until they are found to be needed and to provide some of the fixes.

## Version 9.14.3
New languages:
@@ -8,9 +8,9 @@ Description: Pony is an open-source, object-oriented, actor-model,
function(hljs) {
var KEYWORDS = {
keyword:
'actor addressof and as be break class compile_error compile_intrinsic' +
'consume continue delegate digestof do else elseif embed end error' +
'for fun if ifdef in interface is isnt lambda let match new not object' +
'actor addressof and as be break class compile_error compile_intrinsic ' +
'consume continue delegate digestof do else elseif embed end error ' +
'for fun if ifdef in interface is isnt lambda let match new not object ' +
'or primitive recover repeat return struct then trait try type until ' +
'use var where while with xor',
meta:
@@ -48,47 +48,20 @@ function(hljs) {
begin: hljs.IDENT_RE + '\'', relevance: 0
};

var CLASS = {
className: 'class',
beginKeywords: 'class actor object primitive', end: '$',
contains: [
{
className: 'keyword',
begin: 'is'
},
TYPE_NAME,
hljs.TITLE_MODE,
hljs.C_LINE_COMMENT_MODE
]
}

var FUNCTION = {
className: 'function',
beginKeywords: 'new fun be', end: '=>',
contains: [
hljs.TITLE_MODE,
{
begin: /\(/, end: /\)/,
contains: [
TYPE_NAME,
PRIMED_NAME,
hljs.C_NUMBER_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
},
{
begin: /:/, endsWithParent: true,
contains: [TYPE_NAME]
},
hljs.C_LINE_COMMENT_MODE
]
}
/**
* The `FUNCTION` and `CLASS` modes were intentionally removed to simplify
* highlighting and fix cases like
* ```
* interface Iterator[A: A]
* fun has_next(): Bool
* fun next(): A?
* ```
* where it is valid to have a function head without a body
*/

return {
keywords: KEYWORDS,
contains: [
CLASS,
FUNCTION,
TYPE_NAME,
TRIPLE_QUOTE_STRING_MODE,
QUOTE_STRING_MODE,
@@ -0,0 +1,21 @@
<span class="hljs-keyword">if</span> a == b <span class="hljs-keyword">and</span> b == a <span class="hljs-keyword">then</span>
env.out.print(<span class="hljs-string">"they are the same"</span>)
<span class="hljs-keyword">elseif</span> a &gt; b <span class="hljs-keyword">or</span> b &lt; a <span class="hljs-keyword">then</span>
env.out.print(<span class="hljs-string">"a is bigger"</span>)
<span class="hljs-keyword">else</span>
env.out.print(<span class="hljs-string">"b bigger"</span>)
<span class="hljs-keyword">end</span>

<span class="hljs-keyword">while</span> count &lt;= <span class="hljs-number">10</span> <span class="hljs-keyword">do</span>
env.out.print(count.string())
count = count + <span class="hljs-number">1</span>
<span class="hljs-keyword">end</span>

<span class="hljs-keyword">for</span> name <span class="hljs-keyword">in</span> [<span class="hljs-string">"Bob"</span>; <span class="hljs-string">"Fred"</span>; <span class="hljs-string">"Sarah"</span>].values() <span class="hljs-keyword">do</span>
env.out.print(name)
<span class="hljs-keyword">end</span>

<span class="hljs-keyword">repeat</span>
env.out.print(<span class="hljs-string">"hello!"</span>)
counter = counter + <span class="hljs-number">1</span>
<span class="hljs-keyword">until</span> counter &gt; <span class="hljs-number">7</span> <span class="hljs-keyword">end</span>
@@ -0,0 +1,21 @@
if a == b and b == a then
env.out.print("they are the same")
elseif a > b or b < a then
env.out.print("a is bigger")
else
env.out.print("b bigger")
end

while count <= 10 do
env.out.print(count.string())
count = count + 1
end

for name in ["Bob"; "Fred"; "Sarah"].values() do
env.out.print(name)
end

repeat
env.out.print("hello!")
counter = counter + 1
until counter > 7 end
@@ -1,3 +1,3 @@
<span class="hljs-function"><span class="hljs-keyword">new</span> <span class="hljs-title">create</span>(env: <span class="hljs-type">Env</span>, name: <span class="hljs-type">String</span>) =&gt;</span>
<span class="hljs-keyword">new</span> create(env: <span class="hljs-type">Env</span>, name: <span class="hljs-type">String</span>) =&gt;
_env = env
_name = name
@@ -0,0 +1,9 @@
<span class="hljs-keyword">interface</span> <span class="hljs-type">Iterator</span>[<span class="hljs-type">A</span>: <span class="hljs-type">A</span>]
<span class="hljs-keyword">fun</span> has_next(): <span class="hljs-type">Bool</span>
<span class="hljs-keyword">fun</span> next(): <span class="hljs-type">T</span>?

<span class="hljs-keyword">trait</span> <span class="hljs-type">UnitTest</span>
<span class="hljs-keyword">fun</span> name(): <span class="hljs-type">String</span>
<span class="hljs-keyword">fun</span> <span class="hljs-meta">ref</span> set_up(h: <span class="hljs-type">TestHelper</span>) ? =&gt;
<span class="hljs-type">None</span>
<span class="hljs-keyword">fun</span> apply(h: <span class="hljs-type">TestHelper</span>) ?
@@ -0,0 +1,9 @@
interface Iterator[A: A]
fun has_next(): Bool
fun next(): T?

trait UnitTest
fun name(): String
fun ref set_up(h: TestHelper) ? =>
None
fun apply(h: TestHelper) ?
@@ -1,8 +1,8 @@
<span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">foo</span>(bar: <span class="hljs-type">String</span>): <span class="hljs-type">String</span> =&gt;</span>
<span class="hljs-keyword">fun</span> foo(bar: <span class="hljs-type">String</span>): <span class="hljs-type">String</span> =&gt;
bar + <span class="hljs-string">"baz"</span>

<span class="hljs-function"><span class="hljs-keyword">new</span> <span class="hljs-title">create</span>(hunger: <span class="hljs-type">I32</span>) =&gt;</span>
<span class="hljs-keyword">new</span> create(hunger: <span class="hljs-type">I32</span>) =&gt;
_hunger = hunger

<span class="hljs-function"><span class="hljs-keyword">be</span> <span class="hljs-title">feed</span>(food: <span class="hljs-type">I32</span>) =&gt;</span>
<span class="hljs-keyword">be</span> feed(food: <span class="hljs-type">I32</span>) =&gt;
_hunger = _hunger - food
@@ -1,7 +1,11 @@
<span class="hljs-class"><span class="hljs-keyword">primitive</span> <span class="hljs-type">I32</span> <span class="hljs-keyword">is</span> <span class="hljs-type">SignedInteger</span></span>
<span class="hljs-keyword">primitive</span> <span class="hljs-type">I32</span> <span class="hljs-keyword">is</span> <span class="hljs-type">SignedInteger</span>

<span class="hljs-class"><span class="hljs-keyword">actor</span> <span class="hljs-type">Main</span></span>
<span class="hljs-keyword">actor</span> <span class="hljs-type">Main</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ref</span> <span class="hljs-type">List</span>[<span class="hljs-type">A</span>: <span class="hljs-type">A</span>] <span class="hljs-keyword">is</span> <span class="hljs-type">Seq</span>[<span class="hljs-type">A</span>] <span class="hljs-title">ref</span></span>
<span class="hljs-keyword">class</span> <span class="hljs-meta">ref</span> <span class="hljs-type">List</span>[<span class="hljs-type">A</span>: <span class="hljs-type">A</span>] <span class="hljs-keyword">is</span> <span class="hljs-type">Seq</span>[<span class="hljs-type">A</span>] <span class="hljs-meta">ref</span>

<span class="hljs-class"><span class="hljs-keyword">object</span> <span class="hljs-keyword">is</span> <span class="hljs-type">Hashable</span></span>
<span class="hljs-keyword">object</span> <span class="hljs-keyword">is</span> <span class="hljs-type">Hashable</span>

<span class="hljs-keyword">object</span> <span class="hljs-meta">iso</span>

<span class="hljs-keyword">primitive</span> <span class="hljs-type">Foo</span> <span class="hljs-keyword">is</span> <span class="hljs-type">Bar</span> <span class="hljs-meta">iso</span>
@@ -4,4 +4,8 @@ actor Main

class ref List[A: A] is Seq[A] ref

object is Hashable
object is Hashable

object iso

primitive Foo is Bar iso
@@ -1,2 +1,2 @@
<span class="hljs-function"><span class="hljs-keyword">new</span> <span class="hljs-title">create</span>(name': <span class="hljs-type">String</span>) =&gt;</span>
name = name' + <span class="hljs-string">'a'</span>
<span class="hljs-keyword">new</span> create(name': <span class="hljs-type">String</span>) =&gt;
name = name' + <span class="hljs-string">'a'</span>

0 comments on commit dbe4ffa

Please sign in to comment.
You can’t perform that action at this time.