P
Phil Tomson
Anybody got a complete, working and not too large RACC example?
Phil
Phil
Anybody got a complete, working and not too large RACC example?
Phil
Phil said:Anybody got a complete, working and not too large RACC example?
I have done something like this for C only - I am going to release itHow about a RACC-based parser for C/C++ expressions? It's mostly
complete, it works (I use it to translate from the Teja language which
embeds C++ expressions), but it may be too large.
Charles said:I have done something like this for C only - I am going to release it
with a companion article soon...
Is your parser available to look at? Do you build a syntax tree?
-Charlie
Charles said:I have done something like this for C only - I am going to release it
with a companion article soon...
Is your parser available to look at? Do you build a syntax tree?
-Charlie
It's bundled up in
http://PATH.Berkeley.EDU/~vjoel/mobies/teja2hsif/teja2hsif-0.1/
Look in the lib/teja/cparser dir. The nodes.rb, scanner.rb, and
parser.y.rb are the useful parts. There is also a shell.rb in the same
dir that uses readline to interactively parse expressions and show the
tree:
expr> 1+4
= <AddOp>
op: "+"
left_expr: <Constant 1>
right_expr: <Constant 4>
expr> sin(*a[5]->b)
= <FnCall>
fn_expr: <Identifier sin>
arg_expr:
<UnOp>
op: "*"
expr: <DerefAccess>
this_expr: <Aref>
ary_expr: <Identifier a>
idx_expr: <Constant 5>
member_name: "b"
There are some limitations, due to the contstraints of the application:
-- no special attention to strings (no string literals)
-- no attention to declarations, control structures, function defs,
etc.
It would be great if someone put together a complete C parser in
RACC...
Anyway, I hope this is of some use to somebody.
How about a RACC-based parser for C/C++ expressions? It's mostly
complete, it works (I use it to translate from the Teja language which
embeds C++ expressions), but it may be too large.
I have done something like this for C only - I am going to release it
with a companion article soon...
Actually, that would be great as it's similar to something we're trying to
do with the Cardinal project: We want to be able to parse Ruby's C files
(array.c, hash.c, etc) and translate to Parrot assembly.
I don't want to get to far ahead of myself, but if all goes as plannedCool. We need something like this for the Cardinal project.
Where/when will your article appear?
Problem: We want Ruby to run on the Parrot VM
Solution: Write a C compiler that emits parrot bytecodes, and just
recompile the standard Ruby sources
You guys are nuts. Perhaps in a brilliant way, but crazy nonetheless.
It would be great if someone put together a complete C parser in RACC...
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.