Skip to content

Commit

Permalink
Import: Lexer for Slice interface language (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrmont committed May 13, 2019
1 parent a6816d2 commit 5c3b5b5
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/rouge/demos/slice
@@ -0,0 +1,27 @@
// File system module.
module Filesystem {

// Node interface:
interface Node {
idempotent string name();
}

exception GenericError {
string reason;
}

sequence<string> Lines;

["java:implements:java.lang.AutoCloseable"]
interface File extends Node {
idempotent Lines read();
idempotent void write(Lines text) throws GenericError;
}

sequence<Node*> NodeSeq;

// Directory interface:
interface Directory extends Node {
idempotent NodeSeq list();
}
}
33 changes: 33 additions & 0 deletions lib/rouge/lexers/slice.rb
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*- #
# frozen_string_literal: true

module Rouge
module Lexers
load_lexer 'c.rb'

class Slice < C
tag 'slice'
filenames '*.ice'
mimetypes 'text/slice'

title "Slice"
desc "Slice interface language (https://doc.zeroc.com/display/Ice37/The+Slice+Language)"

def self.keywords
@keywords ||= Set.new %w(
extends implements enum interface struct class module dictionary const
optional out throws exception local idempotent sequence

Object LocalObject Value
)
end

def self.keywords_type
@keywords_type ||= Set.new %w(
bool string byte long float double int void short
)
end

end
end
end
18 changes: 18 additions & 0 deletions spec/lexers/slice_spec.rb
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*- #
# frozen_string_literal: true

describe Rouge::Lexers::Slice do
let(:subject) { Rouge::Lexers::Slice.new }

describe 'guessing' do
include Support::Guessing

it 'guesses by filename' do
assert_guess :filename => 'foo.ice'
end

it 'guesses by mimetype' do
assert_guess :mimetype => 'text/slice'
end
end
end
1 change: 1 addition & 0 deletions spec/visual/samples/slice

0 comments on commit 5c3b5b5

Please sign in to comment.