Ejemplo n.º 1
0
        public PftFormatter ParseInput
        (
            string input
        )
        {
            AntlrInputStream  stream = new AntlrInputStream(input);
            PftLexer          lexer  = new PftLexer(stream);
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            PftParser         parser = new PftParser(tokens);

            PftParser.ProgramContext programContext = parser.program();
            Program = new PftProgram(programContext);

            if (!Program.Validate(false))
            {
                throw new ArgumentException();
            }

            return(this);
        }
Ejemplo n.º 2
0
        private void Parse()
        {
            string       recordText = _recordBox.Text;
            StringReader reader     = new StringReader(recordText);

            _record = PlainText.ReadRecord(reader);
            if (!ReferenceEquals(_record, null))
            {
                _record.Mfn = 1; // TODO some other value?
            }
            _recordGrid.SetRecord(_record);

            PftLexer lexer = new PftLexer();

            _tokenList = lexer.Tokenize(_pftBox.Text);

            _tokenGrid.SetTokens(_tokenList);

            PftParser parser = new PftParser(_tokenList);

            _program = parser.Parse();
            _pftTreeView.SetNodes(_program);
        }