package org.metaborg.meta.lang.template.strategies;

import org.spoofax.interpreter.core.Tools;
import org.spoofax.interpreter.terms.IStrategoTerm;
import org.spoofax.interpreter.terms.ITermFactory;
import org.strategoxt.lang.Context;
import org.strategoxt.lang.Strategy;

public class unquote_0_0 extends Strategy {
    public static String unquote(String s) {
        return (s != null && ((s.startsWith("\"") && s.endsWith("\"")) || (s.startsWith("'") && s.endsWith("'")))) ? s =
            s.substring(1, s.length() - 1) : s;
    }

    public static unquote_0_0 instance = new unquote_0_0();

    @Override public IStrategoTerm invoke(Context context, IStrategoTerm current) {
        final String str = Tools.asJavaString(current);
        final ITermFactory factory = context.getFactory();
        IStrategoTerm after = factory.makeString(unquote(str));
        after = factory.annotateTerm(after, current.getAnnotations());
        after = factory.copyAttachments(current, after);
        return after;
    }
}

@@ -370,17 +370,16 @@
  return 
-(
 s != nul
@@ -383,17 +383,47 @@
 null && 
-(
+s.length() %3E= 2%0A            && 
 (s.start
@@ -457,14 +457,12 @@
 %5C%22%22)
-)
  %7C%7C 
-(
 s.st
@@ -498,16 +498,8 @@
 '%22))
-)) ? s =
 %0A   
@@ -506,16 +506,22 @@
         
+     ?
  s.subst

Fix `unquote` strategy for strings containing just a single quote