FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

c++ translator/analyser: sponsorship?

 
Post new topic   Reply to topic     Forum Index -> The Language Machine
View previous topic :: View next topic  
Author Message
mpah



Joined: 18 Jul 2005
Posts: 29
Location: UK

PostPosted: Thu Dec 15, 2005 5:07 am    Post subject: c++ translator/analyser: sponsorship? Reply with quote

I am thinking of using the language machine to write a translator/analyser for c++, almost certainly with D as the first target language. This idea is partly triggered by the evidence from viewing figures here of interest in what Remy Moueza has done on the basis of the d2d translator.

Remy has done something which is useful to him as a conversion tool, but which doesn't do the whole thing. To do that, it would have to deal with the detail of variable types, classes, templates etc. Its a fairly large task, mainly just understanding in detail what all that c++ means.

If anyone sees ways of sponsoring such a project, that would certainly help it along.
_________________
The Language Machine - a toolkit for language and grammar
Back to top
View user's profile Send private message
gamerChad



Joined: 13 Aug 2005
Posts: 21
Location: Cydonia, Mars

PostPosted: Sat Mar 25, 2006 3:35 pm    Post subject: Reply with quote

Sorry I don't have any way to get sponsorship of this.

I'm just posting to say that I love this idea and want to see it happen.

If this needs extra coding work to get done, I'd be happy to help. Of course, I am having trouble wrapping my head around The Language Machine, and I'd be learning a lot of the C++ stuff along the way, but this is pretty damn important to me so I am willing to put time into it.
Back to top
View user's profile Send private message
mpah



Joined: 18 Jul 2005
Posts: 29
Location: UK

PostPosted: Sun Mar 26, 2006 9:23 am    Post subject: Reply with quote

Hi gamerChad - Good to know you are interested - I've developed some tools to translate some standard syntax notations to LMN which may help get things started.

I've also made a start with converting the d2d translator for use as a java-to-d translator. But as I said to Remy, full C++ to D is relatively hard.

I am interested to know how you get on with the language machine - if you have questions, do post them here or on the sourceforge mailing list.

I hope to post the syntax and java-to-d stuff with some more introductory material soon.
_________________
The Language Machine - a toolkit for language and grammar
Back to top
View user's profile Send private message
gamerChad



Joined: 13 Aug 2005
Posts: 21
Location: Cydonia, Mars

PostPosted: Tue Mar 28, 2006 4:31 am    Post subject: Reply with quote

Hey just thought I'd drop in and let you know where I'm at.

It's been a couple months since I messed with the language machine, and apparently DMD no longer compiles the D code that lmn throws out. In hindsight, I could have just used C or something, but I just had to fix the thing. I found out that it was because "scope" is now a keyword in D (see http://www.digitalmars.com/d/changelog.html#new0149). So my solution was just to replace all instances of "scope" with "lmScope", making sure lmScope wasn't already taken of course. May not be the best thing to rename it, but it made the stuff compile.

That done, my state of knowledge in all things LMN is still a very sad sad thing. I'm still trying to figure out what "<-" does. AFAIK it replaces the thing on the left with the thing on the right.

I think my problem is that when I see something like "- out <- eof - ;" I can't really figure out much besides what that means as a whole. What that does as a whole is usually explained very well. But the individual parts like "<-" and the hyphens, I still don't understand either what each of those do, or how they fit into the larger picture. Also, what is control flow like in LMN? Does control flow even make sense in LMN?

Maybe it would help if I had a simple example that isolates a lot of the special symbols. Like something that would take a text file and replace all instances of "cat" with "dog" and spew the results onto whatever output seems most intuitive in LMN. Seeing this stuff in action in a direct way would help me out a lot, I think.
Back to top
View user's profile Send private message
mpah



Joined: 18 Jul 2005
Posts: 29
Location: UK

PostPosted: Tue Mar 28, 2006 12:32 pm    Post subject: Reply with quote

A question about "scope" - I take it you changed "scope" to "lmScope" in the D source of the the engine itself. The name's fine - I must do the same.

Each rule recognises a pattern described by the left-side (everything before the "<-") and replaces it by a pattern described by the right-side (everything after the "<-", upto ";").

The diagram shows how recognition and substitution phases nest independently but interlock where symbols match. Think DNA or some kind of zipper device.

There are in effect two closely coupled threads of control flow: one for the left-side, one for the right-side. So you can write conditionals etc on either side - each side is in effect a pattern generator.

Control flow overall is depends on which rules are tried. The key event is the mismatch event.

There's a summary at

http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/36018

and a not-quite-finished PDF at

http://languagemachine.sf.net/language_machine_notes.pdf

The case you mention is too easy:

Code:
 
  - out      <- eof - ;
  'cat'      <- eof -  'dog' ;


1st rule: we're looking for "eof". Never mind what input symbol we have, try this rule if you have to (it's a top-down rule, and so will be tried only if no specific or bottom-up rules apply). "out" is a special symbol - matches anything, with side-effect of sending it to the output stream. Never mind that the rule promised to subsitute "eof", it substitutes nothing. We're still looking for "eof".

2nd rule: treat 'cat' as 'dog' when looking for "eof".

You could make it more interesting:

Code:
 
  - out           <- eof - ;
  - pattern :A :B <- eof -  ' ' B ' bites ' A '!' ;
  'cat'           <- pattern :"dog"           :"pussycat";
  'zebra'         <- pattern :"stripey beast" :"flea";


So 'cat' and 'zebra' are are recognised as instances of "pattern", and each time "pattern" is matched we expect two values that we call "A" and "B", and these values are subsituted so that

asdfasdf sdfcat sdfadf zebra asdfa df

produces

asdfasdf sdf pussycat bites dog! sdfadf flea bites stripey beast! asdfa df

Try it.

HTH
Peri
_________________
The Language Machine - a toolkit for language and grammar
Back to top
View user's profile Send private message
gamerChad



Joined: 13 Aug 2005
Posts: 21
Location: Cydonia, Mars

PostPosted: Thu Mar 30, 2006 5:10 am    Post subject: Reply with quote

Cool thanks!

That helped a lot. Of course I still have much learning to do, so I'll keep on reading, and I'll post here if I have any more burning questions.

Quote:
A question about "scope" - I take it you changed "scope" to "lmScope" in the D source of the the engine itself. The name's fine - I must do the same.

I just changed it in every .d file in the /src directory.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> The Language Machine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group