[antlr-interest] minimalistic grammar approach

Arturo Hernandez arthernan at hotmail.com
Thu Jun 16 06:43:58 PDT 2011


Sergiy,
It is definitively a starting point. I also would love to hear from more experienced people on the list.
In the meantime I started to make modifications, on a local copy. And I will let you know my progress.
Thanks.
> Date: Wed, 15 Jun 2011 09:12:27 +0300
> Subject: Re: [antlr-interest] minimalistic grammar approach
> From: sergiy.dubovik at gmail.com
> To: arthernan at hotmail.com
> CC: antlr-interest at antlr.org
> 
> Hi,
> 
> I tried to quickly adopt your style to my grammar on which I'm
> currently working. It doesn't work like you described, however it
> could be a starting point, perhaps.
> Would be great to get comments from more experienced folks.
> Grammar and sample input is here: https://gist.github.com/1026572
> I had to switch off function call, it triggers recursion which I can't
> understand. You will need to solve it yourself :)
> I removed AST rewrite rules to simplify grammar. Those are very easy anyway.
> 
> br,
> Sergiy
> 
> On Wed, Jun 15, 2011 at 7:10 AM, Arturo Hernandez <arthernan at hotmail.com> wrote:
> >
> > Hello everybody,
> > Here is an informal draft of the (minimalist) Implementation Independent grammar. It's not meant as a play grammar, but as a practical grammar to specify transformations that are easy to translate to commercial grade implemented languages. Object and unit support is conspicuously absent, not so exceptions. Any criticism, references, ect.. are very welcome.
> > The language used for description in this email is not relevant, I am just taking a shortcut to express the grammar.
> > type aaa integer;type sss record( aaa integer, bbb string);type xxx arrayof aaa index by dddd;
> > integer ccc;var sss;   //infer typeconst int ssss;
> > sss:=function(ref a, const b, c){};return dddd;
> > // pascal sugar inrecord xxx { .aaaa:=ssss;}   //equivalent to xxx.aaaa:=ssss;
> > procedure(a, b, c) {};exit;  //end proc
> > foreach item in collection {};foreach idx indexin collection {};for i is 1 to 4 step 2 {};while (exp) {};break (exp); //exit loop
> > if (exp) {};else (exp) {};elsif (exp) {};case (aaaaa) { const: {} const: {} const: {} default: {}}  //aaaaa is an expression const are constants
> > throw excep ssssss; //ssssss is a variable
> > try {};
> > exception {};  // after a try blockexception (integer ex) {};exception (var ex) {};  // infer type
> > rethrow; // inside an exception block (benign if extra)
> >> From: arthernan at hotmail.com
> >> To: antlr-interest at antlr.org
> >> Date: Tue, 14 Jun 2011 15:30:53 -0500
> >> Subject: Re: [antlr-interest] minimalistic grammar approach
> >>
> >>
> >> Sergiy and Researcher,
> >> Thanks for your answers.
> >> The twist in this case is that I want to get the grammar first and then the language should be very easy. I have gathered the utility of having semicolons, thanks for that.
> >> I would rather not start from scratch if I don't have to. I think I could potentially find simple expression grammar in ANLTR.
> >> I'll be posting some beginning grammar later today.
> >>
> >> Arturo
> >> -- I want to be part of the code generation! --
> >>
> >>
> >> > Date: Tue, 14 Jun 2011 22:58:16 +0300
> >> > Subject: Re: [antlr-interest] minimalistic grammar approach
> >> > From: sergiy.dubovik at gmail.com
> >> > To: arthernan at hotmail.com
> >> >
> >> > Hi,
> >> >
> >> > I usually start with examples of target language I want to develop.
> >> > Write how to declare variables, structures, functions. Then identify
> >> > terminals: strings, integers, floats, operators, identifiers, keywords
> >> > and so on.
> >> > I start from arithmetic expressions, they are quite tricky because of
> >> > precedence. Then define boolean expressions, variable declaration,
> >> > assignments, functions. This process is very iterative you can make it
> >> > as complex as you wish. Use AntlrWorks, it can quickly run your
> >> > grammar on test input, also it can show how AST will look like in
> >> > debugger mode.
> >> >
> >> > It's much easier to start with a grammar which has ending symbol for
> >> > each statement, in C it's ";". Ruby like grammars are more difficult
> >> > (at least i spent several days figuring out how to make it working)
> >> > because of new line which can be separator and whitespace.
> >> >
> >> > Can't promise this will work for you.
> >> >
> >> > br,
> >> > Sergiy
> >> >
> >> > On Tue, Jun 14, 2011 at 8:23 PM, Arturo Hernandez <arthernan at hotmail.com> wrote:
> >> > >
> >> > > Hello everybody,
> >> > > I am making a spec for code generation that I am intending to use on my own Information Systems development
> >> > > My first step is to create a minimalistic implementation independent (II) grammar with support for record types, nested records, typed arrays, function calls and basic loop and contol logic. Such that expressions in a language that implemented this II grammar would be easy to translate to any language. And also easier to manipulate.
> >> > > Hash arrays would also be supported and the typical collection loops. Would also be supported.
> >> > > Does anyone here have any suggestions. Is there such a thing or close to it already implemented in ANTLR.
> >> > >
> >> > > Any info will be greatly appreciated.
> >> > >
> >> > > Arturo-- Object orientation works by hiding data behind more complex data. --
> >> > >
> >> > > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> >> > > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> >> > >
> >>
> >>
> >> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> >> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> >
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> >
 		 	   		  


More information about the antlr-interest mailing list