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 implementations are appropriate?--- Synchronet 3.20a-Linux NewsLink 1.114
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: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>
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 implementations are appropriate?
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)..Ah, now I see what job you are here for...
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 modified to use "records" instead of "dicts" (https://swi-prolog.discourse.group/t/dealing-with-state/6866/50).
You might find it more productive to discuss in https://swi-prolog.discourse.group rather than here.
On Saturday, 28 October 2023 at 19:03:45 UTC+2, peter.l...@gmail.com wrote: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.
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 implementations are appropriate?
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 modified to use "records" instead of "dicts" (https://swi-prolog.discourse.group/t/dealing-with-state/6866/50).
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--- Synchronet 3.20a-Linux NewsLink 1.114
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:
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 still around here and kicking, in fact almost the only active user left.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 miss the good old days of the "Prolog Digest" with Chuck Restivo, The Moderator)
On Sunday, 29 October 2023 at 01:18:24 UTC+2, peter.l...@gmail.com wrote:--- Synchronet 3.20a-Linux NewsLink 1.114
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 miss the good old days of the "Prolog Digest" with Chuck Restivo, The Moderator)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 still 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 understand--- Synchronet 3.20a-Linux NewsLink 1.114
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. (I miss the good old days of the "Prolog Digest" with Chuck Restivo, The Moderator)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 still 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
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 919 |
Nodes: | 10 (1 / 9) |
Uptime: | 73:14:50 |
Calls: | 12,186 |
Calls today: | 1 |
Files: | 186,526 |
Messages: | 2,236,773 |