コード例 #1
0
        //--- Class Methods ---
        public static DekiScriptExpression Parse(Location location, Stream source) {
            if(source == null) {
                throw new ArgumentNullException("source");
            }

            // parse source
            try {
                var scanner = new Scanner(source, location.Origin, location.Line, location.Column);
                var parser = new Parser(scanner);
                parser.Parse();
                return parser.result;
            } catch(FatalError e) {
                throw new DekiScriptParserException(e.Message, Location.None);
            } finally {
                source.Dispose();
            }
        }
コード例 #2
0
        public static DekiScriptExpression Parse(Location location, string source) {
            if(source == null) {
                throw new ArgumentNullException("source");
            }

            // convert unbreakable spaces to regular spaces and trim buffer
            source = source.ReplaceAll("\u00A0", " ", "\u00AD", "").Trim();

            // parse source
            try {
                using(MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(source))) {
                    Scanner scanner = new Scanner(stream, location.Origin, location.Line, location.Column);
                    Parser parser = new Parser(scanner);
                    parser.Parse();
                    return parser.result;
                }
            } catch(FatalError e) {
                throw new DekiScriptParserException(e.Message, Location.None);
            }
        }