[antlr-interest] nondeterminism

PATERSON, Robert r.paterson at ioof.com.au
Sun Nov 20 22:22:59 PST 2005


This is an educated guess as I'm a bit of an ANTLR newbie, but I imagine
the non-determinism is due to (item)* in subfolder being optional. It's
not sure when it encounters two item titles in a row, whether the
H3_START is the manadatory start of an 'item_title' in 'subfolder' or
the start of an optional 'item_title' 'item' at the end of a 'subfolder'
rule.



-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Roshan Achar
Sent: Monday, 21 November 2005 2:06 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] nondeterminism

Hi,

I am trying to write grammer for a bookmarks file. Iam getting the
following error -

 warning:nondeterminism upon
Bookmarks.g:44:     k==1:A_START,H3_START
Bookmarks.g:44:     between alt 1 and exit branch of block

I am not sure of the cause since with k=2 there should be no
nondeterminism between A_START and H3_START.

The grammer is as follows -

options
{
    language = "CSharp";
}

class BookmarksParser extends Parser;

file
    : (item)+
    ;

item
    : (shortcut | subfolder)
    ;

subfolder
    : (item_title) (item)*
    ;

shortcut
    : (A_START) (TEXT)+  (TAG_END)
    ;

item_title
    : (H3_START) (TEXT)+ (TAG_END)
    ;

class BookmarksLexer extends Lexer;
options
{
    k=2;
    //caseSensitive=false;
}

TAG_START
    : '<' ~( 'A' | 'H' | 'a' | 'h' | '/' | '<' | '>' ) (TEXT)*
(ATTRIBUTES)* '>'
    {
        $setType(Token.SKIP);
    }
    ;

TAG_END
    : "</" (~( '>' ))+ '>'
    {
        $setType(Token.SKIP);
    }
    ;

H3_START
    : "<H3"  (attr:ATTRIBUTES {Console.WriteLine("Got attribute -
"+attr.getText());})* '>'
    ;


// Atleast one attribute href="" is needed A_START
    : "<A"  (attr:ATTRIBUTES {Console.WriteLine("Got attribute -
"+attr.getText());})+  '>'
    ;

ATTRIBUTES
    : (TEXT)+ '=' '"' (~('"' | '<' | '>' ))* '"'
    ;

TEXT
    : ~('"' | '<' | '>' | '\r' | '\t' | '\n' | ' ')
    ;

SKIP_WS
    : ( '\r' '\n'
      | '\n'
      | '  '
      | '\t' )
    {
        $setType(Token.SKIP);
    }
    ;

The file format is specified at -
http://msdn.microsoft.com/workshop/browser/external/overview/bookmark_fi
le_format.asp

Any help is appreciated.

Thanks ,
Roshan
broshan at gmail.com


****************************************************************************
IMPORTANT - PLEASE READ
This communication is intended only for the use of the addressee and 
may contain personal information, confidential information or legally 
privileged information. If personal information is contained in this e-mail, 
then it is governed by the Privacy Act 1988 and must be treated in 
accordance with the Privacy Act 1988 by the recipient. The legal 
privilege and confidentiality attached to this e-mail is not waivered, 
lost or destroyed by reason of mistaken delivery to you. If you are not 
the intended recipient, we would appreciate immediate notification by 
return e-mail or telephoning +61-3-8614-4444 and ask that the message 
be permanently deleted from your system. If you are the intended 
recipient of this communication you should not copy, disclose or distribute this communication without the authority of IOOF or its related entities (the IOOF Group).
Any views expressed in this message are those of the individual sender, 
except where they are specifically stated to be the views of the IOOF 
Group.
This e-mail and any attachments have been scanned for computer viruses 
using anti-viral software, but you should also perform your own scan. We 
do not accept liability for any loss or damage, whether caused by our own negligence or not, that results from a computer virus or a defect in the transmission of the e-mail or any attached file.
****************************************************************************



More information about the antlr-interest mailing list