Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1673 > unrolled thread

antlr

Started byruben safir <ruben@mrbrklyn.com>
First post2016-03-13 05:01 -0400
Last post2016-03-23 02:56 -0400
Articles 4 — 2 participants

Back to article view | Back to comp.compilers


Contents

  antlr ruben safir <ruben@mrbrklyn.com> - 2016-03-13 05:01 -0400
    Re: antlr George Neuner <gneuner2@comcast.net> - 2016-03-15 10:53 -0400
      Re: antlr ruben safir <ruben@mrbrklyn.com> - 2016-03-22 23:54 -0400
        Re: antlr George Neuner <gneuner2@comcast.net> - 2016-03-23 02:56 -0400

#1673 — antlr

Fromruben safir <ruben@mrbrklyn.com>
Date2016-03-13 05:01 -0400
Subjectantlr
Message-ID<16-03-001@comp.compilers>
anyone using antlr?  I'm taking compiler theory for my masters and they
are using in with Java in intellij... and I find it a bit difficult to
get around the IDE.
[There is a newsgroup comp.compilers.tools.pccts but it's been a long time
since it's seen any traffic. -John]

[toc] | [next] | [standalone]


#1676

FromGeorge Neuner <gneuner2@comcast.net>
Date2016-03-15 10:53 -0400
Message-ID<16-03-004@comp.compilers>
In reply to#1673
On Sun, 13 Mar 2016 05:01:01 -0400, ruben safir <ruben@mrbrklyn.com>
wrote:

>anyone using antlr?  I'm taking compiler theory for my masters and they
>are using in with Java in intellij... and I find it a bit difficult to
>get around the IDE.

The IDE is not Antlr - it is IntelliJ with a plug-in that interfaces
to the separate[*] Antlr tool.  I've never used IntelliJ so I can't
help you with that.

I have used Antlr via command line, through makefiles, and via
external tool options in a few other IDEs.  I haven't used the current
version (4.x), but I have projects based on earlier versions.


[*] Antlr is installed along with the plug-in, but it is separate.


>[There is a newsgroup comp.compilers.tools.pccts but it's been a long time
>since it's seen any traffic. -John]

Yes.  There's some discussion of old versions of Antlr.  PCCTS itself
was a earlier tool from the same author (Terence Parr).  Antlr began
as a more powerful version of PCCTS.

Antlr now is supported mainly on Stackoverflow.com and via a Google
group.  see http://www.antlr.org/support.html


But that won't help with the IntelliJ issue.  If it's hard to use,
that's the fault of the plug-in (or the platform).

George

[toc] | [prev] | [next] | [standalone]


#1677

Fromruben safir <ruben@mrbrklyn.com>
Date2016-03-22 23:54 -0400
Message-ID<16-03-005@comp.compilers>
In reply to#1676
On Tue, 15 Mar 2016 10:53:25 -0400, George Neuner wrote:

> Antlr now is supported mainly on Stackoverflow.com and via a Google
> group.  see http://www.antlr.org/support.html

Lets try usenet

I have two grammars, one with white space

WS	 : [ \n\t\r]+ ->skip;


and one, or two actually,  for comments
COMMENT: '#' .*? '\n' -> channel(HIDDEN);
COMMENT2: '/*' .*? '*/' -> channel(HIDDEN); //This pulls through
                                            //linefeeds?

What is the practical difference between the channel(HIDDEN) and the skip

[toc] | [prev] | [next] | [standalone]


#1678

FromGeorge Neuner <gneuner2@comcast.net>
Date2016-03-23 02:56 -0400
Message-ID<16-03-006@comp.compilers>
In reply to#1677
On Tue, 22 Mar 2016 23:54:19 -0400, ruben safir <ruben@mrbrklyn.com>
wrote:

>On Tue, 15 Mar 2016 10:53:25 -0400, George Neuner wrote:
>
>> Antlr now is supported mainly on Stackoverflow.com and via a Google
>> group.  see http://www.antlr.org/support.html
>
>Lets try usenet
>
>I have two grammars, one with white space
>
>WS	 : [ \n\t\r]+ ->skip;
>
>
>and one, or two actually,  for comments
>COMMENT: '#' .*? '\n' -> channel(HIDDEN);
>COMMENT2: '/*' .*? '*/' -> channel(HIDDEN); //This pulls through
>                                            //linefeeds?
>
>What is the practical difference between the channel(HIDDEN) and the skip

"skip" just throws away the match.  There is no token produced for
anything that is skipped.

"channel" is a bit more complicated.

Antlr uses named streams - "channels" - to communicate between the
lexer and parser.  The parser only draws tokens from one stream at a
time (but you can change which stream it follows).

There are two built in channels: DEFAULT and HIDDEN.  The parser
(unless told otherwise) listens to DEFAULT.  Tokens sent to HIDDEN are
not parsed, but are still available to be inserted back into output
later.  This is useful for, e.g., source->source transformations
preserving comments.

You can define other channels for different purposes, e.g., an
embedded DSL could be handled by a separate parser.

Unfortunately a useful example would be complicated.


The online documentation tracks the state of the latest version, but
the best source for insight into how Antlr works is Terence's book.

George

[toc] | [prev] | [standalone]


Back to top | Article view | comp.compilers


csiph-web