Пример #1
0
 /**
  * Creates a new parser.
  *
  * @param tokenizer      the tokenizer to use
  * @param analyzer       the analyzer callback to use
  */
 public RecursiveDescentParser(Tokenizer tokenizer,
                               Analyzer analyzer)
     : base(tokenizer, analyzer) {
 }
Пример #2
0
 /**
  * Creates a new parser.
  *
  * @param input          the input stream to read from
  * @param analyzer       the analyzer callback to use
  *
  * @throws ParserCreationException if the tokenizer couldn't be
  *             initialized correctly
  *
  * @since 1.5
  */
 public RecursiveDescentParser(TextReader input, Analyzer analyzer)
     : base(input, analyzer) {
 }
Пример #3
0
 /**
  * Creates a new parser.
  *
  * @param input          the input stream to read from
  * @param analyzer       the analyzer callback to use
  *
  * @throws ParserCreationException if the tokenizer couldn't be
  *             initialized correctly
  *
  * @since 1.5
  */
 internal Parser(TextReader input, Analyzer analyzer) {
     this.tokenizer = NewTokenizer(input);
     this.analyzer = (analyzer == null) ? NewAnalyzer() : analyzer;
 }
Пример #4
0
 /**
  * Creates a new parser.
  *
  * @param tokenizer       the tokenizer to use
  * @param analyzer        the analyzer callback to use
  */
 internal Parser(Tokenizer tokenizer, Analyzer analyzer) {
     this.tokenizer = tokenizer;
     this.analyzer = (analyzer == null) ? NewAnalyzer() : analyzer;
 }
Пример #5
0
        /// <summary>
        /// Parses the code from the Code property and files syntax errors if any.
        /// </summary>
        protected void Parse()
        {
            // The parser expects each instruction to end with '\n'.
            if (!Code.EndsWith("\n")) Code += "\n";

            Analyzer a = new Analyzer(this);
            Parser p = new PicoParser(new StringReader(Code), a);
            try
            {
                Node n = p.Parse();
            }
            catch (ParserLogException ex)
            {
                for (int i = 0; i < ex.Count; i++)
                {
                    ParseException e = ex[i];
                    Error err = new Error();
                    err.ID = 0;
                    err.Description = string.Format(Messages.E0000, e.ErrorMessage);
                    err.Line = e.Line;
                    err.Column = e.Column;
                    Errors.Add(err);
                }
            }
        }