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

Add julia parser #2654

Merged
merged 2 commits into from
Nov 23, 2020
Merged

Add julia parser #2654

merged 2 commits into from
Nov 23, 2020

Conversation

getzze
Copy link
Contributor

@getzze getzze commented Oct 2, 2020

Tested with Geany (geany/geany#2584)

@coveralls
Copy link

coveralls commented Oct 2, 2020

Coverage Status

Coverage increased (+0.1%) to 87.187% when pulling 09796eb on getzze:julia into f048404 on universal-ctags:master.

parsers/julia.c Outdated Show resolved Hide resolved
parsers/julia.c Outdated Show resolved Hide resolved
@masatake
Copy link
Member

masatake commented Oct 3, 2020

I would like you to add "Julia" to docs/news.rst.

@masatake
Copy link
Member

masatake commented Oct 3, 2020

Could you add "julia.c" to win32/ctags_vs2013.vcxproj and win32/ctags_vs2013.vcxproj.filters.
Please don't put a newline at the end of the above files. Some editors put a newline at the end of editing files automatically.
In such case -p option of git add.

@masatake
Copy link
Member

masatake commented Oct 3, 2020

Thank you for your contribution. I must say this first.

{ true, 's', "struct", "Structures" },
{ true, 't', "type", "Types" },
{ true, 'x', "unknown", "Imported name"}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In u-ctags, we use "reference tag" to tag for X in "import X" because
"import X" doesn't define X. X is defined somewhere. "import X" refers it.

See #2428,
https://docs.ctags.io/en/latest/man/ctags-lang-python.7.html, and parsrs/python.c.

As far as I can remember, I don't write any document the way to make reference tags. So whether I can ask you to use a reference tag for extracting X in "import X". I can work on this topic instead of you. Tell me if I should do (after merging your parser). In such a case, what I'm afraid of is that the impact of my change to Geany.
You are working on Julia's support in Geany. Introducing reference tags may break your work partially.
To avoid it, we have to cooperate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how reference tags work. Can you explain a bit? I found it in python.c and thought it was appropriate for julia too. Just for you to know, in Julia, imports work like in python from <module> import * so I don't know if looking for definition in another file would work...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description of reference tags for users:
By default, ctags records only definition tags.
If you also want ctags to record reference tags, specify --extras=+r.
A reference tag has a kind like function, variable, etc. This is the same as definition tags.
In addition, a tag has roles. A role is a subcategory of a kind. The roles are not shown by
default. specify --fileds=+r.

x = 1
y++
def z

In this example

x ... kind:variable roles:assigned
y ... kind:variable roles:assigned,incremented
z ... kind:varaible roles:def

def in roles means z is tagged as a definition tag.
x and y have no def' in roles` field. Therefore, they are tagged as reference tags.

What kind of roles other than def is defined can be listed with --list-roles option.

$ ./ctags --list-roles=Python
#KIND(L/N) NAME               ENABLED DESCRIPTION
i/module   imported           on      imported modules
i/module   indirectlyImported on      module imported in alternative name
i/module   namespace          on      namespace from where classes/variables/functions are imported
x/unknown  imported           on      imported from the other module
x/unknown  indirectlyImported on      classes/variables/functions/modules imported in alternative name
$ ./ctags --list-roles=Python.'{module}'
#KIND(L/N) NAME               ENABLED DESCRIPTION
i/module   imported           on      imported modules
i/module   indirectlyImported on      module imported in alternative name
i/module   namespace          on      namespace from where classes/variables/functions are imported

CURRENTLY, Reference tags are not popular.
However, in a limited area, I'm pushing introducing reference tags. See #2428.

The description of reference tags for parser developers.
Follow the steps to introduce a reference tag to your parser.

  1. define a role in a kind like:
typedef enum {
	...
	K_MODULE,
	...
	COUNT_KIND
} pythonKind;

typedef enum {
	PYTHON_MODULE_IMPORTED,
	PYTHON_MODULE_NAMESPACE,
	PYTHON_MODULE_INDIRECTLY_IMPORTED,
} pythonModuleRole;

static roleDefinition PythonModuleRoles [] = {
	{ true, "imported",
	  "imported modules" },
	{ true, "namespace",
	  "namespace from where classes/variables/functions are imported" },
	{ true, "indirectlyImported",
	  "module imported in alternative name" },
};

/* if a kind is never used for making a definition tag,
   set `referenceOnly` to true. */
static kindDefinition PythonKinds[COUNT_KIND] = {
	...
	{true, 'i', "module",    "modules",
	 .referenceOnly = true,  ATTACH_ROLES(PythonModuleRoles)},
        ...
};
  1. make a referenec tag like
		tagEntryInfo e; 
		int kindIndex = K_MODULE;
		int roleIndex = PYTHON_MODULE_NAMESPACE;
		initRefTagEntry (&e, "tagNameInCString",
		                 kindIndex, roleIndex);
		...

		markTagExtraBit (&e, XTAG_REFERENCE_TAGS);

		return makeTagEntry (&e);

or

		makeSimpleRefTag (tagNameinVString, K_MODULE, PYTHON_MODULE_NAMESPACE);

@getzze
Copy link
Contributor Author

getzze commented Oct 3, 2020

Hi, thank you, I added julia.c to the 3 files you mentioned and I changed Tabs to spaces and remove trailing spaces, I hope the code is more readable like this.

@getzze
Copy link
Contributor Author

getzze commented Oct 3, 2020

Is there a library in ctag to help deal with unicode? It's because julia makes a big use of unicode identifiers and operators, so it would be good if they are well parsed (currently unicode operators are parsed as identifiers).

@masatake
Copy link
Member

masatake commented Oct 3, 2020

  • Squash the three commits into one "Add julia parser"?
  • Put the name of the author(s) of this parser

@masatake
Copy link
Member

masatake commented Oct 3, 2020

The C compiler on Windows says somthing:

parsers\julia.c(487) : error C2220: warning treated as error - no 'object' file generated
parsers\julia.c(487) : warning C4098: 'scanParenBlock' : 'void' function returning a value
parsers\julia.c(495) : warning C4098: 'scanIndexBlock' : 'void' function returning a value
parsers\julia.c(502) : warning C4098: 'scanCurlyBlock' : 'void' function returning a value
parsers\julia.c(890) : warning C4098: 'skipUntilEnd' : 'void' function returning a value

@masatake
Copy link
Member

masatake commented Oct 5, 2020

Is there a library in ctag to help deal with unicode?

No, there isn't. However, you may be able to study some from parsers/json.c.

@masatake
Copy link
Member

masatake commented Oct 5, 2020

BTW, I found an interesting document: https://docs.ctags.io/en/latest/contributions.html#
I cannot remember when I wrote this.

@masatake
Copy link
Member

masatake commented Oct 5, 2020

A test case is failed.

	............................................................
	--- ./Units/parser-julia.r/julia_test.d/expected.tags	2020-10-05 00:21:44.793096906 +0000
	+++ /root/universal-ctags/Units/parser-julia.r/julia_test.d/FILTERED.tmp	2020-10-05 00:22:41.665756917 +0000
	@@ -19,0 +20 @@
	+α	input.jl	/^    α::Real$/;"	g	struct:Test1

Your parser extracted α unexpectedly.

@masatake
Copy link
Member

masatake commented Oct 5, 2020

I tried the parser.

Run make units LANGUAGES=Julia VG=1 after installing Valgrind, Valgrind reports:

=4307== Memcheck, a memory error detector
==4307== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4307== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==4307== Command: ./ctags --verbose --options=NONE --optlib-dir=+./Units/parser-julia.r/julia_test.d/optlib -o - ./Units/parser-julia.r/julia_test.d/input.jl
==4307== Parent PID: 1693
==4307== 
==4307== 
==4307== HEAP SUMMARY:
==4307==     in use at exit: 1,072 bytes in 36 blocks
==4307==   total heap usage: 5,283 allocs, 5,247 frees, 243,323 bytes allocated
==4307== 
==4307== 56 (24 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 16
==4307==    at 0x4C2EE3B: malloc (vg_replace_malloc.c:309)
==4307==    by 0x4149CD: eMalloc (routines.c:220)
==4307==    by 0x416AAA: vStringNew (vstring.c:72)
==4307==    by 0x416AED: vStringNewCopy (vstring.c:85)
==4307==    by 0x44BD96: parseConst (julia.c:1145)
==4307==    by 0x44BD96: parseExpr (julia.c:1328)
==4307==    by 0x44BD96: findJuliaTags (julia.c:1385)
==4307==    by 0x4112A2: createTagsForFile (parse.c:3722)
==4307==    by 0x4112A2: createTagsWithFallback1 (parse.c:3844)
==4307==    by 0x4115F3: createTagsWithFallback (parse.c:3934)
==4307==    by 0x4115F3: parseMio (parse.c:4096)
==4307==    by 0x411756: parseFileWithMio (parse.c:4142)
==4307==    by 0x411883: parseFile (parse.c:4079)
==4307==    by 0x403317: createTagsForEntry (main.c:221)
==4307==    by 0x40365F: createTagsForArgs (main.c:266)
==4307==    by 0x40365F: batchMakeTags (main.c:360)
==4307==    by 0x403AE5: runMainLoop (main.c:332)
==4307==    by 0x403AE5: ctags_cli_main (main.c:585)
==4307== 
==4307== 112 (48 direct, 64 indirect) bytes in 2 blocks are definitely lost in loss record 10 of 16
==4307==    at 0x4C2EE3B: malloc (vg_replace_malloc.c:309)
==4307==    by 0x4149CD: eMalloc (routines.c:220)
==4307==    by 0x416AAA: vStringNew (vstring.c:72)
==4307==    by 0x44BB1C: parseStruct (julia.c:1235)
==4307==    by 0x44BB1C: parseExpr (julia.c:1340)
==4307==    by 0x44BB1C: findJuliaTags (julia.c:1385)
==4307==    by 0x4112A2: createTagsForFile (parse.c:3722)
==4307==    by 0x4112A2: createTagsWithFallback1 (parse.c:3844)
==4307==    by 0x4115F3: createTagsWithFallback (parse.c:3934)
==4307==    by 0x4115F3: parseMio (parse.c:4096)
==4307==    by 0x411756: parseFileWithMio (parse.c:4142)
==4307==    by 0x411883: parseFile (parse.c:4079)
==4307==    by 0x403317: createTagsForEntry (main.c:221)
==4307==    by 0x40365F: createTagsForArgs (main.c:266)
==4307==    by 0x40365F: batchMakeTags (main.c:360)
==4307==    by 0x403AE5: runMainLoop (main.c:332)
==4307==    by 0x403AE5: ctags_cli_main (main.c:585)
==4307==    by 0x583B11A: (below main) (libc-start.c:308)
==4307== 
==4307== 112 (48 direct, 64 indirect) bytes in 2 blocks are definitely lost in loss record 11 of 16
==4307==    at 0x4C2EE3B: malloc (vg_replace_malloc.c:309)
==4307==    by 0x4149CD: eMalloc (routines.c:220)
==4307==    by 0x416AAA: vStringNew (vstring.c:72)
==4307==    by 0x416AED: vStringNewCopy (vstring.c:85)
==4307==    by 0x44BB3A: parseStruct (julia.c:1245)
==4307==    by 0x44BB3A: parseExpr (julia.c:1340)
==4307==    by 0x44BB3A: findJuliaTags (julia.c:1385)
==4307==    by 0x4112A2: createTagsForFile (parse.c:3722)
==4307==    by 0x4112A2: createTagsWithFallback1 (parse.c:3844)
==4307==    by 0x4115F3: createTagsWithFallback (parse.c:3934)
==4307==    by 0x4115F3: parseMio (parse.c:4096)
==4307==    by 0x411756: parseFileWithMio (parse.c:4142)
==4307==    by 0x411883: parseFile (parse.c:4079)
==4307==    by 0x403317: createTagsForEntry (main.c:221)
==4307==    by 0x40365F: createTagsForArgs (main.c:266)
==4307==    by 0x40365F: batchMakeTags (main.c:360)
==4307==    by 0x403AE5: runMainLoop (main.c:332)
==4307==    by 0x403AE5: ctags_cli_main (main.c:585)
==4307== 
==4307== 144 (48 direct, 96 indirect) bytes in 2 blocks are definitely lost in loss record 13 of 16
==4307==    at 0x4C2EE3B: malloc (vg_replace_malloc.c:309)
==4307==    by 0x4149CD: eMalloc (routines.c:220)
==4307==    by 0x416AAA: vStringNew (vstring.c:72)
==4307==    by 0x416AED: vStringNewCopy (vstring.c:85)
==4307==    by 0x44B873: parseShortFunction (julia.c:1012)
==4307==    by 0x44BF61: parseExpr (julia.c:1352)
==4307==    by 0x44BF61: findJuliaTags (julia.c:1385)
==4307==    by 0x4112A2: createTagsForFile (parse.c:3722)
==4307==    by 0x4112A2: createTagsWithFallback1 (parse.c:3844)
==4307==    by 0x4115F3: createTagsWithFallback (parse.c:3934)
==4307==    by 0x4115F3: parseMio (parse.c:4096)
==4307==    by 0x411756: parseFileWithMio (parse.c:4142)
==4307==    by 0x411883: parseFile (parse.c:4079)
==4307==    by 0x403317: createTagsForEntry (main.c:221)
==4307==    by 0x40365F: createTagsForArgs (main.c:266)
==4307==    by 0x40365F: batchMakeTags (main.c:360)
==4307== 
==4307== 168 (72 direct, 96 indirect) bytes in 3 blocks are definitely lost in loss record 14 of 16
==4307==    at 0x4C2EE3B: malloc (vg_replace_malloc.c:309)
==4307==    by 0x4149CD: eMalloc (routines.c:220)
==4307==    by 0x416AAA: vStringNew (vstring.c:72)
==4307==    by 0x416AED: vStringNewCopy (vstring.c:85)
==4307==    by 0x44B873: parseShortFunction (julia.c:1012)
==4307==    by 0x44C0C1: parseStruct (julia.c:1276)
==4307==    by 0x44C0C1: parseExpr (julia.c:1340)
==4307==    by 0x44C0C1: findJuliaTags (julia.c:1385)
==4307==    by 0x4112A2: createTagsForFile (parse.c:3722)
==4307==    by 0x4112A2: createTagsWithFallback1 (parse.c:3844)
==4307==    by 0x4115F3: createTagsWithFallback (parse.c:3934)
==4307==    by 0x4115F3: parseMio (parse.c:4096)
==4307==    by 0x411756: parseFileWithMio (parse.c:4142)
==4307==    by 0x411883: parseFile (parse.c:4079)
==4307==    by 0x403317: createTagsForEntry (main.c:221)
==4307==    by 0x40365F: createTagsForArgs (main.c:266)
==4307==    by 0x40365F: batchMakeTags (main.c:360)
==4307== 
==4307== 224 (96 direct, 128 indirect) bytes in 4 blocks are definitely lost in loss record 15 of 16
==4307==    at 0x4C2EE3B: malloc (vg_replace_malloc.c:309)
==4307==    by 0x4149CD: eMalloc (routines.c:220)
==4307==    by 0x416AAA: vStringNew (vstring.c:72)
==4307==    by 0x44BDF4: parseImport (julia.c:1197)
==4307==    by 0x44BDF4: parseExpr (julia.c:1346)
==4307==    by 0x44BDF4: findJuliaTags (julia.c:1385)
==4307==    by 0x4112A2: createTagsForFile (parse.c:3722)
==4307==    by 0x4112A2: createTagsWithFallback1 (parse.c:3844)
==4307==    by 0x4115F3: createTagsWithFallback (parse.c:3934)
==4307==    by 0x4115F3: parseMio (parse.c:4096)
==4307==    by 0x411756: parseFileWithMio (parse.c:4142)
==4307==    by 0x411883: parseFile (parse.c:4079)
==4307==    by 0x403317: createTagsForEntry (main.c:221)
==4307==    by 0x40365F: createTagsForArgs (main.c:266)
==4307==    by 0x40365F: batchMakeTags (main.c:360)
==4307==    by 0x403AE5: runMainLoop (main.c:332)
==4307==    by 0x403AE5: ctags_cli_main (main.c:585)
==4307==    by 0x583B11A: (below main) (libc-start.c:308)
==4307== 
==4307== 256 (96 direct, 160 indirect) bytes in 4 blocks are definitely lost in loss record 16 of 16
==4307==    at 0x4C2EE3B: malloc (vg_replace_malloc.c:309)
==4307==    by 0x4149CD: eMalloc (routines.c:220)
==4307==    by 0x416AAA: vStringNew (vstring.c:72)
==4307==    by 0x44B65B: parseFunction (julia.c:1055)
==4307==    by 0x44BC99: parseExpr (julia.c:1331)
==4307==    by 0x44BC99: findJuliaTags (julia.c:1385)
==4307==    by 0x4112A2: createTagsForFile (parse.c:3722)
==4307==    by 0x4112A2: createTagsWithFallback1 (parse.c:3844)
==4307==    by 0x4115F3: createTagsWithFallback (parse.c:3934)
==4307==    by 0x4115F3: parseMio (parse.c:4096)
==4307==    by 0x411756: parseFileWithMio (parse.c:4142)
==4307==    by 0x411883: parseFile (parse.c:4079)
==4307==    by 0x403317: createTagsForEntry (main.c:221)
==4307==    by 0x40365F: createTagsForArgs (main.c:266)
==4307==    by 0x40365F: batchMakeTags (main.c:360)
==4307==    by 0x403AE5: runMainLoop (main.c:332)
==4307==    by 0x403AE5: ctags_cli_main (main.c:585)
==4307== 
==4307== LEAK SUMMARY:
==4307==    definitely lost: 432 bytes in 18 blocks
==4307==    indirectly lost: 640 bytes in 18 blocks
==4307==      possibly lost: 0 bytes in 0 blocks
==4307==    still reachable: 0 bytes in 0 blocks
==4307==         suppressed: 0 bytes in 0 blocks
==4307== 
==4307== For counts of detected and suppressed errors, rerun with: -v
==4307== ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0)

Some vStrings are not deleted.

parsers/julia.c Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 6, 2020

Codecov Report

Merging #2654 (09796eb) into master (bdeb61a) will increase coverage by 0.10%.
The diff coverage is 95.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2654      +/-   ##
==========================================
+ Coverage   86.99%   87.10%   +0.10%     
==========================================
  Files         185      186       +1     
  Lines       39465    39947     +482     
==========================================
+ Hits        34334    34796     +462     
- Misses       5131     5151      +20     
Impacted Files Coverage Δ
parsers/julia.c 95.89% <95.89%> (ø)
parsers/verilog.c 98.63% <0.00%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdeb61a...09796eb. Read the comment docs.

@masatake
Copy link
Member

masatake commented Oct 6, 2020

@getzze, though I described the way to implement reference tags, I think we can implement them in Julia later.
I think we should focus on merging the current implementation.

@masatake
Copy link
Member

masatake commented Oct 6, 2020

@getzze, could you introduce me larger git repositries where source files written in Julia are stored? (if you know)
I would like use it for testing your parser.

I would like to add the repositories to https://github.com/universal-ctags/codebase.

@getzze
Copy link
Contributor Author

getzze commented Oct 7, 2020 via email

@masatake
Copy link
Member

masatake commented Oct 7, 2020

Thank you.

@getzze
Copy link
Contributor Author

getzze commented Oct 7, 2020 via email

parsers/julia.c Outdated
/* Resets the scope string to the old length */
static void resetScope (vString *scope, size_t old_len)
{
scope->length = old_len;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use vStringTruncate() here.

@masatake
Copy link
Member

Can I take over this PR? I would like to make more minor changes.
I would like to hide or remove 'x' kind related code temporarily because we don't break the compatibilities when we implement reference tags for import and using.

@getzze
Copy link
Contributor Author

getzze commented Oct 13, 2020

@getzze, with the following input (foo.jl), ctags enters an infinite loop:

Great catch. I am not very satisfied of how short functions are parsed, because it is very prone to bugs, if you have a better implementation it would be great. The problem is to parse an = sign in the line, with an identifier followed by parenthesis before this. But there are some extra stuff, like where T construct after the parenthesis, and other problems like line continuation with long parameters.

Right now, several cases are missed:

  • Call definition of a struct, of the form:

    struct MyFunc
        x
    end
    
    (f::MyFunc)() = println(f.x)

    Expected ctag:

    (f::MyFunc)	input.jl	/^(f::MyFunc)() = println(f.x)$/;"	f   struct:MyFunc
    
  • Defining operator as short function is not recognized as a function definition:

    abstract type AdditiveType end
    
    +(a::AdditiveType, b::AdditiveType) = a

    Expected ctag:

    +	input.jl	/^+(a::AdditiveType, b::AdditiveType) = a$/;"	f
    
  • Macro preceding a function definition (python decorator equivalent), not recognized as function definition
    [EDIT: working now!]

    @inline @boundscheck f(a) = a + 1
  • Code generation using eval (probably impossible to parse with ctags):

    for op = (:sin, :cos, :tan, :log, :exp)
        eval(quote
            $op(a::MyNumber) = MyNumber($op(a.x))
        end)
    end

@masatake edited the style of indentation.

@masatake
Copy link
Member

Do you have a plan to introduce more changes?
I wrote "I will take over this PR", I would like to wait on your commits if you have a plan.

Anyway rebasing on the master branch is welcome. So reviewing becomes easier.

@getzze
Copy link
Contributor Author

getzze commented Oct 21, 2020

Sorry, I thought pulling your changes before committing would not disturb.
It was just this change. It's all yours now.

PS: the reference tags are working fine in Geany!

@masatake
Copy link
Member

Sorry, I thought pulling your changes before committing would not disturb.
It was just this change. It's all yours now.

I see.

PS: the reference tags are working fine in Geany!

Interesting. Could you tell more? I would like to know how Geany utilizes the reference tags.
Though I introduced the concept of reference tags proposed by the developer og GNU Global. I have nerver seen an application of the reference tags. What I think of is that an user of Geany can open a file, X by clicking X in "import X".

@getzze
Copy link
Contributor Author

getzze commented Oct 21, 2020

What I think of is that an user of Geany can open a file, X by clicking X in "import X".

No, this doesn't work, especially in Julia where you have several files X, for each version of the package.
But if you have the file X opened and you encounter in another file a function defined in file X, geany sends you there. But it's probably that all the tags from all the opened files are searched.
So no, it's not reference tags, sorry...

@masatake
Copy link
Member

Oh, I see. Thank you.

@masatake
Copy link
Member

Great catch. I am not very satisfied of how short functions are parsed, because it is very prone to bugs, if you have a better implementation it would be great. The problem is to parse an = sign in the line, with an identifier followed by parenthesis before this. But there are some extra stuff, like where T construct after the parenthesis, and other problems like line continuation with long parameters.

I don't understand the problem well because I don't know Julia.
I just found the infinite loop. I don't want to have such an infinite loop in ctags.

Do I have to study the syntax of Julia? In that case, it will take much more time to merge this parser.

I need examples that include input files and expected tags and actual tags.

@getzze
Copy link
Contributor Author

getzze commented Nov 19, 2020

I think you don't have to study Julia syntax, I was just trying to explain in case there was an example (that you coded for ctags) in another language where a function is defined without keyword. So that I could use it as an example for the julia parser.
But I think for now it's working good enough.

I pushed a more extensive testing unit file like you asked, it should help improve coverage too.

Do you need help from me to finish reviewing the parser?

@masatake
Copy link
Member

o.k.

Great catch. I am not very satisfied of how short functions are parsed, because it is very prone to bugs, if you have a better implementation it would be great. The problem is to parse an = sign in the line, with an identifier followed by parenthesis before this. But there are some extra stuff, like where T construct after the parenthesis, and other problems like line continuation with long parameters.

Could you show examples of the above sentences in Julia language?
You use words, "prone to bugs", "The problem is to parse", "other problems".

... I'm sorry. You already showed examples in the comment #2654 (comment). I missed the comment. I will review the changes again.

@masatake
Copy link
Member

In #2654 (comment) you showed some code examples.
Could you add Ideal tags output to the comment?

@getzze
Copy link
Contributor Author

getzze commented Nov 19, 2020

I added the expected tags in #2654 (comment).
I also factored some code in julia.c and added a test for macro definition in julia_test.d to improve coverage.

@masatake
Copy link
Member

roundtrip test harness reports a failure about alpha.
I will inspect what happens.

masatake added a commit to masatake/libreadtags that referenced this pull request Nov 20, 2020
The original bug was found when developing Juila parser in u-ctags
repo[1].  When searching a tag name "α", readtags reported nothing
though an entry for "α" was in the tags file used for testing
the Julia parser.

"α" is {206, 177} as a byte sequence.

However, when comparing bytes in strings, libreadtags used (singed)
char type. In the case "α" was {-50, -79}.  Using {-50, -79} for
comparison, the binary search didn't work as we expected.

The test for this change will be done in u-ctag side.

[1] universal-ctags/ctags#2654

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
@masatake
Copy link
Member

A bug of libreadtags causes the failures of testing on the CI environments.
I made a pull request for fixing it. universal-ctags/libreadtags#24

So please ignore the failures for a while.

@masatake masatake mentioned this pull request Nov 21, 2020
@masatake
Copy link
Member

Thank you for updating the comment. I don't know Julia. So I always need the pair (input and expected output) to understand what you write.

Obviously, we can't deal with eval. So let's forget it.

Could you rebase the changes of this pull request onto the latest HEAD of the master branch, and push --force here again?
I updated libreadtags in our source tree. As the result, the test that failed in the current code base may pass.

@masatake
Copy link
Member

Force updated.

@masatake masatake mentioned this pull request Nov 23, 2020
8 tasks
getzze and others added 2 commits November 24, 2020 00:12
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
@masatake
Copy link
Member

I would like to review code tagging language objects related to "import".
So I temporarily disabled the "unknown" kind.
#2733 is for tracking TODO items including "unknown" kind related topic.

@masatake masatake merged commit 7b8fb5d into universal-ctags:master Nov 23, 2020
@masatake
Copy link
Member

Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants