Package org.eclipse.imp.pdb.facts

Examples of org.eclipse.imp.pdb.facts.IString


  private Content nodeToContent(IConstructor n) {
    if (n.getConstructorType() == Factory.Node_element) {
      return nodeToElement(n);
    }
    if (n.getConstructorType() == Factory.Node_pi) {
      IString target = (IString) n.get(0);
      IString data = (IString) n.get(1);
      return new ProcessingInstruction(target.getValue(), data.getValue());
     
    }
    if (n.getConstructorType() == Factory.Node_charRef) {
      IInteger code = (IInteger) n.get(0);
      int c = java.lang.Integer.parseInt(code.getStringRepresentation());
View Full Code Here


    return null;
  }

  private Attribute nodeToAttribute(IConstructor n) {
    IConstructor ns = (IConstructor) n.get(0);
    IString name = (IString) n.get(1);
    IString data = (IString) n.get(2);
    return new Attribute(name.getValue(), data.getValue(), namespaceToNamespace(ns));
  }
View Full Code Here

  private Namespace namespaceToNamespace(IConstructor ns) {
    if (ns.getConstructorType() == Factory.Namespace_none) {
      return Namespace.NO_NAMESPACE;
    }
    IString prefix = (IString) ns.get(0);
    IString uri = (IString) ns.get(1);
    return Namespace.getNamespace(prefix.getValue(), uri.getValue());
  }
View Full Code Here

  private IConstructor convertElement(Element e, boolean trim) {
    IListWriter kids = vf.listWriter(Factory.Node);
    for (Object o: e.getAttributes()) {
      Attribute attr = (Attribute)o;
      IString key = vf.string(attr.getName());
      IString val = vf.string(attr.getValue());

      kids.insert(vf.constructor(Factory.Node_attribute, convertNamespace(attr.getNamespace()), key, val));
    }

    int len = e.getContentSize();
    for (int i = 0; i < len; i++) {
      try {
        kids.append(convertContent(e.getContent(i), trim));
      }
      catch (Skip c) { // Ugh, terrible, but I'm in hurry
        continue;
      }
    }
   
    IString name = vf.string(e.getName());
    return vf.constructor(Factory.Node_element, convertNamespace(e.getNamespace()), name, kids.done());
  }
View Full Code Here

  private IConstructor convertNamespace(Namespace ns) {
    if (ns == Namespace.NO_NAMESPACE) {
      return vf.constructor(Factory.Namespace_none);
    }
    IString prefix = vf.string(ns.getPrefix());
    IString uri = vf.string(ns.getURI());
    IConstructor nscon = vf.constructor(Factory.Namespace_namespace, prefix, uri);
    return nscon;
  }
View Full Code Here

      Text text = (Text)content;
      return vf.constructor(Factory.Node_charData, getString(trim, text));
    }
    if (content instanceof Comment) {
      Comment comment = (Comment)content;
      IString data = vf.string(comment.getText());
      return vf.constructor(Factory.Node_comment, data);
    }
    if (content instanceof ProcessingInstruction) {
      ProcessingInstruction pi = (ProcessingInstruction)content;
      IString data = vf.string(pi.getData());
      return vf.constructor(Factory.Node_pi, data);
    }
    if (content instanceof EntityRef) {
      EntityRef er = (EntityRef)content;
      IString data = vf.string(er.getName());
      return vf.constructor(Factory.Node_entityRef, data);
    }
    throw new AssertionError("cannot convert JDOM content type " + content.getClass());
  }
View Full Code Here

//      if(matcher == null){
        matcher = pat.matcher(subject);
//        matcherCache.put(RegExpAsString, matcher);
//      } else
//        matcher.reset(subject);
      IString empty = ctx.getValueFactory().string("");
     
      // Initialize all pattern variables to ""
      for(String name : patternVars){
        if(!this.iWroteItMySelf
            && !ctx.getCurrentEnvt().declareVariable(tf.stringType(), name))
View Full Code Here

  }
 
  private void writeFile(ISourceLocation sloc, IList V, boolean append, RascalExecutionContext rex){
    sloc = rex.resolveSourceLocation(sloc);

    IString charset = values.string("UTF8");
    if (append) {
      // in case the file already has a encoding, we have to correctly append that.
      InputStream in = null;
      Charset detected = null;
      try {
View Full Code Here

    return super.slice(first, second, end, getValue().length());
  }
 
  public Result<IValue> makeSlice(int first, int second, int end){
    StringBuilder buffer = new StringBuilder();
    IString s = getValue();
    int increment = second - first;
    if(first == end || increment == 0){
      // nothing to be done
    } else
    if(first <= end){
      for(int i = first; i >= 0 && i < end; i += increment){
        buffer.appendCodePoint(s.charAt(i));
      }
    } else {
      for(int j = first; j >= 0 && j > end && j < getValue().length(); j += increment){
        buffer.appendCodePoint(s.charAt(j));
      }
    }
    return makeResult(TypeFactory.getInstance().stringType(), getValueFactory().string(buffer.toString()), ctx);
  }
View Full Code Here

      Nonterminal nonterminal = symbol.getNonterminal();
      return factory.constructor(Factory.Symbol_Start_Sort, factory.constructor(Factory.Symbol_Sort, factory.string(((Nonterminal.Lexical) nonterminal).getString())))
    }
    if (symbol.isNonterminal()) {
      Nonterminal nonterminal = symbol.getNonterminal();
      IString name = factory.string(((Nonterminal.Lexical) nonterminal).getString());
      if (lex) {
        return factory.constructor(Factory.Symbol_Lex, name);
      }
      else {
        return factory.constructor(Factory.Symbol_Sort, name);
View Full Code Here

TOP

Related Classes of org.eclipse.imp.pdb.facts.IString

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.