|Compiler Design + feedback email@example.com (Philip Herron) (2009-04-21)|
|Re: Compiler Design + feedback cfc@shell01.TheWorld.com (Chris F Clark) (2009-04-21)|
|Re: Compiler Design + feedback firstname.lastname@example.org (Philip Herron) (2009-04-22)|
|Re: Compiler Design + feedback email@example.com (russell kym horsell) (2009-04-23)|
|Re: Compiler Design + feedback firstname.lastname@example.org (Pertti Kellomaki) (2009-04-24)|
|Re: PCC, was Compiler Design + feedback email@example.com (Jonathan Thornburg) (2009-04-25)|
|Re: PCC, was Compiler Design + feedback firstname.lastname@example.org (toby) (2009-05-10)|
|[1 later articles]|
|From:||Philip Herron <email@example.com>|
|Date:||Tue, 21 Apr 2009 16:33:00 +0100|
|Posted-Date:||21 Apr 2009 17:18:55 EDT|
I am kind of new to compiler design but its become my personal
interest now! I know my way around flex and bison pretty well i hope
and been doing it in good old c so far. And got past that whole
multiple lexer/parser problem inside automake i posted the solution to
the automake list recently if anyone is interested.
Anyways i am having some problems due to my lack of knowledge in the
area so far so some input would be great!
So i have been playing around and starting to write a simple rules
based language you can embed into applications. So you can quickly
change how the program works. Anyways thats not what i am here to talk
about. So lets look at an example of my language :
#simple test to show it can be used like make :)
#main workflow depends main() to be ran before compileHelloWorld
CC := "gcc"
CFLAGS := "-g -02"
workflow := compileHelloWorld;
echo "Compiling main.c -> main.o"
>ompile main.c to obj...
`$CC $CFLAGS -c -o main.o main.c`
rule -> compileHelloWorld ( main() )
echo "Linking main.o -> helloworld.exe"
`$CC $CFLAGS -o helloworld.exe main.o`
So this just is one mega basic way to show what i am thinking about
but it goes much further i'll show more in a sec. So the idea is you
have global variables CC/CFLAGS etc.. you define your 'workflow' which
is the set of rules you want to run in order. For this example its
just one rule...
So looking at this there is one rule to be run which depends the
method main to be run before the rule is run. I think of paramaters in
this as depandancies to a rule/method. So when i go to run that rule
main() is run first.... and main.c is compiled to .o bla bla then it
links a very basic makefile style thing but then i go on to:
Something like a system configuration language:
DEFAULT_root_password := "admin"
workflow := configuration;
#re-usable methods for activation
def dhcpNetworking( )
def hostToHostsList( <hostname>, <ip> )
#base rule if no ovf-props defined...
rule -> configuration()
rule -> configuration( <config.net.db>, <config.net.dp.ip> )
#asume dhcp networking...
#default too's username to sapadmin
rules -> configuration( <config.net.db>, <config.net.dp.ip>
>hange root users password
So the idea is i have the workflow to run the rule configuration but
there are multiple definitions of configuration each with different
dependancies these depeandcies are just variables but before this rul
is run i jsut push this onto a variable stack i have so they can be
there or not.
So say the stack has no variables defined yet like no configuration
passed it will run:
rule -> configuration()
And then say i pushed the <config.net.db>, <config.net.dp.ip>
configration props it will run that or etc....
the <*> is just a small snytax saying it depends these variables to be
on the stack.
Then they can run the above methods def hostToHostsList( <hostname>,
<ip> ) has 2 depandancies which you have to pass to it etc...
So ok i hope i bored you all so far to death :-).
I would like some feedback on this idea for a simple language whats
the bad points and why i am an idiot :P. But i also would like so
ideas or help on the design i guess.
I have been doing a lot of playing around with bison and flex i have
been parsing this all Top down so its statement by statement. I am
trying to think, to have like a workflow i mean as in for my
interpreter to figure out what is the first operation to do then the
next next next and so on.
So when i parse this file first i have my grammar to say the first
things can only be VariableDecalaration or workflowDefinitions then
onces in workflow definitions it can have rules or methods.
I understand how to use bison to have a parser etc..
But for an interpreter should you like do the python way of doing
things and just execute line by line, i just dont know how you conrol
the flow that way of your program without parsing the entire source
code into some kind of syntax map.
Like knowing the first thing i want to be able to do is push those
variables onto the stack then know which rule suits this paticular
execution and have the methods in memory. So i would need a kind of
LinkedList or Map of operations to run in order from the top level
rule and for each rule defined to be run in the worflow.
I guess this sounds kind of like a simple jit compiler. Or am i over
Anyways I am going to play around with this a little more :)
Thanks very much guys
Return to the
Search the comp.compilers archives again.