Loading ...
Sorry, an error occurred while loading the content.

Help: problem with definitions in query.g

Expand Messages
  • Axel Herold
    Hello, i have problems with following definitions in the query.g file: DATE: (DIGIT) (DIGIT)? / (DIGIT) (DIGIT)? / DIGIT DIGIT DIGIT DIGIT (( | t )(
    Message 1 of 2 , Dec 9, 1998
    • 0 Attachment
      Hello,

      i have problems with following definitions in the query.g file:

      DATE:
      (DIGIT) (DIGIT)? '/' (DIGIT) (DIGIT)? '/' DIGIT DIGIT DIGIT DIGIT (('
      '| '\t')(' '| '\t')* DIGIT (DIGIT)? (':' DIGIT (DIGIT)? (':' DIGIT
      (DIGIT)?)?)?)?
      ;

      NUM_INT :
      (DIGIT) (DIGIT)* ( '.' (DIGIT)* { _ttype = NUM_FLOAT; })?
      ;

      the error:

      ANTLR Parser Generator Version 2.5.0 1989-1998 MageLang Institute
      warning: lexical nondeterminism between rules DATE and NUM_INT upon
      k==1:'0'..'9'
      k==2:'0'..'9'
      k==3:'0'..'9'
      k==4:'0'..'9'
      k==5:'0'..'9'
      k==6:'0'..'9'
      k==7:'0'..'9'
      k==8:'0'..'9'
      k==9:<end-of-token>,'0'..'9'
      k==10:<end-of-token>,'0'..'9'
      k==11:<end-of-token>,'0'..'9'
      k==12:<end-of-token>,'0'..'9'

      I don't understand this error, because I set forward looking for the
      lexer to 12 (see attachment query.g) and a DATE posses a /(slash) at
      second or third place.

      If you have any idea, please send a mail.

      Thanks in advance

      Axel
    • Axel.Herold@xxx.xxxxxxx.xx
      Hello, i have problems with following definitions in the query.g file: DATE: (DIGIT) (DIGIT)? / (DIGIT) (DIGIT)? / DIGIT DIGIT DIGIT DIGIT (( | t )(
      Message 2 of 2 , Dec 9, 1998
      • 0 Attachment
        Hello,

        i have problems with following definitions in the query.g file:

        DATE:
        (DIGIT) (DIGIT)? '/' (DIGIT) (DIGIT)? '/' DIGIT DIGIT DIGIT DIGIT (('
        '| '\t')(' '| '\t')* DIGIT (DIGIT)? (':' DIGIT (DIGIT)? (':' DIGIT
        (DIGIT)?)?)?)?
        ;

        NUM_INT :
        (DIGIT) (DIGIT)* ( '.' (DIGIT)* { _ttype = NUM_FLOAT; })?
        ;

        the error:

        ANTLR Parser Generator Version 2.5.0 1989-1998 MageLang Institute
        warning: lexical nondeterminism between rules DATE and NUM_INT upon
        k==1:'0'..'9'
        k==2:'0'..'9'
        k==3:'0'..'9'
        k==4:'0'..'9'
        k==5:'0'..'9'
        k==6:'0'..'9'
        k==7:'0'..'9'
        k==8:'0'..'9'
        k==9:<end-of-token>,'0'..'9'
        k==10:<end-of-token>,'0'..'9'
        k==11:<end-of-token>,'0'..'9'
        k==12:<end-of-token>,'0'..'9'

        I don't understand this error, because I set forward looking for the
        lexer to 12 (see attachment query.g) and a DATE posses a /(slash) at
        second or third place.

        If you have any idea, please send a mail.

        Thanks in advance

        Axel



        ---------------- quer.g -----------------------


        header
        {
        package DE.siemens.oen.cmpro.AccessService;
        }
        options
        {
        language="Java";
        }

        class ASQueryParser extends Parser;
        options
        {
        k = 2;
        defaultErrorHandler = true;
        buildAST = true;
        tokenVocabulary=ASQueryLanguage;
        codeGenMakeSwitchThreshold = 2;
        codeGenBitsetTestThreshold = 3;
        }

        startRule:
        select where EOF!;

        select:
        SELECT^ citypes;

        where:
        WHERE^ exp EOFEXP!
        ;

        citypes:
        ALL
        |
        ciSubType
        ;

        ciSubType:
        (SOFTLINKS | VERSIONS | CONTAINERS | ITEMS) (TYPEDELIM! ciSubType)?
        ;

        exp:
        logicalOrExpression
        ;


        logicalOrExpression
        :
        logicalAndExpression
        (
        OR^
        logicalAndExpression
        )*
        ;


        logicalAndExpression
        :
        simpleExp
        (
        AND^
        simpleExp
        )*
        ;


        simpleExp:
        (NOT^)? LBRA! exp RBRA!
        |
        attr (LT^ | GT^ | LE^ | GE^ | EQ^ | NEQ^ | DATE_LT^ | DATE_GT^) (attr | value)
        |
        fAttr
        ;


        attr:
        systemAttr
        |
        attributeAttr
        |
        permUnixAttr
        |
        permNtfsAttr
        |
        permPvcsAttr
        |
        COMMENT
        |
        BRANCH
        |
        ELEMTTYPE
        ;

        systemAttr:
        SYSTEM^ ATTRID;

        attributeAttr:
        ATTRIBUTE^ ATTRID;

        permUnixAttr:
        PERMISSION_UNIX^ ATTRID;

        permNtfsAttr:
        PERMISSION_NTFS^ ATTRID;

        permPvcsAttr:
        PERMISSION_PVCS^ ATTRID;

        value:
        STRING |
        DATE |
        NUM_INT|
        NUM_FLOAT |
        WILDCARD
        ;

        fAttr:
        (HASLABEL^ | HASPROMOTIONGROUP^) LBRA! (STRING | WILDCARD) RBRA!;




        class ASQueryLexer extends Lexer;
        options
        {
        k=12;
        caseSensitive=false;
        charVocabulary = '\3'..'\377';
        tokenVocabulary=ASQueryLanguage;
        }

        LBRA: '(';
        RBRA: ')';
        TYPEDELIM: ',';
        EOFEXP: ';';

        SELECT: "select";
        WHERE: "where";
        ALL: "all";

        BRANCH: "branch";
        ELEMTTYPE: "elementtype";
        COMMENT: "comment";

        SOFTLINKS: "softlinks";
        VERSIONS: "versions";
        CONTAINERS: "containers";
        ITEMS: "items";

        SYSTEM: "system";
        ATTRIBUTE: "attribute";
        PERMISSION_UNIX: "permission_unix";
        PERMISSION_NTFS: "permission_ntfs";
        PERMISSION_PVCS: "permission_pvcs";


        LT: "<";
        LE: "<=";
        GT: ">";
        GE: ">=";
        EQ: "=";
        NEQ: "!=";
        DATE_LT: "<<";
        DATE_GT: ">>";

        AND: "and";
        OR: "or";
        NOT: "not";

        HASLABEL: "haslabel";
        HASPROMOTIONGROUP: "haspromotiongroup";

        protected
        DIGIT:
        ('0'..'9');

        LETTER:
        ('a'..'z') | '_';

        STRING:
        '"'
        (ESC|~'"')*
        '"'
        {
        String s = getText();
        s = s.substring(1, s.length()-1);
        setText(s);
        }
        ;


        WILDCARD:
        '/'
        (~'/')*
        '/'
        {
        String s = getText();
        s = s.substring(1, s.length()-1);
        setText(s);
        }
        ;


        DATE:
        (DIGIT) (DIGIT)? '/' (DIGIT) (DIGIT)? '/' DIGIT DIGIT DIGIT DIGIT ((' '| '\t')(' '| '\t')* DIGIT (DIGIT)? (':' DIGIT (DIGIT)? (':' DIGIT (DIGIT)?)?)?)?
        ;


        NUM_INT :
        (DIGIT) (DIGIT)* ( '.' (DIGIT)* { _ttype = NUM_FLOAT; })?
        ;



        ATTRID:
        '.' ((DIGIT) | (LETTER))+
        {
        String s = getText();
        s = s.substring(1, s.length());
        setText(s);
        }
        ;




        protected ESC
        {
        int len = text.length();
        char c = ' ';
        }
        : '\\'
        (
        '"' { c = '"';}
        |
        '\\' { c = '\\';}
        )
        {
        text.setLength(len);
        text.append(c);
        }

        ;

        WS : (' '
        | '\t'
        | '\n' { newline(); }
        | '\r') { _ttype = Token.SKIP; }
        ;
      Your message has been successfully submitted and would be delivered to recipients shortly.