Skip to content

Commit

Permalink
Idris: Fixed import statements (#3115)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Oct 5, 2021
1 parent d359eea commit 15cb3b7
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 15 deletions.
14 changes: 10 additions & 4 deletions components/prism-idris.js
Expand Up @@ -3,11 +3,17 @@ Prism.languages.idris = Prism.languages.extend('haskell', {
pattern: /(?:(?:--|\|\|\|).*$|\{-[\s\S]*?-\})/m,
},
'keyword': /\b(?:Type|case|class|codata|constructor|corecord|data|do|dsl|else|export|if|implementation|implicit|import|impossible|in|infix|infixl|infixr|instance|interface|let|module|mutual|namespace|of|parameters|partial|postulate|private|proof|public|quoteGoal|record|rewrite|syntax|then|total|using|where|with)\b/,
'import-statement': {
pattern: /(^\s*)import\s+(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*/m,
lookbehind: true
},
'builtin': undefined
});

Prism.languages.insertBefore('idris', 'keyword', {
'import-statement': {
pattern: /(^\s*import\s+)(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*/m,
lookbehind: true,
inside: {
'punctuation': /\./
}
}
});

Prism.languages.idr = Prism.languages.idris;
2 changes: 1 addition & 1 deletion components/prism-idris.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion tests/languages/idris/import_statement_feature.test
@@ -1,10 +1,18 @@
import Foo
import Maths.NumOps

----------------------------------------------------

[
["keyword", "import"],
["constant", ["Foo"]]
["import-statement", ["Foo"]],

["keyword", "import"],
["import-statement", [
"Maths",
["punctuation", "."],
"NumOps"
]]
]

----------------------------------------------------
Expand Down
94 changes: 85 additions & 9 deletions tests/languages/idris/keyword_feature.test
@@ -1,17 +1,93 @@
case data do else if implementation
in infixl infixr interface let
module of then where
Type
case
class
codata
constructor
corecord
data
do
dsl
else
export
if
implementation
implicit
import
impossible
in
infix
infixl
infixr
instance
interface
let
module
mutual
namespace
of
parameters
partial
postulate
private
proof
public
quoteGoal
record
rewrite
syntax
then
total
using
where
with

----------------------------------------------------

[
["keyword", "case"], ["keyword", "data"], ["keyword", "do"],
["keyword", "else"], ["keyword", "if"], ["keyword", "implementation"],
["keyword", "in"], ["keyword", "infixl"], ["keyword", "infixr"],
["keyword", "interface"], ["keyword", "let"], ["keyword", "module"],
["keyword", "of"], ["keyword", "then"], ["keyword", "where"]
["keyword", "Type"],
["keyword", "case"],
["keyword", "class"],
["keyword", "codata"],
["keyword", "constructor"],
["keyword", "corecord"],
["keyword", "data"],
["keyword", "do"],
["keyword", "dsl"],
["keyword", "else"],
["keyword", "export"],
["keyword", "if"],
["keyword", "implementation"],
["keyword", "implicit"],
["keyword", "import"],
["keyword", "impossible"],
["keyword", "in"],
["keyword", "infix"],
["keyword", "infixl"],
["keyword", "infixr"],
["keyword", "instance"],
["keyword", "interface"],
["keyword", "let"],
["keyword", "module"],
["keyword", "mutual"],
["keyword", "namespace"],
["keyword", "of"],
["keyword", "parameters"],
["keyword", "partial"],
["keyword", "postulate"],
["keyword", "private"],
["keyword", "proof"],
["keyword", "public"],
["keyword", "quoteGoal"],
["keyword", "record"],
["keyword", "rewrite"],
["keyword", "syntax"],
["keyword", "then"],
["keyword", "total"],
["keyword", "using"],
["keyword", "where"],
["keyword", "with"]
]

----------------------------------------------------

Checks for some keywords.
Checks for some keywords.

0 comments on commit 15cb3b7

Please sign in to comment.