-
Notifications
You must be signed in to change notification settings - Fork 629
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
Request: Prolog Parser #2628
Comments
SWI Prolog syntax grammar/BNF? http://swi-prolog.996271.n3.nabble.com/SWI-Prolog-syntax-grammar-BNF-td11598.html |
SWI Prolog provide a clone of Emacs that (I believe*) parses Prolog: https://www.swi-prolog.org/pldoc/man?section=pceemacs https://en.wikipedia.org/wiki/SWI-Prolog#PceEmacs
|
Thank you. I will write an initial minimum version of prolog parser. Taken from [1]:
What kind of tags output do you expect? |
Hey Masatake, Cheers for coming back so quickly. I'll read #2622. Thanks also for your efforts writing the minimum parser. I'll do what I can to complete it, though will probably need assistance. |
I'm not that familiar with ctags, so may not answer your question correctly. Tags: predicates: mother_child, father_child etc. Translation from Prolog speak: "predicates" -> method (Prolog has no functions) String -> string (text surrounded with ", Text surrounded with ' are treated as an atom. |
I note that Prolog defines modules [1], for example: 36 :- module(charsio, Is the definition for the module 'charsio' [2]. Predicates listed in the list (from line 37 onwards) are added to the global namespace. Predicates not listed are still accessible, by prepending the module name. For example charsio:some_other_predicate. Fyi, the number following the predicate name (e.g. atom_to_chars/3) is the arity; it specifies the number of arguments.... [1] https://www.swi-prolog.org/pldoc/man?section=modules |
If you have the time, here is a quick intro to Prolog: https://www.youtube.com/watch?v=SykxWpFwMGs It's 1 hour long, but you wouldn't need to watch anything like that much to see most of the syntax... |
Thank you but prolog knowledge is enough. |
Let's focus on smaller input:
What should be tagged? |
Here's the syntax doco fro Gnu Prolog: |
I'm not that familiar with ctags yet. I can read more to be more helpful. From what I know now, "mother_child" would be tagged as the equivalent of a C method, trude and sally as the equivalent of C strings. ... would it be helpful for me to write an "equivalent" C program and run it through u-ctags xref...? My C is rusty, but it would be something like:
I know this isn't valid C; but trude and sally aren't variables here. By comparison,
would be:
in Prolog. |
O.k. I wrote minimum version of prolog parser.
Is this the same as what you expect? |
That was quick! |
... I also think I see what you're doing. I can build on that... |
Let's extend the input a bit.
The first question is I guess you may want to have a arity: field like:
Am I correct? if yes, what I should do for the input:
Is the arity for mother_child 1 or 2? |
It shoud be tagged twice; they're multiple definitions of the predicate (method).
Maybe, though I'm not sure how that would be used. Arity is just the count of predicate arguments...
2 - the size of the argument list [ trude, Name ]. Everything after the :- is the "implementation" (in C terms... 😄 ). |
|
I guess arity field and signature field should be filled. |
Feel free to reopen this. |
Creating an issue for extending universal-ctags to handle Prolog [1].
... as per Masatake's request [2]
[1] https://en.wikipedia.org/wiki/Prolog
[2] #1566 (comment)
The text was updated successfully, but these errors were encountered: