Package com.sun.msv.grammar

Examples of com.sun.msv.grammar.Expression


   
    Set workQueue = new java.util.HashSet();
    workQueue.add(rootSymbol);
    while(!workQueue.isEmpty()) {
      // get the first one in the queue.
      Expression symbol = (Expression)workQueue.iterator().next();
      workQueue.remove(symbol);
       
      Rule[] rs = this.getAll(symbol);
      assert(rs!=null && rs.length!=0);
       
      result.addAll(symbol,rs);
       
      for( int i=0; i<rs.length; i++ ) {
        for( int j=0; j<rs[i].right.length; j++ ) {
          Expression e = rs[i].right[j];
          if(!Util.isTerminalSymbol(e) && !result.contains(e)) {
            if(!recurseElement && (e instanceof NameClassAndExpression) )
              // if this is ElementExp or AttributeExp and
              // we don't want to recursively visit them.
              continue;
View Full Code Here


     */
    private Grammar union( Grammar g1, Grammar g2 ) {
        // either g1.getPool() or g2.getPool() is OK.
        // this is just a metter of performance problem.
        final ExpressionPool pool = g1.getPool();
        final Expression top = pool.createChoice(g1.getTopLevel(),g2.getTopLevel());
       
        return new Grammar() {
            public ExpressionPool getPool() {
                return pool;
            }
View Full Code Here

       
        return onAttribute( docDecl.attToken, refErr );
    }
   
    protected boolean onAttribute( AttributeToken token, StringRef refErr ) {
        Expression r = docDecl.attFeeder.feed( this.expression, token, ignoreUndeclaredAttributes );
       
        if( r!=Expression.nullSet ) {
            // this attribute is properly consumed.
            expression = r;
           
View Full Code Here

    }
   

    public boolean onEndAttributes( StartTagInfo sti, StringRef refErr ) {
       
        Expression r = docDecl.attPruner.prune( this.expression );
        if( r!=Expression.nullSet ) {
            // there was no error.
            this.expression = r;
            return true;
        }
View Full Code Here

   
   
   
    protected boolean stepForward( Token token, StringRef errRef ) {
       
        Expression residual = docDecl.resCalc.calcResidual( expression, token );
       
        if( com.sun.msv.driver.textui.Debug.debug ) {
            System.out.println("residual of stepForward("+token+")");
            System.out.print(com.sun.msv.grammar.util.ExpressionPrinter.printContentModel(expression));
            System.out.print("   ->   ");
View Full Code Here

       
        CombinedChildContentExpCreator.ExpressionPair combinedEoC =
            cccc.get( expression, null, false );
       
        // get residual of EoC.
        Expression eocr = docDecl.resCalc.calcResidual( expression, AnyElementToken.theInstance );
       
        Expression continuation = docDecl.pool.createChoice(
            expression, eocr );
        Expression contentModel = combinedEoC.content;
       
        if( com.sun.msv.driver.textui.Debug.debug )
        {
            System.out.println("content model of recovery acceptor:"+
                com.sun.msv.grammar.util.ExpressionPrinter.printContentModel(contentModel) );
View Full Code Here

    private String diagnoseBadTagName( StartTagInfo sti ) {
        final CombinedChildContentExpCreator cccc = docDecl.cccec;
       
       
        // try creating combined child content pattern without tag name check.
        Expression r = cccc.get(expression,sti,false).content;
           
        if( r==Expression.nullSet )
            // no element is allowed here at all.
            return docDecl.localizeMessage( REDocumentDeclaration.DIAG_ELEMENT_NOT_ALLOWED, sti.qName );
       
View Full Code Here

        // if the combined child content expression is not complex,
        // only binary expressions used are choice and sequence.
                           
        // this is the choice of all constraints that made this
        // attribute fail.
        Expression constraint = rtoken.getFailedExp();
                           
        // The problem here is that sti.attributes.getValue(i)
        // didn't satisfy this expression.
                           
        // test some typical expression patterns and
View Full Code Here

//            // hope is remote that we can find required attributes.
//               
//            // TODO: reduce strength by converting concur to choice?
//            return null;
       
        Expression e = expression.visit(docDecl.attPicker);
               
        if( e.isEpsilonReducible() )    throw new Error();    // assertion
        // if attribute expression is epsilon reducible, then
        // AttributePruner must return Expression other than nullSet.
        // In that case, there should have been no error.

        final Set s = new java.util.HashSet();
        boolean more = false;
               
        while( e instanceof ChoiceExp ) {
            ChoiceExp ch = (ChoiceExp)e;
                   
            NameClass nc = ((AttributeExp)ch.exp2).nameClass;
            if( nc instanceof SimpleNameClass )
                s.add( nc.toString() );
            else
                more = true;
           
            e = ch.exp1;
        }
       
        if( e==Expression.nullSet )
            // we are in the full panic mode.
            // abandon diagnosis.
            return null;
       
        if(!(e instanceof AttributeExp ))    throw new Error(e.toString());    //assertion
       
        NameClass nc = ((AttributeExp)e).nameClass;
        if( nc instanceof SimpleNameClass )
            s.add( nc.toString() );
        else
View Full Code Here

    private String diagnoseUnexpectedLiteral( StringToken token ) {
        final StringRecoveryToken srt = new StringRecoveryToken(token);
       
        // this residual corresponds to the expression we get
        // when we replace thie unexpected token by one of expected tokens.
        Expression recoveryResidual
            = docDecl.resCalc.calcResidual(expression,srt);
       
        if( recoveryResidual==Expression.nullSet )
            // we now know that no string literal was expected at all.
            return docDecl.localizeMessage( REDocumentDeclaration.DIAG_STRING_NOT_ALLOWED, token.literal.trim() );
View Full Code Here

TOP

Related Classes of com.sun.msv.grammar.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.