Exemplo n.º 1
0
    /// <summary>
    /// Parse a number. Intended to be used at runtime for string-to-number conversions.
    /// </summary>
    public static void ParseNumber(string number, ref mdr.DValue dValue)
    {
      var parser = new JavaScriptParser.SequentialParser(number);
      var numericLiteral = parser.ParseNumber();

      // Convert to a DValue and return via the ref parameter.
      Debug.Assert(numericLiteral is IR.PrimitiveLiteral, "ParseNumber() should yield a PrimitiveLiteral.");
      (numericLiteral as IR.PrimitiveLiteral).SetAsDValue(ref dValue);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Parse a script, converting it to a Program.
    /// </summary>
    public static IR.Program ParseScript(string script)
    {
      #if DEBUG
        CheckEncoding(script);
      #endif

      var parser = new JavaScriptParser.SequentialParser(script);
      return (IR.Program) parser.ParseScript();
    }
Exemplo n.º 3
0
        /// <summary>
        /// Parse a number. Intended to be used at runtime for string-to-number conversions.
        /// </summary>
        public static void ParseNumber(string number, ref mdr.DValue dValue)
        {
            var parser         = new JavaScriptParser.SequentialParser(number);
            var numericLiteral = parser.ParseNumber();

            // Convert to a DValue and return via the ref parameter.
            Debug.Assert(numericLiteral is IR.PrimitiveLiteral, "ParseNumber() should yield a PrimitiveLiteral.");
            (numericLiteral as IR.PrimitiveLiteral).SetAsDValue(ref dValue);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Parse a script, converting it to a Program.
        /// </summary>
        public static IR.Program ParseScript(string script)
        {
      #if DEBUG
            CheckEncoding(script);
      #endif

            var parser = new JavaScriptParser.SequentialParser(script);
            return((IR.Program)parser.ParseScript());
        }
Exemplo n.º 5
0
    /// <summary>
    /// Parse a regular expression. Intended to be used at runtime for the RegExp constructor.
    /// </summary>
    /// <exception cref="SyntaxException">Thrown when the regular expression is malformed.</exception>
    public static string ParseRegularExpression(string regex)
    {
      var parser = new JavaScriptParser.SequentialParser(regex);

      return parser.ParseRegularExpression();
    }
Exemplo n.º 6
0
        /// <summary>
        /// Parse a regular expression. Intended to be used at runtime for the RegExp constructor.
        /// </summary>
        /// <exception cref="SyntaxException">Thrown when the regular expression is malformed.</exception>
        public static string ParseRegularExpression(string regex)
        {
            var parser = new JavaScriptParser.SequentialParser(regex);

            return(parser.ParseRegularExpression());
        }