lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


As for UI design, my friends and I have found using IUP (http://www.tecgraf.puc-rio.br/iup/) to work well, providing new functions with the interface provided by the module for using the UI in other environments.

-----Original Message----- From: Silas Silva Sent: Thursday, September 02, 2010 P9:55 Newsgroups: gmane.comp.lang.lua.general
To: lua-l@lists.lua.org
Subject: C with embedded Lua or Lua-only program?

Hi all,

I've been done some research for a project of mine, regarding
"embeddable" languages to make it extensible, and figured out that Lua
would be the best solution for this particular situation.

My question is:  Lua is a language made to be embedded (like Tcl and
Guile -- not sure about the last one), not like Python or Perl, which
make it perfect to be used as a scripting language in a C program.  But,
over the time, lots of libraries were built on the top of Lua, that
makes it a great general-purpose language.  Should I make a C + Lua
program or only Lua?  Let me explain my problem:

Over the years, I've done some GUI applications in several ways: using
Tk, Qt, HTML forms, ncurses etc.  But never found a uniform way to
specify a GUI and generate the resulting code for a language/toolkit
combination.  I didn't find anything like that on the internet (please,
tell me if I'm wrong) so I'll invent the wheel.

This program will read a file (whose content will be a description of a
GUI in a DSL (domain-specific language) that I intend to specify soon)
and generate the code.  So, basically, some would call the program in
that way:

   program --generate qt-xml < file.dsl > output.ui

   program --generate html < file.dsl > output.html

The DSL should be simple (similar to Tcl/Tk code):

   button foo -text "Foo" -x 10 -y 20
   label ...

So, I though about using Lex & Yacc in C to parse the DSL, put
everything in well defined data structures and generate the output.  The
generation rules would be in Lua scripts, something like (for HTML):

   -- Oversimplified example
   function button()
       print("<input type=submit>")
   end

So, my questions are:

1. Is there any replacement for lex/flex & yacc/bison for Lua?  How do
  you design DSLs in Lua?  I thought about using Lex & Yacc + C it is a
  long standing wish of mine to learn parsers, BNF with Lex & Yacc...

2. I was thinking that it would be interesting to make the DSL
  Turing-complete, to make it easily programmable.  Use Lua itself as
  the DSL would solve this problem, but what about if I need different
  syntax not present in Lua, like in "button foo ..."?

3. Is there any reason about why to develop it in C + Lua instead of Lua
  only?

4. Am I reinventing the wheel?  If yes, could you point me to open
  source solutions on this problem?

Thank you very much.

--
Silas Silva