In my very first attempt, I tried to port a package which sounds to me like the one you describe. In the examples there was a snoopy world as a search example, maybe you recall it from that. �However I realized that I didn't want to emulate Prolog in Pharo; nothing like fast�compiled and optimized code for WAM.�
The idea was to emulate the language boxes of Helvetia to mix Prolog and Smalltalk code and use NativeBoost to call the swi-prolog shared library, so I could use a highly deployed version of Prolog. �Some time ago I made an inquiry and for handling some text highlighting issues that would help in my aims, just for a direct reference, the code is below:
| text textRenderer textShower |
text := 'p(Q,R):-q(R), unify_st(X, smalltalk_code), r(T).
q(Q):-d(R).
q(Q).'.
textRenderer := [
PPTextHighlighter new
parser: PPPrologParser new;
color: 'small_atom' with: Color blue muchDarker;
bold: 'small_atom';
color: 'unify_st' with: Color green muchDarker;
bold: 'unify_st';
color: 'string' with: Color gray muchDarker;
color: 'number' with: Color gray muchDarker;
color: 'boolean' with: Color gray muchDarker;
highlight: text asText.
].
" � � � � � � � �__ � � �
� � � � � � � � � �|
� � � � �<Renders IN>
� �|
� W
GLMTextPresentation
� � |
�� <Renders IN>
� �|
�W
GLMMorphicRenderer
"
textShower := GLMMorphicRenderer new.
(textShower open: (
GLMTextPresentation new display: textRenderer; renderGlamorouslyOn: textShower; yourself )) window title: 'Prolog Editor'.�
"Here I created a highlighter through the transform method of the grammar"
grammar := PPPrologParser new.
highlighter := grammar transform: [ :parser |
Transcript show: parser.
parser class = TokenParser�
ifTrue: [ parser ==> [ :token |
textShower model highlight: token style range: token interval ] ]
ifFalse: [ parser ] ].�
text := 'p(Q,R):-q(R), unify_st(X, smalltalk_code), r(T).
q(Q):-d(R).
q(Q).'.
pp := highlighter parse: text asText.
However, as I said, it was too much work to create everything from scratch, so I decided only to impose queries and the result looks pretty much as the code I provided in my previous post.�
I omitted one detail however; I am using a python bridge through the pyswi library which does pretty much was I was trying to achieve with NativeBoost. It is a RPC-JSON server which handles the interaction between Pharo and Prolog and retrieves the query results in a JSON dictionary.
At about that time I also was looking at Logtalk (logtalk.org) �for SWI and maybe waiting for XSB ... as our manager would not go for iLOG and we were VisualWorks only ... then IBM bought iLOG and something odd happened to Prologia with Air Liquide in France.
Logtalk is pretty much what I wanted to achieve, but the OOP language would be Pharo�instead. I still think it would be good to make some effort towards creating such a framework, if I can call it like that.
You may know about the prolog for Smalltalk/DOS of about 1990 vintage �... I must have it on a floppy in a box somewhere on a shelf.
I would be interesting to have a look. Please send me a copy to this email if you find it.�
Cheers,�
Jesus