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

Is this the tool for me?



I have a complete "newbie" question.	I am trying to do
something I have never done, namely create a parser for an interperted language.  I
have an existing (legacy) code and I want to build a new parser (easier to maintain)
and add some new languange syntax to it. I am trying to determine if SableCC is the
tool I need. 
The system I am interfacing to is a geometric modelling tool that
knows about geometry (such as surfaces and solids) that have certain
attributes as well as symbols (that are like variables in any other
language)

I want to be able to create a language parser that will be able to
parse statements like a normal programming language:
 Dimension Z(3)
 Z(i) = 4*c
 A = 3*4.3 + 10.
 b = sqrt(abc)
 call routineXYZ(Objectname,x,y,z)  ! return the coordinates from an object

as well as create geometric objects such as a surface by saying
something like:
  Surf = FIT Strings CUBIC WITH TANGENT=(1,1)
  Surf:DESCRIPTOR(1) = 'this is a surface'
  xvalue = Surf:COORD(1) * 10


Where Surf is a geometric object resulting from performing the
operation FIT on Strings, and the CUBIC WITH TANGENT... describes
some optional inputs that control the type of fitting done.  Once
created, Surf then has various attributes that can either be set
(like the DESCRIPTOR) or can be evaluated and used in expressions
(like Surf.COORD(1)).  


Finally, I also need to be able to execute some of the legacy commands,which are of the form
  CMDNAME object1 arg1=abc arg2=x arg3= 
Where CMDNAME is the name of particular commands, and the arguments can by any of several items (objects, text strings, numbers, etc.).  In addition, the argument names (arg1=, arg2= , etc) is actually optional, and just the argument values can be given.  For example
  CMDName Object Arg1=2 arg2=X arg3=4   
is the same as 
  CMDName Object 2 X 4



This language is designed to be a scripting language for use by
non-programmers, and they have a requirement to not need to declare
ahead of time variable/object names.   There is also a desire,
although not a requirement, to allow the user to only have to type in
enough to make things unique.  That is, Surf.DESCR(1) would be
equivalent to Surf.DESCRIPTOR(1).

Some questions I have are:
1) is SABLECC the appropriate tool for this,
2) how do you define in the grammer to account for the fact that some
items are objects with attributes, and some items are just variables, (or is that something parser doesn't care about, just the working sections need to handle)
3) How would I implement the desired ability to abbreviate commands
to just what is unique?
4) Has anyone else done something similar I could use as an example
5) Does any of this make sense or am I asking the impossible??


Thanks for any help/insight you can give me.  As you can tell, I am hardly an expert in this area.  I am comfortable with programming, but have never actually done any parser-type things or interpereters.


-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm