Skip to content

Commit

Permalink
Merge pull request #1922 from razum2um/master
Browse files Browse the repository at this point in the history
Clojure: allow fullqualified function definition
  • Loading branch information
masatake authored Oct 20, 2018
2 parents 45968ef + a761eaf commit 836df9d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions Units/parser-clojure.r/simple-clojure.d/expected.tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
another.name input.clj /^(ns another.name)$/;" n
app.controller input.clj /^(ns app.controller)$/;" n
core-function-with-body input.clj /^(clojure.core\/defn core-function-with-body []$/;" f namespace:app.controller
empty-fn input.clj /^ (defn empty-fn [])$/;" f namespace:app.controller
function-with-body input.clj /^(defn function-with-body []$/;" f namespace:app.controller
x input.clj /^(defn x [])$/;" f namespace:another.name
3 changes: 3 additions & 0 deletions Units/parser-clojure.r/simple-clojure.d/input.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
(defn function-with-body []
(println "body"))

(clojure.core/defn core-function-with-body []
(println "core"))

'(defn quoted-function [])
(quote quoted-function2 [])

Expand Down
9 changes: 7 additions & 2 deletions parsers/clojure.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ static int isNamespace (const char *strp)

static int isFunction (const char *strp)
{
return strncmp (++strp, "defn", 4) == 0 && isspace (strp[4]);
return (strncmp (++strp, "defn", 4) == 0 && isspace (strp[4])); // || (strncmp (++strp, "clojure.core/defn", 17) == 0 && isspace (strp[17]));
}

static int isCoreFunction (const char *strp)
{
return (strncmp (++strp, "clojure.core/defn", 17) == 0 && isspace (strp[17]));
}

static int isQuote (const char *strp)
Expand Down Expand Up @@ -154,7 +159,7 @@ static void findClojureTags (void)
skipToSymbol (&p);
scope_index = makeNamespaceTag (name, p);
}
else if (isFunction (p))
else if (isFunction (p) || isCoreFunction (p))
{
skipToSymbol (&p);
makeFunctionTag (name, p, scope_index);
Expand Down

0 comments on commit 836df9d

Please sign in to comment.