Ejemplo n.º 1
0
		public static IList<JsStatement> ParseProgram(string source) {
			var lex = new ES3Lexer(new ANTLRStringStream(source));
   			var tokens = new CommonTokenStream(lex);
			var parser = new ES3Parser(tokens);

			var r = parser.program();
			var tree = new ES3Walker(new CommonTreeNodeStream(r.Tree));
			return tree.program();
		}
Ejemplo n.º 2
0
		public static JsStatement ParseStatement(string source, bool allowCustomKeywords = false) {
			var lex = new ES3Lexer(new ANTLRStringStream(source.Trim())) { AllowCustomKeywords = allowCustomKeywords };
			var tokens = new CommonTokenStream(lex);
			var parser = new ES3Parser(tokens);

			var r = parser.sourceElement();
			var tree = new ES3Walker(new CommonTreeNodeStream(r.Tree));
			return tree.statement();
		}
Ejemplo n.º 3
0
		public static JsExpression ParseExpression(string source, bool allowCustomKeywords = false) {
			var lex = new ES3Lexer(new ANTLRStringStream(source)) { AllowCustomKeywords = allowCustomKeywords };
			var tokens = new CommonTokenStream(lex);
			var parser = new ES3Parser(tokens);

			var r = parser.expressionOnly();
			var tree = new ES3Walker(new CommonTreeNodeStream(r.Tree));
			return tree.expression();
		}
Ejemplo n.º 4
0
        public static JsStatement ParseStatement(string source)
        {
            var lex = new ES3Lexer(new ANTLRStringStream(source.Trim()));
               			CommonTokenStream tokens = new CommonTokenStream(lex);
            var parser = new ES3Parser(tokens);

            var r = parser.sourceElement();
            var tree = new ES3Walker(new CommonTreeNodeStream(r.Tree));
            return tree.statement();
        }
Ejemplo n.º 5
0
        public static JsExpression ParseExpression(string source)
        {
            var lex = new ES3Lexer(new ANTLRStringStream(source));
               			CommonTokenStream tokens = new CommonTokenStream(lex);
            var parser = new ES3Parser(tokens);

            var r = parser.expression();
            var tree = new ES3Walker(new CommonTreeNodeStream(r.Tree));
            return tree.expression();
        }
Ejemplo n.º 6
0
		void CreateTokenStream()
		{
			var stream = new ANTLRStringStream(code);
			var lexer = new ES3Lexer(stream);
			tokenStream = new CommonTokenStream(lexer);
		}