private AstRoot Parse(CharSequence cs) { CompilerEnvirons compilerEnv = new CompilerEnvirons(); compilerEnv.InitFromContext(cx); ErrorReporter compilationErrorReporter = compilerEnv.GetErrorReporter(); Parser p = new Parser(compilerEnv, compilationErrorReporter); return p.Parse(cs.ToString(), "<eval>", 1); }
/// <summary>Tokenizes the text and returns an array of tokens.</summary> /// <remarks>Tokenizes the text and returns an array of tokens.</remarks> /// <param name="text">The text</param> /// <returns>The tokens</returns> public static string[] Tokenize(CharSequence text) { string replaced = text.ToString().ReplaceAll(RE_U00A0, "'\u00A0'"); string match1 = PAT_WORD_BOUNDARY.Matcher(replaced).ReplaceAll("\u2063"); string match2 = PAT_NOT_WORD_BOUNDARY.Matcher(match1).ReplaceAll("$1"); string replaced2 = match2.ReplaceAll(RE_U2063, " "); string trimmed = replaced2.Trim(); //string[] parts = trimmed.Split("[ ]+"); string[] parts = RE_SPACE_SPLITTER.Split(trimmed); return parts; }
/// <summary> /// Compiles /// <code>source</code> /// and returns the transformed and optimized /// <see cref="Rhino.Ast.ScriptNode">Rhino.Ast.ScriptNode</see> /// </summary> protected internal virtual ScriptNode Compile(CharSequence source) { string mainMethodClassName = "Main"; string scriptClassName = "Main"; CompilerEnvirons compilerEnv = new CompilerEnvirons(); compilerEnv.InitFromContext(cx); ErrorReporter compilationErrorReporter = compilerEnv.GetErrorReporter(); Parser p = new Parser(compilerEnv, compilationErrorReporter); AstRoot ast = p.Parse(source.ToString(), "<eval>", 1); IRFactory irf = new IRFactory(compilerEnv); ScriptNode tree = irf.TransformTree(ast); Codegen codegen = new Codegen(); codegen.SetMainMethodClass(mainMethodClassName); codegen.CompileToClassFile(compilerEnv, scriptClassName, tree, tree.GetEncodedSource(), false); return tree; }
public static ByteBuffer Encode(this Encoding e, CharSequence str) { return(ByteBuffer.Wrap(e.GetBytes(str.ToString()))); }
public Matcher Reset(CharSequence str) { return(Reset(str.ToString())); }
/// <exception cref="System.IO.IOException"></exception> protected internal override void WriteOne(CharSequence line) { pckOut.WriteString(line.ToString()); }
private static bool EqString(CharSequence x, object y) { for (; ; ) { if (y == null || y == Undefined.instance) { return false; } else { if (y is CharSequence) { CharSequence c = (CharSequence)y; return x.Length == c.Length && x.ToString().Equals(c.ToString()); } else { if (y is Number) { return ToNumber(x.ToString()) == System.Convert.ToDouble(((Number)y)); } else { if (y is bool) { return ToNumber(x.ToString()) == (((bool)y) ? 1.0 : 0.0); } else { if (y is Scriptable) { if (y is ScriptableObject) { object test = ((ScriptableObject)y).EquivalentValues(x.ToString()); if (test != ScriptableConstants.NOT_FOUND) { return ((bool)test); } } y = ToPrimitive(y); continue; } else { WarnAboutNonJSObject(y); return false; } } } } } } }
public Matcher Reset (CharSequence str) { return Reset (str.ToString ()); }
public ByteBuffer Encode(CharSequence str) { return(Encode(str.ToString())); }
public ByteBuffer Encode (CharSequence str) { return Encode (str.ToString ()); }
/// <summary>Tokenizes the text and returns an array of tokens.</summary> /// <remarks>Tokenizes the text and returns an array of tokens.</remarks> /// <param name="text">The text</param> /// <returns>The tokens</returns> public static string[] Tokenize(CharSequence text) { return PAT_NOT_WORD_BOUNDARY.Matcher(PAT_WORD_BOUNDARY.Matcher(text.ToString().ReplaceAll ("\u00A0","'\u00A0'")).ReplaceAll("\u2063" )).ReplaceAll("$1").ReplaceAll("[ \u2063]+", " ").Trim().Split("[ ]+"); }
private bool IsClause(CharSequence text) { Matcher m = PAT_WHITESPACE.Matcher(text.ToString()); int n = 1; while (m.Find()) { n++; if (n >= minWords) { return true; } } return n >= minWords; }
private object Eval(CharSequence cs) { return cx.EvaluateString(scope, cs.ToString(), "<eval>", 1, null); }