All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thaiopensource.xml.dtd.parse.AtomParser Maven / Gradle / Ivy

There is a newer version: 20220510
Show newest version
package com.thaiopensource.xml.dtd.parse;

import java.util.Vector;

import com.thaiopensource.xml.tok.Tokenizer;

class AtomParser {
  private final DtdBuilder db;
  private final AtomStream as;
  private final PrologParser pp;
  private final Vector v;
  private Particle group;

  AtomParser(DtdBuilder db, AtomStream as, PrologParser pp, Vector v) {
    this.db = db;
    this.as = as;
    this.pp = pp;
    this.v = v;
  }

  AtomParser(DtdBuilder db, AtomStream as, PrologParser pp, Particle group) {
    this.db = db;
    this.as = as;
    this.pp = pp;
    this.v = group.particles;
    this.group = group;
  }

  void parse() {
    try {
      parseDecls();
      pp.end();
    }
    catch (PrologSyntaxException e) {
      throw new Error("syntax error on reparse at end of file");
    }
  }

  private void parseDecls() throws PrologSyntaxException {
    while (as.advance()) {
      Decl d = null;
      if (as.entity != null) {
	d = new Decl(Decl.REFERENCE);
	d.entity = as.entity;
	v.addElement(d);
	int start = v.size();
	new AtomParser(db, new AtomStream(as.entity.atoms), pp, v).parseDecls();
	d.entity.setParsed(Entity.DECL_LEVEL, v, start, v.size());
	d = new Decl(Decl.REFERENCE_END);
      }
      else {
	doAction();
	switch (as.tokenType) {
	case Tokenizer.TOK_COMMENT:
	  d = new Decl(Decl.COMMENT);
	  d.value = as.token.substring(4, as.token.length() - 3);
	  break;
	case Tokenizer.TOK_PI:
	  d = new Decl(Decl.PROCESSING_INSTRUCTION);
	  d.value = as.token.substring(2, as.token.length() - 2);
	  break;
	case Tokenizer.TOK_PROLOG_S:
	case Tokenizer.TOK_XML_DECL:
	  break;
	case Tokenizer.TOK_DECL_OPEN:
	  {
	    int type;
	    if (as.token.equals("




© 2015 - 2024 Weber Informatics LLC | Privacy Policy