Re: [BangPypers] Language Parsing and output generation

2011-08-24 Thread Gopalakrishnan Subramani
This is not about running Lua inside Python or Python inside Lua. I will go
thorough few of tools you all mentioned and will back.

Making a grammar is really fun. I am more curious to know how the AST would
turn to be.

--

Gopal



On Tue, Aug 23, 2011 at 3:04 AM, Anand Balachandran Pillai 
abpil...@gmail.com wrote:

 On Tue, Aug 23, 2011 at 11:15 AM, Gopalakrishnan Subramani 
 gopalakrishnan.subram...@gmail.com wrote:

  I could make a grammar compiled myself. I will look into SPARK.. Anybody
  has
  experience in pyparsing http://pyparsing.wikispaces.com/ ?
  Under Examples http://pyparsing.wikispaces.com/Examples Python language
  example is promising.
 

 Have you taken a look at Lunatic Python ?

 http://labix.org/lunatic-python

 Looks like it already provides the required interfaces you need.



 
  Regards,
 
  Gopal
 
 
  On Mon, Aug 22, 2011 at 11:25 PM, Noufal Ibrahim nou...@gmail.com
 wrote:
 
   Gopalakrishnan Subramani gopalakrishnan.subram...@gmail.com writes:
  
Source language IO is very limited and it has functions to map to IO
  and
   UI.
As a total, they have around 100+ function.
   
Those can be easily done in Lua.
  
   [...]
  
   For a project in one of my earlier companies, I used SPARK[1] to write
 a
   little parser for a language of my own making to used to specify some
   conditionals.
  
   The parser would convert this into a python expression which could be
   evaluated with some objects to return a true or a false.
  
   If you have the grammar of your source language at hand, it's a fews
   hours job to write a parser for it using SPARK. Once you do that, you
   have to write a backend to convert it into LUA which might be a little
   more complex but not impossibly so.
  
  
  
  
   Footnotes:
   [1]  http://pages.cpsc.ucalgary.ca/~aycock/spark/
  
   --
   ~noufal
   http://nibrahim.net.in
  
   An empty cab drove up and Sarah Bernhardt got out. -Arthur Baer,
 American
   comic and columnist
   ___
   BangPypers mailing list
   BangPypers@python.org
   http://mail.python.org/mailman/listinfo/bangpypers
  
  ___
  BangPypers mailing list
  BangPypers@python.org
  http://mail.python.org/mailman/listinfo/bangpypers
 



 --
 --Anand
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Language Parsing and output generation

2011-08-23 Thread Balachandran Sivakumar
Hi,

On Tue, Aug 23, 2011 at 12:39 AM, Gopalakrishnan Subramani
gopalakrishnan.subram...@gmail.com wrote:

 The idea is to convert the 'Description Language' code to Lua code using
 Python. This involves 2 things. One is parsing and another is generation. In
 between 2, I need to make a tree as a output from parser, kind of AST.


   LLVM is a good tool for such stuff. llvm-py is the one with
python bindings. The original LLVM site has good tutorials and
examples.

Project URL: http://www.mdevan.org/llvm-py/


-- 
Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.

Mail: benignb...@gmail.com
Blog: http://benignbala.wordpress.com/
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Language Parsing and output generation

2011-08-23 Thread Anand Balachandran Pillai
On Tue, Aug 23, 2011 at 11:15 AM, Gopalakrishnan Subramani 
gopalakrishnan.subram...@gmail.com wrote:

 I could make a grammar compiled myself. I will look into SPARK.. Anybody
 has
 experience in pyparsing http://pyparsing.wikispaces.com/ ?
 Under Examples http://pyparsing.wikispaces.com/Examples Python language
 example is promising.


Have you taken a look at Lunatic Python ?

http://labix.org/lunatic-python

Looks like it already provides the required interfaces you need.




 Regards,

 Gopal


 On Mon, Aug 22, 2011 at 11:25 PM, Noufal Ibrahim nou...@gmail.com wrote:

  Gopalakrishnan Subramani gopalakrishnan.subram...@gmail.com writes:
 
   Source language IO is very limited and it has functions to map to IO
 and
  UI.
   As a total, they have around 100+ function.
  
   Those can be easily done in Lua.
 
  [...]
 
  For a project in one of my earlier companies, I used SPARK[1] to write a
  little parser for a language of my own making to used to specify some
  conditionals.
 
  The parser would convert this into a python expression which could be
  evaluated with some objects to return a true or a false.
 
  If you have the grammar of your source language at hand, it's a fews
  hours job to write a parser for it using SPARK. Once you do that, you
  have to write a backend to convert it into LUA which might be a little
  more complex but not impossibly so.
 
 
 
 
  Footnotes:
  [1]  http://pages.cpsc.ucalgary.ca/~aycock/spark/
 
  --
  ~noufal
  http://nibrahim.net.in
 
  An empty cab drove up and Sarah Bernhardt got out. -Arthur Baer, American
  comic and columnist
  ___
  BangPypers mailing list
  BangPypers@python.org
  http://mail.python.org/mailman/listinfo/bangpypers
 
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers




-- 
--Anand
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Language Parsing and output generation

2011-08-22 Thread Senthil Kumaran
On Mon, Aug 22, 2011 at 01:09:19PM -0600, Gopalakrishnan Subramani wrote:
 I prefer Python for this conversion. Any idea is appreciated.

In your source language, do you have tools to create AST? If not, then
it would be the first thing to aim for. Then you need a mechanism to
translate that AST to the target language specs.

There is a lot of compiler theory involved in this problem, unless
your source language really really very minimal (just I/O, conditional
and looping) and in which case you do a literal translation to the
other language and see it works.


-- 
Senthil
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Language Parsing and output generation

2011-08-22 Thread Gopalakrishnan Subramani
Source language IO is very limited and it has functions to map to IO and UI.
As a total, they have around 100+ function.

Those can be easily done in Lua.


--

Gopal

On Mon, Aug 22, 2011 at 6:10 PM, Senthil Kumaran sent...@uthcode.comwrote:

 On Mon, Aug 22, 2011 at 01:09:19PM -0600, Gopalakrishnan Subramani wrote:
  I prefer Python for this conversion. Any idea is appreciated.

 In your source language, do you have tools to create AST? If not, then
 it would be the first thing to aim for. Then you need a mechanism to
 translate that AST to the target language specs.

 There is a lot of compiler theory involved in this problem, unless
 your source language really really very minimal (just I/O, conditional
 and looping) and in which case you do a literal translation to the
 other language and see it works.


 --
 Senthil
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Language Parsing and output generation

2011-08-22 Thread Gopalakrishnan Subramani
I could make a grammar compiled myself. I will look into SPARK.. Anybody has
experience in pyparsing http://pyparsing.wikispaces.com/ ?
Under Examples http://pyparsing.wikispaces.com/Examples Python language
example is promising.

Regards,

Gopal


On Mon, Aug 22, 2011 at 11:25 PM, Noufal Ibrahim nou...@gmail.com wrote:

 Gopalakrishnan Subramani gopalakrishnan.subram...@gmail.com writes:

  Source language IO is very limited and it has functions to map to IO and
 UI.
  As a total, they have around 100+ function.
 
  Those can be easily done in Lua.

 [...]

 For a project in one of my earlier companies, I used SPARK[1] to write a
 little parser for a language of my own making to used to specify some
 conditionals.

 The parser would convert this into a python expression which could be
 evaluated with some objects to return a true or a false.

 If you have the grammar of your source language at hand, it's a fews
 hours job to write a parser for it using SPARK. Once you do that, you
 have to write a backend to convert it into LUA which might be a little
 more complex but not impossibly so.




 Footnotes:
 [1]  http://pages.cpsc.ucalgary.ca/~aycock/spark/

 --
 ~noufal
 http://nibrahim.net.in

 An empty cab drove up and Sarah Bernhardt got out. -Arthur Baer, American
 comic and columnist
 ___
 BangPypers mailing list
 BangPypers@python.org
 http://mail.python.org/mailman/listinfo/bangpypers

___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers