From 5037dd5add3ddfe32c117d98ecb2c3f60c182745 Mon Sep 17 00:00:00 2001 From: Ricky Elrod Date: Thu, 31 Oct 2013 02:06:25 -0400 Subject: [PATCH] Add Idris. This adds Idris into the mix and uses the text-only parser for now, pending upstream merging this patch in: https://bitbucket.org/birkenfeld/pygments-main/pull-request/210/idris-lexer-added-lexer-for-idris/diff Once that gets merged in, the lexer should change to idris. --- lib/linguist/languages.yml | 7 +++++++ samples/Idris/Chars.idr | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 samples/Idris/Chars.idr diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index a627bf46..254a23bb 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -628,6 +628,13 @@ INI: - .properties primary_extension: .ini +Idris: + type: programming + lexer: Text only + primary_extension: .idr + extensions: + - .lidr + Inno Setup: primary_extension: .iss lexer: Text only diff --git a/samples/Idris/Chars.idr b/samples/Idris/Chars.idr new file mode 100644 index 00000000..7e3e3e86 --- /dev/null +++ b/samples/Idris/Chars.idr @@ -0,0 +1,42 @@ +module Prelude.Char + +import Builtins + +isUpper : Char -> Bool +isUpper x = x >= 'A' && x <= 'Z' + +isLower : Char -> Bool +isLower x = x >= 'a' && x <= 'z' + +isAlpha : Char -> Bool +isAlpha x = isUpper x || isLower x + +isDigit : Char -> Bool +isDigit x = (x >= '0' && x <= '9') + +isAlphaNum : Char -> Bool +isAlphaNum x = isDigit x || isAlpha x + +isSpace : Char -> Bool +isSpace x = x == ' ' || x == '\t' || x == '\r' || + x == '\n' || x == '\f' || x == '\v' || + x == '\xa0' + +isNL : Char -> Bool +isNL x = x == '\r' || x == '\n' + +toUpper : Char -> Char +toUpper x = if (isLower x) + then (prim__intToChar (prim__charToInt x - 32)) + else x + +toLower : Char -> Char +toLower x = if (isUpper x) + then (prim__intToChar (prim__charToInt x + 32)) + else x + +isHexDigit : Char -> Bool +isHexDigit x = elem (toUpper x) hexChars where + hexChars : List Char + hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F']