mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Add the Mercury language to linguist
lib/linguist/languages.yml:
Add the declaration for the language.
samples/Mercury:
Add samples for the classifier as Mercury shares it's filename extension
with several other languages.
This commit is contained in:
committed by
Sebastian Godelet
parent
f39456ee47
commit
42194094a2
50
samples/Mercury/rot13_ralph.m
Normal file
50
samples/Mercury/rot13_ralph.m
Normal file
@@ -0,0 +1,50 @@
|
||||
% ---------------------------------------------------------------------------- %
|
||||
% rot13_ralph.m
|
||||
% Copyright (C) 2001 Ralph Becket <rbeck@microsoft.com>
|
||||
% Tue Jan 9 18:10:44 GMT 2001
|
||||
% vim: ts=4 sw=4 et tw=0 wm=0 ff=unix ft=mercury
|
||||
%
|
||||
% Short and sweet.
|
||||
%
|
||||
% ---------------------------------------------------------------------------- %
|
||||
|
||||
:- module rot13_ralph.
|
||||
|
||||
:- interface.
|
||||
|
||||
:- import_module io.
|
||||
|
||||
|
||||
|
||||
:- pred main(io__state::di, io__state::uo) is det.
|
||||
|
||||
% ---------------------------------------------------------------------------- %
|
||||
% ---------------------------------------------------------------------------- %
|
||||
|
||||
:- implementation.
|
||||
|
||||
:- import_module int, require.
|
||||
|
||||
% ---------------------------------------------------------------------------- %
|
||||
|
||||
main -->
|
||||
io__read_byte(Result),
|
||||
( { Result = ok(X) }, io__write_byte(rot13(X)), main
|
||||
; { Result = eof }
|
||||
; { Result = error(ErrNo)}, { error(io__error_message(ErrNo)) }
|
||||
).
|
||||
|
||||
% ---------------------------------------------------------------------------- %
|
||||
|
||||
:- func rot13(int) = int.
|
||||
|
||||
rot13(X) =
|
||||
( if 0'a =< X, X =< 0'z then Rot13(X, 0'a)
|
||||
else if 0'A =< X, X =< 0'Z then Rot13(X, 0'A)
|
||||
else X
|
||||
)
|
||||
:-
|
||||
Rot13 = ( func(C, A) = ((13 + C - A) `rem` 26) + A ).
|
||||
|
||||
% ---------------------------------------------------------------------------- %
|
||||
% ---------------------------------------------------------------------------- %
|
||||
Reference in New Issue
Block a user