[antlr-interest] Why waiting timeout? why cannot find symbol?

Su Zhang westlifezs at gmail.com
Sat Nov 22 09:36:39 PST 2008


Hi all,

I meet two very strange problems when debugging my program,the first
one is "timeout waiting connect remote parser", the other is cannot
find symbol
[11:17:54] symbol  : variable b64
[11:17:54] location: class assignment6Parser
[11:17:54]             b64=i.getText();
is anybody have solutions to similar problems?
here is my grammar just for common tree
:

grammar assignment6;

options {
    output=AST;
    ASTLabelType=CommonTree;
    k=*;
    memoize = true;
}

tokens {
        CredentialHeader  = '-----BEGIN MPKI CREDENTIAL-----';
        CredentialEnd  = '-----END MPKI CREDENTIAL-----';
        PublicKeyHeader  = '-----BEGIN PUBLIC KEY-----';
        PublicKeyEnd = '-----END PUBLIC KEY-----';
        SignatureHeader  = '-----BEGIN SIGNATURE-----';
        SignatureEnd  = '-----END SIGNATURE-----';
        ValidityHeader  = '-----BEGIN VALIDITY-----';
        ValidityEnd = '-----END VALIDITY-----';
        CertHeader = '-----BEGIN MPKI CERTIFICATE-----';
        CertEnd  = '-----END MPKI CERTIFICATE-----';
        ChallengeHeader  = '-----BEGIN MPKI CHALLENGE-----';
        ChallengeEnd = '-----END MPKI CHALLENGE-----';
        ResponseHeader = '-----BEGIN MPKI CHALLENGE RESPONSE-----';
        ResponseEnd  = '-----END MPKI CHALLENGE RESPONSE-----';
        RequestHeader = '-----BEGIN REPOSITORY CLIENT REQUEST-----';
        RequestEnd = '-----END REPOSITORY CLIENT REQUEST-----';
        ReplyHeader  = '-----BEGIN REPOSITORY SERVER REPLY-----';
        ReplyEnd  = '-----END REPOSITORY SERVER REPLY-----';
        NotBefore  = 'Not before:';
        NotAfter  = 'Not after:';
        DAYTIME = 'daytime';
        Read = 'read';
        Write = 'write';
        Commit = 'commit';
        //Says = 'says';
       // Granted = 'granted';
        //Denied = 'denied';
       // request = 'request';

}

@header {

}

@lexer::header {
//package certificate;

}
prog    :    credential
    ;

credential
    :    CredentialHeader publicKey certificate* CredentialEnd
    ;

certificate returns [ String cert ]
    :   CertHeader clause+ validity? publicKey signature CertEnd
        { /*cert = 74*/}
    ;

signature
    :  SignatureHeader b=base{}	 SignatureEnd
     // { isTypeName(b.getText()); }
    ;

validity  returns [String v]
    : ValidityHeader NotBefore tb= timeTuple NotAfter ta= timeTuple ValidityEnd
    { /*v= tb + ta;*/ }
    ;

timeTuple  returns [String time]
    : 'datime' '('t1= num ','t2= num ','t3= num ','t4= num ','t5= num
','t6= num ')' '.'
    {//time= new timeTuple(t1, t2, t3, t4, t5 ,t6);
    // time = "daytime" + '(' + t1 + ','+ t2 +','+ t3 +',' + t4+',' +
t5+',' +t6 + ')';
    }
    ;

//num    returns [String t]
      //  :n = Num
       // {/*t = n.getText();*/}
       // ;

clause    : literal '.' | literal ':-' literal (',' literal)* '.'
    ;

literal    : predicate | 'says' '(' id ',' predicate')'
    ;


predicate
    : id'(' id ( ',' id)* ')'
    ;


publicKey
    :    PublicKeyHeader b=base PublicKeyEnd
     // { isTypeName(b.getText()); }
    ;

challenge
    :     ChallengeHeader base ChallengeEnd
    ;
response
    :     ResponseHeader b= base ResponseEnd
          //  { isTypeName(b.getText()); }
    ;

//Base64Block
//       : s =Base64Block
//           {isType(s.getText())}? Base64Block
//       ;
base  returns [String b64 ]	
     : i= ID {!(i.getText().contains("-"))
}?{!(i.getText().contains("_"))}? {b64=i.getText();}
     ;
id  returns [String identification]	
     : ident= ID
{!(ident.getText().contains("+"))}?{!(ident.getText().contains("="))}?{!(ident.getText().contains("/"))}?
 {identification= ident.getText();}
     ;
num  	  returns [String no]
        :	n= ID {no=
n.getText();}{n.getText().contains("0")}?{n.getText().contains("1")}?{n.getText().contains("2")}?{n.getText().contains("3")}?{n.getText().contains("4")}?{n.getText().contains("5")}?{n.getText().contains("6")}?{n.getText().contains("7")}?{n.getText().contains("8")}?{n.getText().contains("9")}?
        ;
request
    :     RequestHeader 'request' '('op ',' ID ')' RequestEnd
    ;
op      :    'read' | Write | Commit
    ;
reply      :     ReplyHeader result ReplyEnd
    ;
result  :     'granted' | 'denied'
    ;

ID   :	  ('a'..'z' | 'A'..'Z' | 'O'..'9' | '/' | '+' | '='| '-'| '_'|':')*
     ;
//Id   :     ( 'a'..'z' | 'A'..'Z' | '_' ) ( 'a'..'z' | 'A'..'Z' | '_'
|'-'| '0'..'9' ) *;
//Base64Block      : ('a'..'z' | 'A'..'Z' | 'O'..'9' | '/' | '+' | '=')*;
//ChallengeBlock   : ( 'a'..'z' | 'A'..'Z' | 'O'..'9'| ':')* ;
//Num   :     ( '0'..'9' ) * ;
//fragment
WS  :  (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;}
    ;

thanks alot!


2008/11/21, antlr-interest-request at antlr.org <antlr-interest-request at antlr.org>:
> Send antlr-interest mailing list submissions to
> 	antlr-interest at antlr.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.antlr.org/mailman/listinfo/antlr-interest
> or, via email, send a message with subject or body 'help' to
> 	antlr-interest-request at antlr.org
>
> You can reach the person managing the list at
> 	antlr-interest-owner at antlr.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of antlr-interest digest..."
>
>
> Today's Topics:
>
>    1. StringTemplates in C? (Robert Soule)
>    2. Re: StringTemplates in C? (Sam Harwell)
>    3. Does it make sense to use Antlr for interactive	parsing?
>       (Vishwanath Hawargi)
>    4. Re: StringTemplates in C? (Jim Idle)
>    5. Re: Does it make sense to use Antlr for interactive parsing?
>       (Jim Idle)
>    6. Updated vim syntax highlighter (Davyd Madeley)
>    7. Re: Maven builds, hudson continuous (Jean Bovet)
>    8. How to get the last token type just recognized in	the lexer?
>       (chain one)
>    9. Re: Updated vim syntax highlighter (Jim Idle)
>   10. Re: Updated vim syntax highlighter (Terence Parr)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 20 Nov 2008 15:38:27 -0500
> From: "Robert Soule" <robert.soule at gmail.com>
> Subject: [antlr-interest] StringTemplates in C?
> To: antlr-interest at antlr.org
> Message-ID:
> 	<d1316fd70811201238x5fc18f9aga508c3764ed1421a at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi,
>
> Is there a port of StringTemplates to C? I would like to have my
> tree grammar with C target language output templates, but I can't
> seem to compile my grammar, The www.stringtemplate.org
> website only says "with ports for C# and Python", which makes
> me suspect I'm in for some bad news...
>
> -Robert
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 20 Nov 2008 14:52:28 -0600
> From: "Sam Harwell" <sharwell at pixelminegames.com>
> Subject: Re: [antlr-interest] StringTemplates in C?
> To: "Robert Soule" <robert.soule at gmail.com>,
> 	<antlr-interest at antlr.org>
> Message-ID:
> 	<86403CA0939415448BCCB83855EFE09A64E911 at Bloodymary.ironwillgames.com>
> Content-Type: text/plain;	charset="us-ascii"
>
> StringTemplate relies heavily on features that would be extremely
> difficult to duplicate in C. If there was ever a "port" of
> StringTemplate to C, it would altered to the point of being a different
> product.
>
> Sam
>
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Robert Soule
> Sent: Thursday, November 20, 2008 2:38 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] StringTemplates in C?
>
> Hi,
>
> Is there a port of StringTemplates to C? I would like to have my
> tree grammar with C target language output templates, but I can't
> seem to compile my grammar, The www.stringtemplate.org
> website only says "with ports for C# and Python", which makes
> me suspect I'm in for some bad news...
>
> -Robert
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
> ess
>
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 20 Nov 2008 15:13:11 -0600
> From: "Vishwanath Hawargi" <vhawargi at gmail.com>
> Subject: [antlr-interest] Does it make sense to use Antlr for
> 	interactive	parsing?
> To: antlr-interest at antlr.org
> Message-ID:
> 	<4c63b36c0811201313k31488297rd9f85bb99415674a at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hello,
>  Another dumb question from me.
>
> I am looking for parsing an expression from the command line. Each of
> these expressions are syntactically correct.
> Instead of having a input file, i am having one expression at a time
> to  be processed.
> In this situation is it optimal/ ok to use antlr to validate and
> generate the tokens?
>
> Also, how do i process input arg instead of input file?
>
> please let me know.
>
> thank you.
> vishwa
>
>
> ------------------------------
>
> Message: 4
> Date: Thu, 20 Nov 2008 14:44:28 -0800
> From: Jim Idle <jimi at temporal-wave.com>
> Subject: Re: [antlr-interest] StringTemplates in C?
> To: Robert Soule <robert.soule at gmail.com>
> Cc: antlr-interest at antlr.org
> Message-ID: <1227221068.22288.53.camel at jimi.temporal-wave.com>
> Content-Type: text/plain; charset="us-ascii"
>
> On Thu, 2008-11-20 at 15:38 -0500, Robert Soule wrote:
>
>> Hi,
>>
>> Is there a port of StringTemplates to C? I would like to have my
>> tree grammar with C target language output templates, but I can't
>> seem to compile my grammar, The www.stringtemplate.org
>> website only says "with ports for C# and Python", which makes
>> me suspect I'm in for some bad news...
>
>
> Stringtemplate is object based, so there is no way to create a C port,
> at least as the design stands. Something similar could be created but
> would probably be relatively unwieldy.
>
> Jim
>
>
>>
>> -Robert
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://www.antlr.org/pipermail/antlr-interest/attachments/20081120/4655e873/attachment-0001.html
>
> ------------------------------
>
> Message: 5
> Date: Thu, 20 Nov 2008 14:50:02 -0800
> From: Jim Idle <jimi at temporal-wave.com>
> Subject: Re: [antlr-interest] Does it make sense to use Antlr for
> 	interactive parsing?
> Cc: antlr-interest at antlr.org
> Message-ID: <1227221402.22288.56.camel at jimi.temporal-wave.com>
> Content-Type: text/plain; charset="us-ascii"
>
> On Thu, 2008-11-20 at 15:13 -0600, Vishwanath Hawargi wrote:
>
>> Hello,
>>  Another dumb question from me.
>>
>> I am looking for parsing an expression from the command line. Each of
>> these expressions are syntactically correct.
>> Instead of having a input file, i am having one expression at a time
>> to  be processed.
>> In this situation is it optimal/ ok to use antlr to validate and
>> generate the tokens?
>>
>> Also, how do i process input arg instead of input file?
>>
>
>
> It makes sense if the input is relatively complicated, but if it is
> just: command {options} something, then probably custom code is as good.
> You run it exactly the same way as a file but use the StringStream
> rather than the file stream. See teh api docs:
>
> http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1_a_n_t_l_r_string_stream.html
> http://www.antlr.org/api/Java
>
> Jim
>
>
>> please let me know.
>>
>> thank you.
>> vishwa
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://www.antlr.org/pipermail/antlr-interest/attachments/20081120/721a45a1/attachment-0001.html
>
> ------------------------------
>
> Message: 6
> Date: Fri, 21 Nov 2008 13:32:58 +0900
> From: Davyd Madeley <davyd at fugro-fsi.com.au>
> Subject: [antlr-interest] Updated vim syntax highlighter
> To: antlr-interest at antlr.org
> Message-ID: <1227241978.751.152.camel at tc35>
> Content-Type: text/plain; charset="us-ascii"
>
> I found an old vim syntax highlighter on antlr-interest,  but it didn't
> deal very nicely with some things in my grammar.
>
> I've updated it and thought I'd share it with anyone who might be
> interested.
>
> Add it to ~/.vim/syntax/
>
> And add something like this to your .vimrc:
> au BufRead,BufNewFile *.g       set syntax=antlr3
>
> Regards,
> --davyd
>
> --
> Davyd Madeley        Software Engineer
> Fugro Seismic Imaging, Perth Australia
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: antlr3.vim
> Type: application/octet-stream
> Size: 2040 bytes
> Desc: not available
> Url :
> http://www.antlr.org/pipermail/antlr-interest/attachments/20081121/0e4bcde1/attachment-0001.obj
>
> ------------------------------
>
> Message: 7
> Date: Thu, 20 Nov 2008 22:06:36 -0800
> From: Jean Bovet <antlr-list at arizona-software.ch>
> Subject: Re: [antlr-interest] Maven builds, hudson continuous
> To: Terence Parr <parrt at cs.usfca.edu>
> Cc: antlr-interest <antlr-interest at antlr.org>
> Message-ID: <0990F569-A597-4BC1-9A04-AA97257C1077 at arizona-software.ch>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> Great job Jim!
>
> Jean
>
> On Nov 20, 2008, at 10:28 AM, Terence Parr wrote:
>
>> HI everyone,
>>
>> Just wanted to follow up on this note to recognize Jim Idle (or is it
>> Idol!?) for his extraordinary efforts to get maven and the continuous
>> build server Hudson working! It really is a huge improvement in an
>> area that I always lag behind (build systems).
>>
>> I'll update the website to include all of these links for easy
>> reference.
>>
>> Ter
>>
>> On Nov 19, 2008, at 4:39 PM, Jim Idle wrote:
>>
>>> As some of you may have noticed, a lot of work has been done lately
>>> to provide the ANTLR components as Maven artifacts
>>> (http://maven.apache.org/
>>> ), to provide an auto-syncing repository so that new release are
>>> available via Maven within 4 hours of release and finally to create
>>> Maven projects so that it is easy for people other than Ter to build
>>> ANTLR.
>>>
>>> If you build Java projects and have not come across Maven then I
>>> highly recommend taking the 10 minute tour as it is pretty useful.
>>>
>>> As a side effect of this work, if you install the Maven plugin into
>>> your IDE (Netbeans/IDEA/Eclipse) then you will find that you can
>>> open the directory that contains the ANTLR source code (look for the
>>> pom.xml file) in the IDE and it will automatically know how to build
>>> and test the software.
>>>
>>> A further side effect however, should make the need for you to build
>>> your own development snapshots. This is because we have also
>>> implemented an instance of the Hudson continuous build server. Here
>>> you can find the latests build status of all the ANTLR tools and you
>>> can download the latest development snapshot, if you are not using
>>> Maven.
>>>
>>> You can find the hudson reports at: http://www.antlr.org:8888/
>>> hudson  (JIRA is still at http://www.antlr.org:8888 )
>>>
>>> Finally, if you are a Maven user and for some reason feel the need
>>> to build with the latest snapshot releases (perhaps to get a bug fix
>>> and so on), then you can connect to the ANTLR snapshot repository by
>>> specifying it in your maven pom.xml file as follows:
>>>
>>> <project> ...
>>>
>>>    <!--
>>>
>>>    Inform Maven of the ANTLR snapshot repository, which it will
>>>    need to consult to get the latest snapshot build of the runtime
>>>    and tool directories if it was not built and installed locally.
>>>    -->
>>>    <repositories>
>>>
>>>        <!--
>>>        This is the ANTLR repository.
>>>        -->
>>>        <repository>
>>>            <id>antlr-snapshot</id>
>>>            <name>ANTLR Testing Snapshot Repository</name>
>>>            <url>http://antlr.org/antlr-snapshot</url>
>>>            <snapshots>
>>>                <enabled>true</enabled>
>>>                <updatePolicy>always</updatePolicy>
>>>            </snapshots>
>>>        </repository>
>>>
>>>    </repositories>
>>> ...
>>> </project>
>>>
>>>
>>> Jim
>>>
>>> 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
>>
>
>
>
> ------------------------------
>
> Message: 8
> Date: Fri, 21 Nov 2008 21:30:57 +0800
> From: "chain one" <chainone at gmail.com>
> Subject: [antlr-interest] How to get the last token type just
> 	recognized in	the lexer?
> To: antlr-interest <antlr-interest at antlr.org>
> Message-ID:
> 	<5a92ffb60811210530p6f807a85mb3968c853fe9e93f at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I am right now using antlr V2 to write a parser.And I meet this
> problem,don't know how to fix it.
> The problem is:
>
> Lexer rule:
>
>
> INT
> :    (DIGIT)+
> ;
>
> FLOAT
> :    '.' (DIGIT)+ (('e' | 'E') ('+' | '-')? (DIGIT)+)?
> |    '.' ('e' | 'E') ('+' | '-')? (DIGIT)+
>      ;
>
> DIGIT
> : '0'..'9'
> ;
>
> I want to match the strings like:
>
> 0.1E-10
> 0.1e+1
> 0.0
>
> 0.E14
>
> To deal with the case like:"class.e9", ".e9" here could be accepted by FLOAT
> rule and ID rule
>
> So it seems that the only solution is to predict the last token just
> recognized, if the last token is a INT, then FLOAT rule should be followed.
>
> so I need to know what the last token is.
> calling function LA(-1) could do this, however LA(-1) is only available in
> parser not in lexer
>
> So...Is there anyone could tell me how to get the last token type
> just recognized in the lexer?
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://www.antlr.org/pipermail/antlr-interest/attachments/20081121/0ce5b75c/attachment-0001.html
>
> ------------------------------
>
> Message: 9
> Date: Fri, 21 Nov 2008 09:23:05 -0800
> From: Jim Idle <jimi at temporal-wave.com>
> Subject: Re: [antlr-interest] Updated vim syntax highlighter
> To: Davyd Madeley <davyd at fugro-fsi.com.au>
> Cc: antlr-interest at antlr.org
> Message-ID: <1227288185.22288.89.camel at jimi.temporal-wave.com>
> Content-Type: text/plain; charset="us-ascii"
>
> On Fri, 2008-11-21 at 13:32 +0900, Davyd Madeley wrote:
>
>> I found an old vim syntax highlighter on antlr-interest,  but it didn't
>> deal very nicely with some things in my grammar.
>>
>> I've updated it and thought I'd share it with anyone who might be
>> interested.
>>
>> Add it to ~/.vim/syntax/
>>
>> And add something like this to your .vimrc:
>> au BufRead,BufNewFile *.g       set syntax=antlr3
>>
>
> Works a treat for me :-)
>
> We should put this up as a download.
>
> Jim
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://www.antlr.org/pipermail/antlr-interest/attachments/20081121/12af141d/attachment-0001.html
>
> ------------------------------
>
> Message: 10
> Date: Fri, 21 Nov 2008 11:34:47 -0800
> From: Terence Parr <parrt at cs.usfca.edu>
> Subject: Re: [antlr-interest] Updated vim syntax highlighter
> To: Jim Idle <jimi at temporal-wave.com>
> Cc: antlr-interest at antlr.org
> Message-ID: <4AA6C070-81E3-4F0E-B9C1-FA4ED4BD4C51 at cs.usfca.edu>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> It's in share now.
> Ter
> On Nov 21, 2008, at 9:23 AM, Jim Idle wrote:
>
>> On Fri, 2008-11-21 at 13:32 +0900, Davyd Madeley wrote:
>>>
>>> I found an old vim syntax highlighter on antlr-interest,  but it
>>> didn't
>>> deal very nicely with some things in my grammar.
>>>
>>> I've updated it and thought I'd share it with anyone who might be
>>> interested.
>>>
>>> Add it to ~/.vim/syntax/
>>>
>>> And add something like this to your .vimrc:
>>> au BufRead,BufNewFile *.g       set syntax=antlr3
>>>
>> Works a treat for me :-)
>>
>> We should put this up as a download.
>>
>> Jim
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
>
>
> ------------------------------
>
> _______________________________________________
> antlr-interest mailing list
> antlr-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/antlr-interest
>
>
> End of antlr-interest Digest, Vol 48, Issue 19
> **********************************************
>


-- 
Su Zhang
Computer Information and Science
Kansas State University


More information about the antlr-interest mailing list