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

Idris: Fixed import statements #3115

Merged
merged 2 commits into from Oct 5, 2021
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
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.