コード例 #1
0
ファイル: Bug688021Test.cs プロジェクト: hazzik/Rhino.Net
		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);
		}
コード例 #2
0
        /// <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;
        }
コード例 #3
0
ファイル: Bug708801Test.cs プロジェクト: hazzik/Rhino.Net
			/// <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;
			}
コード例 #4
0
 public static ByteBuffer Encode(this Encoding e, CharSequence str)
 {
     return(ByteBuffer.Wrap(e.GetBytes(str.ToString())));
 }
コード例 #5
0
ファイル: Matcher.cs プロジェクト: yangfan111/CsharpCode
 public Matcher Reset(CharSequence str)
 {
     return(Reset(str.ToString()));
 }
コード例 #6
0
			/// <exception cref="System.IO.IOException"></exception>
			protected internal override void WriteOne(CharSequence line)
			{
				pckOut.WriteString(line.ToString());
			}
コード例 #7
0
ファイル: ScriptRuntime.cs プロジェクト: hazzik/Rhino.Net
		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;
								}
							}
						}
					}
				}
			}
		}
コード例 #8
0
 public Matcher Reset (CharSequence str)
 {
     return Reset (str.ToString ());
 }
コード例 #9
0
 public ByteBuffer Encode(CharSequence str)
 {
     return(Encode(str.ToString()));
 }
コード例 #10
0
		public ByteBuffer Encode (CharSequence str)
		{
			return Encode (str.ToString ());
		}
コード例 #11
0
		/// <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("[ ]+");
		}
コード例 #12
0
 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;
 }
コード例 #13
0
ファイル: Bug687669Test.cs プロジェクト: hazzik/Rhino.Net
		private object Eval(CharSequence cs)
		{
			return cx.EvaluateString(scope, cs.ToString(), "<eval>", 1, null);
		}