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

Import: Lexer for Slice interface language #50

Merged
merged 4 commits into from May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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