[il-antlr-interest: 33082] Re: [antlr-interest] Parsing Question

2011-07-08 Thread Bart Kiers
Hi Chris,

Very original! :)

Try to do more in lexer rules. Some of your keywords may probably also be a
part of the "instruction phrase": you need to be aware of that.
How about something like this:

grammar KnittingGrammer;

parse
  :  instruction+ EOF
  ;

instruction
  :  section FullStop
  |  castOn FullStop
  ;

section
  :  NumberDecoration Section
  |  Section NumberDecoration
  ;

castOn
  :  CastOn Number Stitches+ anyWordExceptStitches anyWord*
  ;

anyWordExceptStitches
  :  NumberDecoration
  |  Number
  |  Section
  |  Word
  ;

anyWord
  :  NumberDecoration
  |  Number
  |  Section
  |  Stitches
  |  Word
  ;

NumberDecoration
 :  Digit+ ('st' | 'nd' | 'rd' | 'th')
 ;

Number
  :  Digit+
  ;

FullStop
  :  ':'
  |  ';'
  |  ','
  |  '.'
  |  '\n'
  |  '\r'
  ;

Section
  :  'section'
  ;

CastOn
  :  'cast' Space+ 'on'
  |  'co'
  ;

Stitches
  :  'stitch' 'es'?
  |  '(sts)'
  |  'sts'
  ;

Space
  :  (' ' | '\t') {skip();}
  ;

Word
  :  ('a'..'z' | 'A'..'Z')+
  ;

fragment Digit : '0'..'9';


which parses input like this properly:

1st section: cast on 63 stitches (sts) and work in pattern section as
follows:


Regards,

Bart.


On Fri, Jul 8, 2011 at 2:15 AM, Chris Wegener
wrote:

> Dear Friends-
>
>
>
> I am attempting to define a language that will let me parse knitting
> instructions.  (Don't ask.)
>
>
>
> By and large it is a well understood convention with standard abbreviations
> and phrases.  Occasionally the originator will insert a phrase in the
> instructions that are not directly relevant.  What I would like is to parse
> out those words and deal with them around the issue of reading the
> instructions.  I have tried:
>
>
>
> text :(letter)+;
>
> letter :  ('a'..'z' | 'A'..'Z');
>
> WS   :(' ' | '\n' | '\r');
>
>
>
> And it doesn't work at all.  I changed it to:
>
>
>
> text :   (letter)+;
>
> letter :~('"' | '\\');
>
> WS   :   (' ' | '\n' | '\r');
>
>
> That works, but becomes unweildy very quickly when I start including all of
> the things I do know to scan for. I have attached the KnittingGrammer.g
> file
> with my rules.
>
> For example:
>
> "1st Section: Cast on 63 stitches (sts) and work in pattern as follows:" is
> parsed into '1st Section:' and 'Cast on 63 stitches (sts)' which leaves the
> text until the colon which is the stop character.  I would like to parse
> the
> 'and work in pattern as follows' into the parse tree under text so I can
> inspect it or lex it seperately or even display to the user.
>
> What am I missing or doing wrong?
>
> My thanks for your help in advance.
>
> Regards,
>
> Chris
>
>
>
>
>
> 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

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33083] Re: [antlr-interest] left recursion removal

2011-07-08 Thread Sébastien Kirche
Le 7 juillet 2011 17:51, John B. Brodie  a écrit :
>
> change the singleStatement rule to this:
>
> singleStatement
>        :       IDENT ( OPEQ expression | '(' expressionList? ')' )
>        |       'return' expression
>        ;
>
> and delete the now unnecessary assignment rule.

And it works.
It's like watching a juggler on tv : it looks almost easy ;o)

Thanks.
-- 
Sébastien Kirche

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33084] [antlr-interest] Are there ANTLR Consulting service?

2011-07-08 Thread James Ladd

Hi All,

I have some antlr work that I need to get done a.s.a.p.
Are any ANTLR Consulting services I can contact to get this work done?  

Rgs, James.
  

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.



[il-antlr-interest: 33086] [antlr-interest] Updated Visual Studio 2010 Extensions for ANTLR and ST4

2011-07-08 Thread Sam Harwell
Hello everyone,

 

I just published updated versions of my Visual Studio 2010 extensions to the
Visual Studio Gallery. Below is a note for existing users followed by a
description of the extensions and links to the Visual Studio Gallery where
they are published.

 

Important: If you previously installed an early copy of the following 3
extensions, you'll need to manually uninstall them (all of them) from the
"Tools -> Extension Manager." dialog before installing the new version. In
the future, the extensions should update correctly without having to
reinstall them.

. ANTLR language support

. StringTemplate 4 language support

. Visual Studio Extensibility Framework

 

With that out of the way, here is a description of the various extensions.
Screenshots are available on the gallery pages for each extension.

 

ANTLR Language Support

http://visualstudiogallery.msdn.microsoft.com/25b991db-befd-441b-b23b-bb5f8d
07ee9f

 

. Provides syntax highlighting and basic IntelliSense features for
ANTLR v3 grammars.

. Adds the exceptions from Antlr.Runtime and Antlr.Runtime.Tree to
the Debug->Exceptions... dialog for easy configuration.

 

StringTemplate 4 Language Support

http://visualstudiogallery.msdn.microsoft.com/5ca30e58-96b4-4edf-b95e-3030da
f474ff

 

. Provides syntax highlighting and a select few IntelliSense
features for StringTemplate files.

. Some features are limited to the default delimiters '<' and '>'.

 

The following extensions are not quite as developed as the two above, but
I'll include them since some people may find them useful and because I used
ANTLR to create them. All of these extensions are being created for one of
my ongoing research projects.

 

Java Language Support

http://visualstudiogallery.msdn.microsoft.com/bc561769-36ff-4a40-9504-e266e8
706f93

 

PHP Language Support

http://visualstudiogallery.msdn.microsoft.com/2a10ba81-26c5-47d9-939b-6bcc7b
bec251

 

Alloy Language Support (http://alloy.mit.edu/community)

http://visualstudiogallery.msdn.microsoft.com/4ae31812-f841-45c3-8052-113077
5473f8

 

Go Language Support (http://golang.org)

http://visualstudiogallery.msdn.microsoft.com/bd7675ba-1bf5-4395-8c5a-4fc19d
fc0d76

 

Thank you,

Sam Harwell


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.