Package org.idpf.epubcheck.util.css.CssExceptions

Examples of org.idpf.epubcheck.util.css.CssExceptions.CssGrammarException


        return sel;
      }
      else
      {
       
        err.error(new CssGrammarException(GRAMMAR_UNEXPECTED_TOKEN, start.location, start.chars));
        return null;
      }

    }
View Full Code Here


          func = createFunctionalPseudo(tk, iter, MATCH_OPENBRACE, err);
        }

        if (func == null)
        {
          err.error(new CssGrammarException(
              CssErrorCode.GRAMMAR_UNEXPECTED_TOKEN, iter.last.location, iter.last.chars,
              next.getChars()));
          return null;
        }
        cps.function = (CssFunction) func;
View Full Code Here

          {
            cas.components.add(val);
          }
          else
          {
            err.error(new CssGrammarException(
                CssErrorCode.GRAMMAR_EXPECTING_TOKEN, next.location, next.chars,
                Messages.get("a_string_or_dentifier")));
            return null;
          }
          iter.next(); // ']'
        }
        else
        {
          err.error(new CssGrammarException(
              CssErrorCode.GRAMMAR_EXPECTING_TOKEN, next.location, next.chars,
              Messages.get("an_attribute_value_matcher")));
          return null;
        }
      }
View Full Code Here

        CssException
    {

      if (start.type != CssToken.Type.IDENT && !MATCH_STAR_PIPE.apply(start))
      {
        err.error(new CssGrammarException(
            CssErrorCode.GRAMMAR_EXPECTING_TOKEN, start.location,
            start.getChars(), Messages.get("a_type_or_universal_selector")));
        return null;
      }

      StringBuilder sb = new StringBuilder();
      sb.append(start.getChars());

      if (MATCH_PIPE.apply(start))
      {
        //|E
        CssToken next = iter.peek(FILTER_NONE);
        if (next.type != CssToken.Type.IDENT)
        {
          err.error(new CssGrammarException(
              CssErrorCode.GRAMMAR_EXPECTING_TOKEN, next.location,
              next.getChars(), Messages.get("a_type_or_universal_selector")));
          return null;
        }
        else
        {
          sb.append(iter.next().getChars());
        }
      }
      else if (MATCH_PIPE.apply(iter.peek(FILTER_NONE)))
      {
        //ns|E, *|E,
        sb.append(iter.next().getChars());
        CssToken next = iter.next(FILTER_NONE);
        if (next.type != CssToken.Type.IDENT && !MATCH_STAR.apply(next))
        {
          err.error(new CssGrammarException(
              CssErrorCode.GRAMMAR_EXPECTING_TOKEN, start.location,
              next.getChars(), Messages.get("a_type_or_universal_selector")));
          return null;
        }
        else
View Full Code Here

      doc.endSelectors(selectors);

    }
    catch (NoSuchElementException nse)
    {
      err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF,
          iter.last.location, "'" + errChar + "'"));
      throw new PrematureEOFException();
    }

    if (debug)
View Full Code Here

          }
        }
      }
      catch (NoSuchElementException nse)
      {
        err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location, "';' "
            + Messages.get("or") + " '}'"));
        throw new PrematureEOFException();
      }
    }
  }
View Full Code Here

      CssException
  {

    if (name.type != CssToken.Type.IDENT)
    {
      err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, name.location, name
          .getChars(), Messages.get("a_property_name")));
      return null;
    }

    CssDeclaration declaration = new CssDeclaration(name.getChars(), name.location);

    try
    {
      if (!MATCH_COLON.apply(iter.next()))
      {
        err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN, name.location, iter.last
            .getChars(), ":"));
        return null;
      }
    }
    catch (NoSuchElementException nse)
    {
      err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location, ":"));
      throw new PrematureEOFException();
    }

    try
    {
      while (true)
      {
        CssToken value = iter.next();
        if (MATCH_SEMI_CLOSEBRACE.apply(value))
        {
          if (declaration.components.size() < 1)
          {
            err.error(new CssGrammarException(GRAMMAR_EXPECTING_TOKEN,
                iter.last.location, value.getChar(), Messages
                .get("a_property_value")));
            return null;
          }
          else
          {
            return declaration;
          }
        }
        else
        {
          if (!handlePropertyValue(declaration, value, iter, isStyleAttribute))
          {
            err.error(new CssGrammarException(GRAMMAR_UNEXPECTED_TOKEN,
                iter.last.location, iter.last.getChars()));
            return null;
          }
          else
          {
            if (isStyleAttribute && !iter.hasNext())
            {
              return declaration;
            }
          }
        }
      }
    }
    catch (NoSuchElementException nse)
    {
      err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location, "';' "
          + Messages.get("or") + " '}'"));
      throw new PrematureEOFException();
    }

  }
View Full Code Here

        {
          selector.components.add(new CssSelectorCombinator(' ', start.location));
        }
        else
        {
          err.error(new CssGrammarException(GRAMMAR_UNEXPECTED_TOKEN,
              iter.last.location, iter.last.chars));
          return null;
        }
      } //combinator loop
      selectors.add(selector);
View Full Code Here

        {
          CssConstruct param = handleAtRuleParam(tk, iter, doc, err);
          if (param == null)
          {
            // issue error, forward, then return
            err.error(new CssGrammarException(GRAMMAR_UNEXPECTED_TOKEN,
                iter.last.location, iter.last.chars));
            //skip to atrule closebrace, ignoring any inner blocks
            int stack = 0;
            while (true)
            {
              CssToken tok = iter.next();
              if (MATCH_SEMI.apply(tok) && stack == 0)
              {
                return; //a non-block at rule
              }
              else if (MATCH_OPENBRACE.apply(tok))
              {
                stack++;
              }
              else if (MATCH_CLOSEBRACE.apply(tok))
              {
                if (stack == 1)
                {
                  break;
                }
                stack--;
              }
            }
            return;
          }
          else
          {
            atRule.components.add(param);
          }
        }
      }
    }
    catch (NoSuchElementException nse)
    {
      // UAs required to close any open constructs on premature EOF
      doc.startAtRule(atRule);
      err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location, "';' "
          + Messages.get("or") + " '{'"));
      doc.endAtRule(atRule.getName().get());
      throw new PrematureEOFException();
    }

    if (debug)
    {
      checkArgument(MATCH_SEMI_OPENBRACE.apply(iter.last));
      checkArgument(iter.filter() == FILTER_S_CMNT);
    }

    // ending up here only on expected end
    doc.startAtRule(atRule);
    if (atRule.hasBlock)
    {
      try
      {
        if (hasRuleSet(atRule, iter))
        {
          while (!MATCH_CLOSEBRACE.apply(iter.next()))
          {
            if (iter.last.type == CssToken.Type.ATKEYWORD)
            {
              handleAtRule(iter.last, iter, doc, err);
            }
            else
            {
              handleRuleSet(iter.last, iter, doc, err);
            }
          }
        }
        else
        {
          handleDeclarationBlock(iter.next(), iter, doc, err);
        }
      }
      catch (NoSuchElementException nse)
      {
        err.error(new CssGrammarException(GRAMMAR_PREMATURE_EOF, iter.last.location, "'}'"));
        doc.endAtRule(atRule.name.get());
        throw new PrematureEOFException();
      }
    }
    doc.endAtRule(atRule.name.get());
View Full Code Here

TOP

Related Classes of org.idpf.epubcheck.util.css.CssExceptions.CssGrammarException

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.