[il-antlr-interest: 34448] Re: [antlr-interest] This learning curve is getting me down (error messages using examples) NEWBIE NEEDS HELP

2011-10-19 Thread Norman Dunbar
Morning Andy,

> After getting quite excited reading through the first few chapters of 
> Language Implementation Patterns",
Possibly, just possibly, not the best book to start with. Ask me how I know!

 > ...

> How normal are these sorts of startup problems? Are the examples generally 
> not working in this way?
I'd say pretty normal. I suspect you, like me, are not a computer 
science student (or graduate) and so, "compiler" writing is for fun. So 
we are on the back foot from the start.

Equally, as with any half decent system, regardless of what it is, 
documentation is occasionally out of date, or plain wrong, of whatever. 
It's a chore to find something that is decent, current and works. :-)

I had a very similar problem when I started using DocBook for document 
production. I spend ages trying and failing to find anything good enough 
to use for an absolute beginner.

Talking of which, is CSharp a good place to start as a beginner? 
Probably not. Start simple - try building the calculator example from 
the ALTLR website (and in the book as I remember).

When you get that working, try adding on the divide ability (I seem to 
remember that it was a three function calculator - add, subtract, 
multiply but no divide!).

Then build a small "language" to do something equally as simple, and 
then you can build on it. It's the old saying "walk before you run".

 > And how much will it help to get the Definitive Guide To ANTLR?
A lot! This is the book I think you should have started with. I got mine 
from the Book Depository (via Amazon.co.uk) and I'm working my way 
through it for the first time, before I start doing anything.

Also, are you using ANTLRworks? I would if I was you! You can see how 
your grammer will work, or not!

> Will ANTLRworks flag problems like this, which are presumably specific to the 
> C#/.NET platform?
I imagine it will, yes.

> And while I'm at it, once I'm done with this, will I easily be able to get 
> ANTLR to put line and column numbers from my source files into the nodes in 
> ASTs that I build? That's important to me.
I seem to remember reading in the Definitive Guide, that this is 
possible. From the footnote on page 44:

You can put anything you want into the token structure. ANTLR’s default 
CommonToken objects include start/stop indexes into the character 
buffer, the line number, and the token’s character position within that
line, among other things.


Good luck.

-- 
Norman Dunbar
Dunbar IT Consultants Ltd

Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL

Company Number: 05132767

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: 34450] Re: [antlr-interest] Beginner needing help with rewrite rules

2011-10-19 Thread Yves Weißig
Hi!

Thanks for the answers!
That was a good rough guess Jim... I finally came up with this:

group   :   (OPEN
children+=space*
(
children+=group children+=space* |
children+=plaintext children+=space* |
children+=command children+=space* |
children+=escape children+=space*
)+
CLOSE) -> ^(GROUP $children*) ;

Works like a charme, subgroups are created automatically... I had to add
everything to "children" because I need to remain the order of the elements.

Thanks again!

Yves

Am 18.10.2011 23:11, schrieb Jim Idle:
> Looks like you need:
> 
> group :   (OPEN
>   space*
>   (
>   sg=group space* |
>   p=plaintext space* |
>   ((c1=command)+ space) |
>   (e=escape) space*
>   )+
>   ((c2=command)+)?
>   CLOSE) -> ^(GROUP ^(GROUP $sg)* $p+ $c1+ $e+ $c2+)
> 
> At a rough guess.
> 
> 
> Jim
> 
> 
>> -Original Message-
>> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
>> boun...@antlr.org] On Behalf Of Yves Weißig
>> Sent: Tuesday, October 18, 2011 12:11 AM
>> To: antlr-interest@antlr.org
>> Subject: [antlr-interest] Beginner needing help with rewrite rules
>>
>> Hi ANTLR list,
>> I'm using ANTLR within my master's thesis in order to parse the RTF
>> file format. Everything is fine so far, I can parse simple RTF
>> documents. The next step is to generate an AST. Here is where the
>> problems start, it seems as if I have an error in one of my rewrite-
>> rules. If you look at the grammar, what I want to do, is nest the
>> groups. This means, a "group" is child of a "group" if the subrule
>> group in the rule group is
>> called: sg=group space* -> ^(GROUP $sg+). Maybe you try the grammar
>> using a simple RTF snippet, e.g.
>>   {\pard\fs32\b NOTES\par}
>>   {\pard\fs26 Recently I skimmed {\i Structure and Interpretation of
>>Computer Programs}, by Sussman and Abelson, and I think there should
>>have been more pictures.
>>   \line I like pictures.  Is that so na\'efve?
>>   \par}
>> from: http://search.cpan.org/~sburke/RTF-Writer/lib/RTF/Cookbook.pod
>> Do you have any comments or ideas what I'm doing wrong?
>> Best regards, Yves
> 
> 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: 34452] [antlr-interest] Rewriting a list of tokens to a list of custom tokens

2011-10-19 Thread Christian
Hello ANTLR community,

I want to get

t+='void' (t+='*')*

to a list of a custom token type, say TYPE. That is, each element/token
of the list should change its original type to the type TYPE.
The following approach does not work because invalid java code is generated:

t+='void' (t+='*')* -> ^(TYPE[$t]+)

The following implicit list generation works fine, however each element
retains its original type:

t+='void' (t+='*')* -> ^($t+)

Can anyone tell me, whether and how this could be done?

Thanks in advance,
Christian

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: 34453] [antlr-interest] How viable is the Csharp3 target?

2011-10-19 Thread Voelkel, Andy
Hi,



I wrote a post yesterday about the trouble I'm having getting started with 
ANTLR. Overnight, I thought about it some more, and I'm becoming convinced that 
the latest problems I'm having are either problems with the Csharp target or 
backwards compatibility problems between ANTRL example code and the CSharp 
target. I have now purchase "the definitive guide", and I can work through 
examples using the Java based tools. But I do need the generated code to 
ultimately be in C# and to work.



If the Csharp target are actively developed and "supported" here, then I can 
use ANTLR for my project(s) and spread the technology around my workplace. 
Otherwise, I'll have to go back building simpler parser by hand :-( I sure hope 
that that is not the case.



I'm willing to contribute to shaking down the target, contributing and cleaning 
up example code, and write installation help for newbies.



- Andy



CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents, files or 
previous e-mail messages attached to it, may contain information that is 
confidential and/or legally privileged. If you are not the intended recipient, 
or a person responsible for delivering it to the intended recipient, please DO 
NOT disclose the contents to another person, store or copy the information in 
any medium, or use any of the information contained in or attached to this 
transmission for any purpose. If you have received this transmission in error, 
please immediately notify the sender by reply email or at 
priv...@plantronics.com, and destroy the original transmission and its 
attachments without reading or saving in any manner.

For further information about Plantronics - the Company, its products, brands, 
partners, please visit our website www.plantronics.com.

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: 34454] Re: [antlr-interest] How viable is the Csharp3 target?

2011-10-19 Thread pragmaik
Hi Andy!

I am using ANTLR's C# target for a couple of weeks now to create a domain
specific language that is a subset of the C programming language.

My experience is similar to yours, but I can assure you that the C# target
works and that it is actively maintained. It differs from the Java target in
a few places, but it works.

The biggest problem is finding documentation. I've both of Terence Parr's
books on my desk and the folks on this mailing list are very friendly and
competent.

Cheers,
Maik


--
View this message in context: 
http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-tp6908890p6908949.html
Sent from the ANTLR mailing list archive at Nabble.com.

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: 34456] Re: [antlr-interest] How viable is the Csharp3 target?

2011-10-19 Thread Sam Harwell
Hi Andy & Maik,

I agree that the C# target documentation is lacking in many ways. I try to
keep enough documentation at the following page to get you started on the
right path:
http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases

I've been using the CSharp3 target in a commercial product for 3 years now.
At this point, most of the remaining the issues I have with it are
basic/technical limitations of ANTLR 3 that will hopefully be resolved in
later versions.

Sam

-Original Message-
From: antlr-interest-boun...@antlr.org
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of pragmaik
Sent: Wednesday, October 19, 2011 9:36 AM
To: antlr-interest@antlr.org
Subject: Re: [antlr-interest] How viable is the Csharp3 target?

Hi Andy!

I am using ANTLR's C# target for a couple of weeks now to create a domain
specific language that is a subset of the C programming language.

My experience is similar to yours, but I can assure you that the C# target
works and that it is actively maintained. It differs from the Java target in
a few places, but it works.

The biggest problem is finding documentation. I've both of Terence Parr's
books on my desk and the folks on this mailing list are very friendly and
competent.

Cheers,
Maik


--
View this message in context:
http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-tp690889
0p6908949.html
Sent from the ANTLR mailing list archive at Nabble.com.

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: 34455] Re: [antlr-interest] How viable is the Csharp3 target?

2011-10-19 Thread 李志鹏
which version c# runtime do you use? 3.4 or 3.3? download from official
website?

i am newbie, want to build simple project could run an example, but two
weeks passed, i failed…

在 2011-10-19 下午10:36,"pragmaik" 编写:

Hi Andy!

I am using ANTLR's C# target for a couple of weeks now to create a domain
specific language that is a subset of the C programming language.

My experience is similar to yours, but I can assure you that the C# target
works and that it is actively maintained. It differs from the Java target in
a few places, but it works.

The biggest problem is finding documentation. I've both of Terence Parr's
books on my desk and the folks on this mailing list are very friendly and
competent.

Cheers,
Maik


--
View this message in context:
http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-tp6908890p6908949.html
Sent from the ANTLR mailing list archive at Nabble.com.


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailma...

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: 34457] Re: [antlr-interest] How viable is the Csharp3 target?

2011-10-19 Thread Kevin Cherry
I kind of got turned off when CSharp3 target was first introduced and the
code template had bugs in it. For example, at the end it would print out a
single line comment with the keyword namespace and the name of the namespace
(i.e. // namespace foo). The problem was somebody put a newline after the
"//" and so "namespace foo" was taken in as code and caused even simple
grammars to generate syntactically incorrect code. This wasn't the only bug.
I basically had to modify the code template, but good luck trying to figure
out how to do that and still use Antlrworks. I basically used 7zip to unzip
the Antlrworks.jar file, locate the csharp code template, change it, then
use java to archive it back into a jar and run it. I will say, though, that
I enjoy now knowing how to control other aspects of the generated code (like
the visibility of the class, which really should just be an antlr option
considering how dead simple it would be to implement (but I'll leave that
alone)). Anyway, if you are having any issues with the generated code, try
the above approach to get Antlrworks to use your own modified template.

On Wed, Oct 19, 2011 at 9:59 AM, Sam Harwell wrote:

> Hi Andy & Maik,
>
> I agree that the C# target documentation is lacking in many ways. I try to
> keep enough documentation at the following page to get you started on the
> right path:
> http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases
>
> I've been using the CSharp3 target in a commercial product for 3 years now.
> At this point, most of the remaining the issues I have with it are
> basic/technical limitations of ANTLR 3 that will hopefully be resolved in
> later versions.
>
> Sam
>
> -Original Message-
> From: antlr-interest-boun...@antlr.org
> [mailto:antlr-interest-boun...@antlr.org] On Behalf Of pragmaik
> Sent: Wednesday, October 19, 2011 9:36 AM
> To: antlr-interest@antlr.org
> Subject: Re: [antlr-interest] How viable is the Csharp3 target?
>
> Hi Andy!
>
> I am using ANTLR's C# target for a couple of weeks now to create a domain
> specific language that is a subset of the C programming language.
>
> My experience is similar to yours, but I can assure you that the C# target
> works and that it is actively maintained. It differs from the Java target
> in
> a few places, but it works.
>
> The biggest problem is finding documentation. I've both of Terence Parr's
> books on my desk and the folks on this mailing list are very friendly and
> competent.
>
> Cheers,
> Maik
>
>
> --
> View this message in context:
>
> http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-tp690889
> 0p6908949.html
> Sent from the ANTLR mailing list archive at Nabble.com.
>
> 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

-- 
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: 34458] Re: [antlr-interest] This learning curve is getting me down (error messages using examples) NEWBIE NEEDS HELP

2011-10-19 Thread Norman Dunbar
Afternoon Andy,

On 19/10/11 08:39, Norman Dunbar wrote:

 > ...
> Talking of which, is CSharp a good place to start as a beginner?
Sigh! Wish I could read.

When you wrote "using the treeparser example code for target Csharp2" I 
missed the word "target" and thought that you were playing with a 
grammar for the whole of the Csharp2 language.

Apologies.


Cheers,
Norm.

-- 
Norman Dunbar
Dunbar IT Consultants Ltd

Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL

Company Number: 05132767

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: 34459] Re: [antlr-interest] Rewriting a list of tokens to a list of custom tokens

2011-10-19 Thread Jim Idle
t1+='void' (t2+='*')* -> ^(LIST TYPE[$t1]+ TYPE[$t2]+)

By interpolating from your question. At least, that should get you on the
right track.


Jim

> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Christian
> Sent: Wednesday, October 19, 2011 5:40 AM
> To: antlr-interest@antlr.org
> Subject: [antlr-interest] Rewriting a list of tokens to a list of
> custom tokens
>
> Hello ANTLR community,
>
> I want to get
>
> t+='void' (t+='*')*
>
> to a list of a custom token type, say TYPE. That is, each element/token
> of the list should change its original type to the type TYPE.
> The following approach does not work because invalid java code is
> generated:
>
> t+='void' (t+='*')* -> ^(TYPE[$t]+)
>
> The following implicit list generation works fine, however each element
> retains its original type:
>
> t+='void' (t+='*')* -> ^($t+)
>
> Can anyone tell me, whether and how this could be done?
>
> Thanks in advance,
> Christian
>
> 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: 34460] Re: [antlr-interest] How viable is the Csharp3 target?

2011-10-19 Thread Jim Idle
I can confirm that the Csharp3 target is very viable and works perfectly
well. I think that your problems are more to do with being new to ANTLR
and then trying to use the CSharp target as your first try. If you used
the Java target purely inside ANTLRWorks just until you get going, then
you will be able to see where you are going wrong in the VS2010 vs where
your grammar is incorrect.


Jim

> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Sam Harwell
> Sent: Wednesday, October 19, 2011 7:59 AM
> To: 'pragmaik'; antlr-interest@antlr.org
> Subject: Re: [antlr-interest] How viable is the Csharp3 target?
>
> Hi Andy & Maik,
>
> I agree that the C# target documentation is lacking in many ways. I try
> to keep enough documentation at the following page to get you started
> on the right path:
> http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases
>
> I've been using the CSharp3 target in a commercial product for 3 years
> now.
> At this point, most of the remaining the issues I have with it are
> basic/technical limitations of ANTLR 3 that will hopefully be resolved
> in later versions.
>
> Sam
>
> -Original Message-
> From: antlr-interest-boun...@antlr.org
> [mailto:antlr-interest-boun...@antlr.org] On Behalf Of pragmaik
> Sent: Wednesday, October 19, 2011 9:36 AM
> To: antlr-interest@antlr.org
> Subject: Re: [antlr-interest] How viable is the Csharp3 target?
>
> Hi Andy!
>
> I am using ANTLR's C# target for a couple of weeks now to create a
> domain specific language that is a subset of the C programming
> language.
>
> My experience is similar to yours, but I can assure you that the C#
> target works and that it is actively maintained. It differs from the
> Java target in a few places, but it works.
>
> The biggest problem is finding documentation. I've both of Terence
> Parr's books on my desk and the folks on this mailing list are very
> friendly and competent.
>
> Cheers,
> Maik
>
>
> --
> View this message in context:
> http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-
> tp690889
> 0p6908949.html
> Sent from the ANTLR mailing list archive at Nabble.com.
>
> 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

-- 
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: 34461] [antlr-interest] Matching an arbitrary string until the next whitespace occurrence

2011-10-19 Thread Patrick Nick
Hi all,

I just started using antlr and was able to construct a nice grammar that
fulfills my application's needs. There is one thing which I haven't been
able to get to work though.
My grammar is parsing program arguments which the user supplied when
starting the program, and some of that input will need to be forwarded to
another program. This implies that I have almost no control over those
strings and need to be able to parse them only knowing that they are
delimited by whitespace. So what I need (I think) is a lexer rule to match
an arbitrary string which doesn't contain whitespace.

Here is what I tried, with the intention that it should match anything that
doesn't contain one of the four characters.

STRING :(~(' '|'\t'|'\r'|'\n'))+ ;

However, that does not seem to be working, it doesn't recognize numbers for
example, and I don't understand why.
Any hints?

Regards
Patrick

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: 34462] Re: [antlr-interest] Matching an arbitrary string until the next whitespace occurrence

2011-10-19 Thread Jim Idle
I suggest that you want to use getargs, and not try to parse things like
this with ANTLR as the specification is too vague. The lexer is not
context driven, so placing a rule like that in lexer will match everything
that is whitespace to the detriment of any other rule at all.


Jim


> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Patrick Nick
> Sent: Wednesday, October 19, 2011 8:52 AM
> To: antlr-interest@antlr.org
> Subject: [antlr-interest] Matching an arbitrary string until the next
> whitespace occurrence
>
> Hi all,
>
> I just started using antlr and was able to construct a nice grammar
> that fulfills my application's needs. There is one thing which I
> haven't been able to get to work though.
> My grammar is parsing program arguments which the user supplied when
> starting the program, and some of that input will need to be forwarded
> to another program. This implies that I have almost no control over
> those strings and need to be able to parse them only knowing that they
> are delimited by whitespace. So what I need (I think) is a lexer rule
> to match an arbitrary string which doesn't contain whitespace.
>
> Here is what I tried, with the intention that it should match anything
> that doesn't contain one of the four characters.
>
> STRING :(~(' '|'\t'|'\r'|'\n'))+ ;
>
> However, that does not seem to be working, it doesn't recognize numbers
> for example, and I don't understand why.
> Any hints?
>
> Regards
> Patrick
>
> 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: 34463] Re: [antlr-interest] How viable is the Csharp3 target? (more specific questions)

2011-10-19 Thread Voelkel, Andy
Hi,



First, thanks for the encouragement. Knowing there are active users out there 
makes all the difference.



I've now taken the first example from "the definitive ANTLR reference" and 
tried to get it to work, first using the Visual Studio Extensions and 
templates, and then also manually running the ANTLR3.exe file at the command 
line, just to verify that my problems are in the generated code and are not 
errors generated during the generation of code (since the Visual Studio 
Extensions and associated instructions seem to produce projects that both 
generate code and then build it).



So my grammar is this simple:



grammar Lexer1;



options {

language=CSharp3;

}



/** Match things like "call foo;" */

r : 'call' ID ';' {System.out.println("invoke "+$ID.text);} ;

ID: 'a'..'z'+ ;

WS: (' '|'\n'|'\r')+   {$channel=HIDDEN;} ; // ignore whitespace



When I compile the code generated by ANTLR3, I get these errors:


K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(28,2): warning 
CS3021: 'Lexer1Parser' does not need a CLSCompliant attribute because the 
assembly does not have a CLSCompliant attribute
K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error CS1041: 
Identifier expected; 'out' is a keyword
K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error CS1525: 
Invalid expression term 'out'
K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(28,2): warning CS3021: 
'Lexer1Lexer' does not need a CLSCompliant attribute because the assembly does 
not have a CLSCompliant attribute
K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(276,13): error CS0103: 
The name 'HIDDEN' does not exist in the current context



The errors regarding "System.out" make sense, that seems like a call to a Java 
function that does not exist in C#. However the error with HIDDEN is confusing 
to me, and it is the result of sub a basic construct ({$channel=HIDDEN:};). I 
can't imagine what I am doing wrong to cause this, and since it is the first 
example pulled out of the book, you would think it would work!



Can someone help me here? I'm gaining confidence, but I'm having trouble even 
walking before I can run!



Oh, also: What are the files Antlr3.Targets.CSharp2.dll and 
Antlr3.Targets.CSharp3.dll for?



-  Andy





-Original Message-
From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Sam Harwell
Sent: Wednesday, October 19, 2011 7:59 AM
To: 'pragmaik'; antlr-interest@antlr.org
Subject: Re: [antlr-interest] How viable is the Csharp3 target?



Hi Andy & Maik,



I agree that the C# target documentation is lacking in many ways. I try to keep 
enough documentation at the following page to get you started on the right path:

http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases



I've been using the CSharp3 target in a commercial product for 3 years now.

At this point, most of the remaining the issues I have with it are 
basic/technical limitations of ANTLR 3 that will hopefully be resolved in later 
versions.



Sam



-Original Message-

From: antlr-interest-boun...@antlr.org

[mailto:antlr-interest-boun...@antlr.org]
 On Behalf Of pragmaik

Sent: Wednesday, October 19, 2011 9:36 AM

To: antlr-interest@antlr.org

Subject: Re: [antlr-interest] How viable is the Csharp3 target?



Hi Andy!



I am using ANTLR's C# target for a couple of weeks now to create a domain 
specific language that is a subset of the C programming language.



My experience is similar to yours, but I can assure you that the C# target 
works and that it is actively maintained. It differs from the Java target in a 
few places, but it works.



The biggest problem is finding documentation. I've both of Terence Parr's books 
on my desk and the folks on this mailing list are very friendly and competent.



Cheers,

Maik





--

View this message in context:

http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-tp690889

0p6908949.html

Sent from the ANTLR mailing list archive at Nabble.com.



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





CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents, files or 
previous e-mail messages attached to it, may contain information that is 
confidential and/or legally privileged. If you are not the intended recipient, 
or a person responsible for delivering it to the intended recipient, please DO 
NOT disclo

[il-antlr-interest: 34464] Re: [antlr-interest] How viable is the Csharp3 target? (more specific questions)

2011-10-19 Thread Justin Murray
Try using Console.WriteLine() instead of System.out.println(). What is 
inside of the curly braces is directly injected into the C# code being 
generated, and therefore needs to be C# syntax, not Java.

- Justin

On 10/19/2011 2:25 PM, Voelkel, Andy wrote:
> Hi,
>
>
>
> First, thanks for the encouragement. Knowing there are active users out there 
> makes all the difference.
>
>
>
> I've now taken the first example from "the definitive ANTLR reference" and 
> tried to get it to work, first using the Visual Studio Extensions and 
> templates, and then also manually running the ANTLR3.exe file at the command 
> line, just to verify that my problems are in the generated code and are not 
> errors generated during the generation of code (since the Visual Studio 
> Extensions and associated instructions seem to produce projects that both 
> generate code and then build it).
>
>
>
> So my grammar is this simple:
>
>
>
> grammar Lexer1;
>
>
>
> options {
>
>  language=CSharp3;
>
> }
>
>
>
> /** Match things like "call foo;" */
>
> r : 'call' ID ';' {System.out.println("invoke "+$ID.text);} ;
>
> ID: 'a'..'z'+ ;
>
> WS: (' '|'\n'|'\r')+   {$channel=HIDDEN;} ; // ignore whitespace
>
>
>
> When I compile the code generated by ANTLR3, I get these errors:
>
>
> K:\Plantronics\Development 
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(28,2): warning 
> CS3021: 'Lexer1Parser' does not need a CLSCompliant attribute because the 
> assembly does not have a CLSCompliant attribute
> K:\Plantronics\Development 
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error 
> CS1041: Identifier expected; 'out' is a keyword
> K:\Plantronics\Development 
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error 
> CS1525: Invalid expression term 'out'
> K:\Plantronics\Development 
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(28,2): warning 
> CS3021: 'Lexer1Lexer' does not need a CLSCompliant attribute because the 
> assembly does not have a CLSCompliant attribute
> K:\Plantronics\Development 
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(276,13): error 
> CS0103: The name 'HIDDEN' does not exist in the current context
>
>
>
> The errors regarding "System.out" make sense, that seems like a call to a 
> Java function that does not exist in C#. However the error with HIDDEN is 
> confusing to me, and it is the result of sub a basic construct 
> ({$channel=HIDDEN:};). I can't imagine what I am doing wrong to cause this, 
> and since it is the first example pulled out of the book, you would think it 
> would work!
>
>
>
> Can someone help me here? I'm gaining confidence, but I'm having trouble even 
> walking before I can run!
>
>
>
> Oh, also: What are the files Antlr3.Targets.CSharp2.dll and 
> Antlr3.Targets.CSharp3.dll for?
>
>
>
> -  Andy
>
>
>
>
>
> -Original Message-
> From: antlr-interest-boun...@antlr.org 
> [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Sam Harwell
> Sent: Wednesday, October 19, 2011 7:59 AM
> To: 'pragmaik'; antlr-interest@antlr.org
> Subject: Re: [antlr-interest] How viable is the Csharp3 target?
>
>
>
> Hi Andy&  Maik,
>
>
>
> I agree that the C# target documentation is lacking in many ways. I try to 
> keep enough documentation at the following page to get you started on the 
> right path:
>
> http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases
>
>
>
> I've been using the CSharp3 target in a commercial product for 3 years now.
>
> At this point, most of the remaining the issues I have with it are 
> basic/technical limitations of ANTLR 3 that will hopefully be resolved in 
> later versions.
>
>
>
> Sam
>
>
>
> -Original Message-
>
> From: 
> antlr-interest-boun...@antlr.org
>
> [mailto:antlr-interest-boun...@antlr.org]
>   On Behalf Of pragmaik
>
> Sent: Wednesday, October 19, 2011 9:36 AM
>
> To: antlr-interest@antlr.org
>
> Subject: Re: [antlr-interest] How viable is the Csharp3 target?
>
>
>
> Hi Andy!
>
>
>
> I am using ANTLR's C# target for a couple of weeks now to create a domain 
> specific language that is a subset of the C programming language.
>
>
>
> My experience is similar to yours, but I can assure you that the C# target 
> works and that it is actively maintained. It differs from the Java target in 
> a few places, but it works.
>
>
>
> The biggest problem is finding documentation. I've both of Terence Parr's 
> books on my desk and the folks on this mailing list are very friendly and 
> competent.
>
>
>
> Cheers,
>
> Maik
>
>
>
>
>
> --
>
> View this message in context:
>
> http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-tp690889
>
> 0p6908949.html
>
> Sent from the ANTLR mailing list archive at Nabble.com.
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>
> Unsubscribe:
>
> http://www.antlr.org/mailman/options/an

[il-antlr-interest: 34465] Re: [antlr-interest] How viable is the Csharp3 target? (more specific questions)

2011-10-19 Thread Jim Idle
System.out.println("invoke "+$ID.text);}

Is Java code, which is why I encourage you to just use ANTLRWorks with
Java to get your head around ANTLR, then you will be able to see the woods
from the trees switching to C#.

Jim

> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Voelkel, Andy
> Sent: Wednesday, October 19, 2011 11:26 AM
> To: Sam Harwell; 'pragmaik'; antlr-interest@antlr.org
> Subject: Re: [antlr-interest] How viable is the Csharp3 target? (more
> specific questions)
>
> Hi,
>
>
>
> First, thanks for the encouragement. Knowing there are active users out
> there makes all the difference.
>
>
>
> I've now taken the first example from "the definitive ANTLR reference"
> and tried to get it to work, first using the Visual Studio Extensions
> and templates, and then also manually running the ANTLR3.exe file at
> the command line, just to verify that my problems are in the generated
> code and are not errors generated during the generation of code (since
> the Visual Studio Extensions and associated instructions seem to
> produce projects that both generate code and then build it).
>
>
>
> So my grammar is this simple:
>
>
>
> grammar Lexer1;
>
>
>
> options {
>
> language=CSharp3;
>
> }
>
>
>
> /** Match things like "call foo;" */
>
> r : 'call' ID ';' {System.out.println("invoke "+$ID.text);} ;
>
> ID: 'a'..'z'+ ;
>
> WS: (' '|'\n'|'\r')+   {$channel=HIDDEN;} ; // ignore whitespace
>
>
>
> When I compile the code generated by ANTLR3, I get these errors:
>
>
> K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(28,2):
> warning CS3021: 'Lexer1Parser' does not need a CLSCompliant attribute
> because the assembly does not have a CLSCompliant attribute
> K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error
> CS1041: Identifier expected; 'out' is a keyword
> K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error
> CS1525: Invalid expression term 'out'
> K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(28,2): warning
> CS3021: 'Lexer1Lexer' does not need a CLSCompliant attribute because
> the assembly does not have a CLSCompliant attribute
> K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(276,13): error
> CS0103: The name 'HIDDEN' does not exist in the current context
>
>
>
> The errors regarding "System.out" make sense, that seems like a call to
> a Java function that does not exist in C#. However the error with
> HIDDEN is confusing to me, and it is the result of sub a basic
> construct ({$channel=HIDDEN:};). I can't imagine what I am doing wrong
> to cause this, and since it is the first example pulled out of the
> book, you would think it would work!
>
>
>
> Can someone help me here? I'm gaining confidence, but I'm having
> trouble even walking before I can run!
>
>
>
> Oh, also: What are the files Antlr3.Targets.CSharp2.dll and
> Antlr3.Targets.CSharp3.dll for?
>
>
>
> -  Andy
>
>
>
>
>
> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Sam Harwell
> Sent: Wednesday, October 19, 2011 7:59 AM
> To: 'pragmaik'; antlr-interest@antlr.org
> Subject: Re: [antlr-interest] How viable is the Csharp3 target?
>
>
>
> Hi Andy & Maik,
>
>
>
> I agree that the C# target documentation is lacking in many ways. I try
> to keep enough documentation at the following page to get you started
> on the right path:
>
> http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases
>
>
>
> I've been using the CSharp3 target in a commercial product for 3 years
> now.
>
> At this point, most of the remaining the issues I have with it are
> basic/technical limitations of ANTLR 3 that will hopefully be resolved
> in later versions.
>
>
>
> Sam
>
>
>
> -Original Message-
>
> From: antlr-interest-boun...@antlr.org boun...@antlr.org>
>
> [mailto:antlr-interest-boun...@antlr.org] interest-boun...@antlr.org]> On Behalf Of pragmaik
>
> Sent: Wednesday, October 19, 2011 9:36 AM
>
> To: antlr-interest@antlr.org
>
> Subject: Re: [antlr-interest] How viable is the Csharp3 target?
>
>
>
> Hi Andy!
>
>
>
> I am using ANTLR's C# target for a couple of weeks now to create a
> domain specific language that is a subset of the C programming
> language.
>
>
>
> My experience is similar to yours, but I can assure you that the C#
> target works and that it is actively maintained. It differs from the
> Java target in a few places, but it works.
>
>
>
> The biggest problem is finding documentation. I've both of Terence
> Parr's books on my desk and the folks on this mailing list are very
> friendly and competent.
>
>
>
> Cheers,
>
> Maik
>
>
>
>
>
> --
>
> View this message in context:
>
> http://a

[il-antlr-interest: 34466] Re: [antlr-interest] How viable is the Csharp3 target? (more specific questions)

2011-10-19 Thread Kevin Carroll
Andy,

In addition to the other's suggestions, change HIDDEN to Hidden.  The C# target 
attempts to use standard C# conventions when possible. It can be frustrating 
when working from the books and Java-focused documentation, but once you get 
past the few differences and gain some momentum, you should not have too many 
other compatibility issues.

Kevin Carroll

-Original Message-
From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Voelkel, Andy
Sent: Wednesday, October 19, 2011 1:26 PM
To: Sam Harwell; 'pragmaik'; antlr-interest@antlr.org
Subject: Re: [antlr-interest] How viable is the Csharp3 target? (more specific 
questions)

Hi,



First, thanks for the encouragement. Knowing there are active users out there 
makes all the difference.



I've now taken the first example from "the definitive ANTLR reference" and 
tried to get it to work, first using the Visual Studio Extensions and 
templates, and then also manually running the ANTLR3.exe file at the command 
line, just to verify that my problems are in the generated code and are not 
errors generated during the generation of code (since the Visual Studio 
Extensions and associated instructions seem to produce projects that both 
generate code and then build it).



So my grammar is this simple:



grammar Lexer1;



options {

language=CSharp3;

}



/** Match things like "call foo;" */

r : 'call' ID ';' {System.out.println("invoke "+$ID.text);} ;

ID: 'a'..'z'+ ;

WS: (' '|'\n'|'\r')+   {$channel=HIDDEN;} ; // ignore whitespace



When I compile the code generated by ANTLR3, I get these errors:


K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(28,2): warning 
CS3021: 'Lexer1Parser' does not need a CLSCompliant attribute because the 
assembly does not have a CLSCompliant attribute K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error CS1041: 
Identifier expected; 'out' is a keyword K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error CS1525: 
Invalid expression term 'out'
K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(28,2): warning CS3021: 
'Lexer1Lexer' does not need a CLSCompliant attribute because the assembly does 
not have a CLSCompliant attribute K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(276,13): error CS0103: 
The name 'HIDDEN' does not exist in the current context



The errors regarding "System.out" make sense, that seems like a call to a Java 
function that does not exist in C#. However the error with HIDDEN is confusing 
to me, and it is the result of sub a basic construct ({$channel=HIDDEN:};). I 
can't imagine what I am doing wrong to cause this, and since it is the first 
example pulled out of the book, you would think it would work!



Can someone help me here? I'm gaining confidence, but I'm having trouble even 
walking before I can run!



Oh, also: What are the files Antlr3.Targets.CSharp2.dll and 
Antlr3.Targets.CSharp3.dll for?



-  Andy





-Original Message-
From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org] On Behalf Of Sam Harwell
Sent: Wednesday, October 19, 2011 7:59 AM
To: 'pragmaik'; antlr-interest@antlr.org
Subject: Re: [antlr-interest] How viable is the Csharp3 target?



Hi Andy & Maik,



I agree that the C# target documentation is lacking in many ways. I try to keep 
enough documentation at the following page to get you started on the right path:

http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases



I've been using the CSharp3 target in a commercial product for 3 years now.

At this point, most of the remaining the issues I have with it are 
basic/technical limitations of ANTLR 3 that will hopefully be resolved in later 
versions.



Sam



-Original Message-

From: antlr-interest-boun...@antlr.org

[mailto:antlr-interest-boun...@antlr.org]
 On Behalf Of pragmaik

Sent: Wednesday, October 19, 2011 9:36 AM

To: antlr-interest@antlr.org

Subject: Re: [antlr-interest] How viable is the Csharp3 target?



Hi Andy!



I am using ANTLR's C# target for a couple of weeks now to create a domain 
specific language that is a subset of the C programming language.



My experience is similar to yours, but I can assure you that the C# target 
works and that it is actively maintained. It differs from the Java target in a 
few places, but it works.



The biggest problem is finding documentation. I've both of Terence Parr's books 
on my desk and the folks on this mailing list are very friendly and competent.



Cheers,

Maik





--

View this message in context:

http://antlr.1301665.n2.nabble.com/How-viable-is-the-Csharp3-target-tp690889

0p6908949.html

Sent from the ANTLR mai

[il-antlr-interest: 34467] Re: [antlr-interest] How viable is the Csharp3 target? (more specific questions)

2011-10-19 Thread Voelkel, Andy
Hi Kevin,



That's the ticket (change HIDDEN to Hidden)! But doesn't that make the grammar 
non-portable, and aren't portable grammars a goal of ANTLR?



Also, it verifies my suspicion that the example code I got (for Csharp) was 
wrong. All the examples I downloaded are wrong, I just checked. So I went back 
and tried to retrace where I got them from, but found the same examples on the 
Antlr site with the same folder organization, but without the errors. 
Frustrating. I sure haven't figured my way around the ANTLR site properly yet, 
I guess! And there are stale examples out there, since I got them only 
yesterday!



Anyhow, I think I'm unstuck for the moment. Thanks to all of you!



Now I can go see if I can figure out how to use AntlrWorks, since everyone 
seems to rave about it, even though it seems that I need to use grammars that 
are a little different (unfortunately), because it's all Java



-  Andy





-Original Message-
From: Kevin Carroll [mailto:kcarr...@signmgmt.com]
Sent: Wednesday, October 19, 2011 11:35 AM
To: Voelkel, Andy; antlr-interest@antlr.org
Subject: RE: [antlr-interest] How viable is the Csharp3 target? (more specific 
questions)



Andy,



In addition to the other's suggestions, change HIDDEN to Hidden.  The C# target 
attempts to use standard C# conventions when possible. It can be frustrating 
when working from the books and Java-focused documentation, but once you get 
past the few differences and gain some momentum, you should not have too many 
other compatibility issues.



Kevin Carroll



-Original Message-

From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org]
 On Behalf Of Voelkel, Andy

Sent: Wednesday, October 19, 2011 1:26 PM

To: Sam Harwell; 'pragmaik'; 
antlr-interest@antlr.org

Subject: Re: [antlr-interest] How viable is the Csharp3 target? (more specific 
questions)



Hi,







First, thanks for the encouragement. Knowing there are active users out there 
makes all the difference.







I've now taken the first example from "the definitive ANTLR reference" and 
tried to get it to work, first using the Visual Studio Extensions and 
templates, and then also manually running the ANTLR3.exe file at the command 
line, just to verify that my problems are in the generated code and are not 
errors generated during the generation of code (since the Visual Studio 
Extensions and associated instructions seem to produce projects that both 
generate code and then build it).







So my grammar is this simple:







grammar Lexer1;







options {



language=CSharp3;



}







/** Match things like "call foo;" */



r : 'call' ID ';' {System.out.println("invoke "+$ID.text);} ;



ID: 'a'..'z'+ ;



WS: (' '|'\n'|'\r')+   {$channel=HIDDEN;} ; // ignore whitespace







When I compile the code generated by ANTLR3, I get these errors:





K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(28,2): warning 
CS3021: 'Lexer1Parser' does not need a CLSCompliant attribute because the 
assembly does not have a CLSCompliant attribute K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error CS1041: 
Identifier expected; 'out' is a keyword K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error CS1525: 
Invalid expression term 'out'

K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(28,2): warning CS3021: 
'Lexer1Lexer' does not need a CLSCompliant attribute because the assembly does 
not have a CLSCompliant attribute K:\Plantronics\Development 
Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(276,13): error CS0103: 
The name 'HIDDEN' does not exist in the current context







The errors regarding "System.out" make sense, that seems like a call to a Java 
function that does not exist in C#. However the error with HIDDEN is confusing 
to me, and it is the result of sub a basic construct ({$channel=HIDDEN:};). I 
can't imagine what I am doing wrong to cause this, and since it is the first 
example pulled out of the book, you would think it would work!







Can someone help me here? I'm gaining confidence, but I'm having trouble even 
walking before I can run!







Oh, also: What are the files Antlr3.Targets.CSharp2.dll and 
Antlr3.Targets.CSharp3.dll for?







-  Andy











-Original Message-

From: antlr-interest-boun...@antlr.org 
[mailto:antlr-interest-boun...@antlr.org]
 On Behalf Of Sam Harwell

Sent: Wednesday, October 19, 2011 7:59 AM

To: 'pragmaik'; antlr-interest@antlr.org

Subject: Re: [antlr-interest] How viable is the Csharp3 target?







Hi Andy & Maik,







I agree t

[il-antlr-interest: 34468] [antlr-interest] Fwd: How viable is the Csharp3 target? (more specific questions)

2011-10-19 Thread Eric
-- Forwarded message --
From: Eric 
Date: Wed, Oct 19, 2011 at 3:25 PM
Subject: Re: [antlr-interest] How viable is the Csharp3 target? (more
specific questions)
To: "Voelkel, Andy" 




On Wed, Oct 19, 2011 at 3:16 PM, Voelkel, Andy  wrote:

> Hi Kevin,
>
>
>
> That's the ticket (change HIDDEN to Hidden)! But doesn't that make the
> grammar non-portable, and aren't portable grammars a goal of ANTLR?
>
Depends upon your definition of portable. The grammar will be portable, but
the embedded code will be specific to the target language. Depending upon
the grammar, you may not even need to embed target source code. Most
grammars have little to none embedded target code, which is usually just
snippets of several lines or less that can be converted in an hour our so by
someone experienced in both target languages.


>
>
>
> Also, it verifies my suspicion that the example code I got (for Csharp) was
> wrong. All the examples I downloaded are wrong, I just checked. So I went
> back and tried to retrace where I got them from, but found the same examples
> on the Antlr site with the same folder organization, but without the errors.
> Frustrating. I sure haven't figured my way around the ANTLR site properly
> yet, I guess! And there are stale examples out there, since I got them only
> yesterday!
>

Anyhow, I think I'm unstuck for the moment. Thanks to all of you!



Now I can go see if I can figure out how to use AntlrWorks, since everyone
seems to rave about it, even though it seems that I need to use grammars
that are a little different (unfortunately), because it's all Java

Wise choice.

If you are using ANTLRWorks, don't trust the Interpreter, the debugger is
OK.


>
>
>
> -  Andy
>
>
>
>
>
> -Original Message-
> From: Kevin Carroll [mailto:kcarr...@signmgmt.com]
> Sent: Wednesday, October 19, 2011 11:35 AM
> To: Voelkel, Andy; antlr-interest@antlr.org
> Subject: RE: [antlr-interest] How viable is the Csharp3 target? (more
> specific questions)
>
>
>
> Andy,
>
>
>
> In addition to the other's suggestions, change HIDDEN to Hidden.  The C#
> target attempts to use standard C# conventions when possible. It can be
> frustrating when working from the books and Java-focused documentation, but
> once you get past the few differences and gain some momentum, you should not
> have too many other compatibility issues.
>
>
>
> Kevin Carroll
>
>
>
> -Original Message-
>
> From: antlr-interest-boun...@antlr.org antlr-interest-boun...@antlr.org> [mailto:antlr-interest-boun...@antlr.org
> ] On Behalf Of Voelkel,
> Andy
>
> Sent: Wednesday, October 19, 2011 1:26 PM
>
> To: Sam Harwell; 'pragmaik'; antlr-interest@antlr.org antlr-interest@antlr.org>
>
> Subject: Re: [antlr-interest] How viable is the Csharp3 target? (more
> specific questions)
>
>
>
> Hi,
>
>
>
>
>
>
>
> First, thanks for the encouragement. Knowing there are active users out
> there makes all the difference.
>
>
>
>
>
>
>
> I've now taken the first example from "the definitive ANTLR reference" and
> tried to get it to work, first using the Visual Studio Extensions and
> templates, and then also manually running the ANTLR3.exe file at the command
> line, just to verify that my problems are in the generated code and are not
> errors generated during the generation of code (since the Visual Studio
> Extensions and associated instructions seem to produce projects that both
> generate code and then build it).
>
>
>
>
>
>
>
> So my grammar is this simple:
>
>
>
>
>
>
>
> grammar Lexer1;
>
>
>
>
>
>
>
> options {
>
>
>
>language=CSharp3;
>
>
>
> }
>
>
>
>
>
>
>
> /** Match things like "call foo;" */
>
>
>
> r : 'call' ID ';' {System.out.println("invoke "+$ID.text);} ;
>
>
>
> ID: 'a'..'z'+ ;
>
>
>
> WS: (' '|'\n'|'\r')+   {$channel=HIDDEN;} ; // ignore whitespace
>
>
>
>
>
>
>
> When I compile the code generated by ANTLR3, I get these errors:
>
>
>
>
>
> K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(28,2): warning
> CS3021: 'Lexer1Parser' does not need a CLSCompliant attribute because the
> assembly does not have a CLSCompliant attribute K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error
> CS1041: Identifier expected; 'out' is a keyword K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Parser.cs(86,11): error
> CS1525: Invalid expression term 'out'
>
> K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(28,2): warning
> CS3021: 'Lexer1Lexer' does not need a CLSCompliant attribute because the
> assembly does not have a CLSCompliant attribute K:\Plantronics\Development
> Sandbox\AntlrTest\AntlrTest\obj\x86\Debug\Lexer1Lexer.cs(276,13): error
> CS0103: The name 'HIDDEN' does not exist in the current context
>
>
>
>
>
>
>
> The errors regarding "System.out" make sense, that seems like a call to a
> Java function that does not exist 

[il-antlr-interest: 34469] Re: [antlr-interest] Rewriting a list of tokens to a list of custom tokens

2011-10-19 Thread Christian
No, your solution still generates invalid java code for me. Did you test
your solution? The TYPE token does not accept a list as parameter. It is
a simple token defined within the token block at the top of the grammar.
It seems that the construction of an implicit list is only possible for
rules and read token within the rule, but not for imaginary tokens. I
hope I am wrong.

Please make more solution suggestions.

Am 19.10.2011 17:40, schrieb Jim Idle:
> t1+='void' (t2+='*')* -> ^(LIST TYPE[$t1]+ TYPE[$t2]+)
>
> By interpolating from your question. At least, that should get you on the
> right track.
>
>
> Jim
>
>> -Original Message-
>> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
>> boun...@antlr.org] On Behalf Of Christian
>> Sent: Wednesday, October 19, 2011 5:40 AM
>> To: antlr-interest@antlr.org
>> Subject: [antlr-interest] Rewriting a list of tokens to a list of
>> custom tokens
>>
>> Hello ANTLR community,
>>
>> I want to get
>>
>> t+='void' (t+='*')*
>>
>> to a list of a custom token type, say TYPE. That is, each element/token
>> of the list should change its original type to the type TYPE.
>> The following approach does not work because invalid java code is
>> generated:
>>
>> t+='void' (t+='*')* -> ^(TYPE[$t]+)
>>
>> The following implicit list generation works fine, however each element
>> retains its original type:
>>
>> t+='void' (t+='*')* -> ^($t+)
>>
>> Can anyone tell me, whether and how this could be done?
>>
>> Thanks in advance,
>> Christian
>>
>> 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

-- 
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: 34470] Re: [antlr-interest] Rewriting a list of tokens to a list of custom tokens

2011-10-19 Thread Jim Idle
Sorry, I did not see that list thing, but I was trying to get you on the
right track.

First, don't use literals
Put the tokens in subrules
Change the token type in subrule (I usually just set the type field in the
token, but that is a bit of a cheat)
I don't have time to test every code snippet that I post here


x: t1+=void (t2+=star)* -> ^(LIST $t1 $t2*) ;

void: t=VOID -> TYPE[$t];
stat: t=STAR -> TYPE[$t];

VOID: 'void';
STAR: '*';

Jim



> -Original Message-
> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> boun...@antlr.org] On Behalf Of Christian
> Sent: Wednesday, October 19, 2011 2:24 PM
> To: antlr-interest@antlr.org
> Subject: Re: [antlr-interest] Rewriting a list of tokens to a list of
> custom tokens
>
> No, your solution still generates invalid java code for me. Did you
> test your solution? The TYPE token does not accept a list as parameter.
> It is a simple token defined within the token block at the top of the
> grammar.
> It seems that the construction of an implicit list is only possible for
> rules and read token within the rule, but not for imaginary tokens. I
> hope I am wrong.
>
> Please make more solution suggestions.
>
> Am 19.10.2011 17:40, schrieb Jim Idle:
> > t1+='void' (t2+='*')* -> ^(LIST TYPE[$t1]+ TYPE[$t2]+)
> >
> > By interpolating from your question. At least, that should get you on
> > the right track.
> >
> >
> > Jim
> >
> >> -Original Message-
> >> From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-
> >> boun...@antlr.org] On Behalf Of Christian
> >> Sent: Wednesday, October 19, 2011 5:40 AM
> >> To: antlr-interest@antlr.org
> >> Subject: [antlr-interest] Rewriting a list of tokens to a list of
> >> custom tokens
> >>
> >> Hello ANTLR community,
> >>
> >> I want to get
> >>
> >> t+='void' (t+='*')*
> >>
> >> to a list of a custom token type, say TYPE. That is, each
> >> element/token of the list should change its original type to the
> type TYPE.
> >> The following approach does not work because invalid java code is
> >> generated:
> >>
> >> t+='void' (t+='*')* -> ^(TYPE[$t]+)
> >>
> >> The following implicit list generation works fine, however each
> >> element retains its original type:
> >>
> >> t+='void' (t+='*')* -> ^($t+)
> >>
> >> Can anyone tell me, whether and how this could be done?
> >>
> >> Thanks in advance,
> >> Christian
> >>
> >> 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

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.