Fairly new here. I am trying to use Prolog for parsing and analyzing code. Essentially I want to flatten the AST into facts so that with rules, I may query over them. I want to parse Clojure atm, but would like something general. Which Prologimplementations are appropriate?
Also relevant is this article: https://marcellerusu.com/using_prolog_as_the_ast.html
Sincerely,
Josh Cho
Stanford B.S./M.S. in Computer Science
On Friday, October 27, 2023 at 9:39:36 PM UTC-7, Josh Cho wrote:implementations are appropriate?
Fairly new here. I am trying to use Prolog for parsing and analyzing code. Essentially I want to flatten the AST into facts so that with rules, I may query over them. I want to parse Clojure atm, but would like something general. Which Prolog
Also relevant is this article: https://marcellerusu.com/using_prolog_as_the_ast.html
There's a rather old paper: "Logic Programming and Compiler Writing" by David H.D. Warren. Also Peter Van Roy's PhD thesis on the "Aquarius" compiler.
See also Abrahams and Dahl "Logic Grammars" (you can find some simple code for DCTGs on the internet, although it's a somewhat slow implementation).
I wrote some code for processing Python ASTs: https://github.com/kamahen/pykythe (pykythe.pl, predicate kynode)..modified to use "records" instead of "dicts" (https://swi-prolog.discourse.group/t/dealing-with-state/6866/50).
It has what looks like a big pattern-matching "case" statement on the various AST node types. I intend to rewrite this code somewhat, using a newer way of handling accumulators (https://swi-prolog.discourse.group/t/dealing-with-state/6866/10 but
You might find it more productive to discuss in https://swi-prolog.discourse.group rather than here.
On Saturday, October 28, 2023 at 4:10:39 PM UTC-7, Julio Di Egidio wrote:<snip>
On Saturday, 28 October 2023 at 19:03:45 UTC+2, peter.l...@gmail.com wrote:
miss the good old days of the "Prolog Digest" with Chuck Restivo, The Moderator)You might find it more productive to discuss in https://swi-prolog.discourse.group rather than here.
Ah, now I see what job you are here for...
*Troll Alert*
Nope - it's just that I don't read comp.lang.prolog often, but do read https://swi-prolog.discourse.group (moved from https://groups.google.com/g/swi-prolog), which is officially about SWI-Prolog but often has more general discussion about Prolog. (I
On Saturday, 28 October 2023 at 19:03:45 UTC+2, peter.l...@gmail.com wrote:implementations are appropriate?
On Friday, October 27, 2023 at 9:39:36 PM UTC-7, Josh Cho wrote:
Fairly new here. I am trying to use Prolog for parsing and analyzing code. Essentially I want to flatten the AST into facts so that with rules, I may query over them. I want to parse Clojure atm, but would like something general. Which Prolog
modified to use "records" instead of "dicts" (https://swi-prolog.discourse.group/t/dealing-with-state/6866/50).Also relevant is this article: https://marcellerusu.com/using_prolog_as_the_ast.html
There's a rather old paper: "Logic Programming and Compiler Writing" by David H.D. Warren. Also Peter Van Roy's PhD thesis on the "Aquarius" compiler.Parsing is a typical application for Prolog and there is a ton of material available online at all levels: <https://start.duckduckgo.com/?q=Prolog+parsing+AST>
See also Abrahams and Dahl "Logic Grammars" (you can find some simple code for DCTGs on the internet, although it's a somewhat slow implementation).
I wrote some code for processing Python ASTs: https://github.com/kamahen/pykythe (pykythe.pl, predicate kynode)..
It has what looks like a big pattern-matching "case" statement on the various AST node types. I intend to rewrite this code somewhat, using a newer way of handling accumulators (https://swi-prolog.discourse.group/t/dealing-with-state/6866/10 but
You might find it more productive to discuss in https://swi-prolog.discourse.group rather than here.Ah, now I see what job you are here for...
*Troll Alert*
Julio
On Sunday, 29 October 2023 at 01:18:24 UTC+2, peter.l...@gmail.com wrote:miss the good old days of the "Prolog Digest" with Chuck Restivo, The Moderator)
On Saturday, October 28, 2023 at 4:10:39 PM UTC-7, Julio Di Egidio wrote:<snip>
On Saturday, 28 October 2023 at 19:03:45 UTC+2, peter.l...@gmail.com wrote:
You might find it more productive to discuss in https://swi-prolog.discourse.group rather than here.
Ah, now I see what job you are here for...
*Troll Alert*
Nope - it's just that I don't read comp.lang.prolog often, but do read https://swi-prolog.discourse.group (moved from https://groups.google.com/g/swi-prolog), which is officially about SWI-Prolog but often has more general discussion about Prolog. (I
I don't believe you, especially considering the actual history and why we are where we are. Anyway, as an old timer, you should at least know that pointing users somewhere else is very poor etiquette to say the least: especially since I for one amstill around here and kicking, in fact almost the only active user left.
But I'm an optimist, I might be wrong: let's see what happens next.
Julio
Says the guy with no brains, who even doesnt understandI miss the good old days of the "Prolog Digest" with Chuck Restivo, The Moderator)
simple call/1 examples. The contrary of alive and kicking.
More a brain dead Prolog zombie about to desintegrate.
LoL
Julio Di Egidio schrieb am Sonntag, 29. Oktober 2023 um 01:24:50 UTC+2:
On Sunday, 29 October 2023 at 01:18:24 UTC+2, peter.l...@gmail.com wrote:
On Saturday, October 28, 2023 at 4:10:39 PM UTC-7, Julio Di Egidio wrote:<snip>
On Saturday, 28 October 2023 at 19:03:45 UTC+2, peter.l...@gmail.com wrote:
You might find it more productive to discuss in https://swi-prolog.discourse.group rather than here.
Ah, now I see what job you are here for...
*Troll Alert*
Nope - it's just that I don't read comp.lang.prolog often, but do read https://swi-prolog.discourse.group (moved from https://groups.google.com/g/swi-prolog), which is officially about SWI-Prolog but often has more general discussion about Prolog. (
still around here and kicking, in fact almost the only active user left.I don't believe you, especially considering the actual history and why we are where we are. Anyway, as an old timer, you should at least know that pointing users somewhere else is very poor etiquette to say the least: especially since I for one am
But I'm an optimist, I might be wrong: let's see what happens next.
Julio
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 493 |
Nodes: | 16 (2 / 14) |
Uptime: | 22:04:23 |
Calls: | 9,726 |
Calls today: | 16 |
Files: | 13,741 |
Messages: | 6,182,240 |