Example #1
0
 public void Write(ast.Program ast, TranspilerStream stream)
 {
     if (ast.Body == null)
     {
         throw new InvalidOperationException("AST is invalid");
     }
     ast.Emit(stream);
 }
Example #2
0
        public ast.Program Parse(IEnumerator <Token> tokens)
        {
            this.tokens = tokens;

            var t = Next();

            if (t.Id != TokenId.Begin)
            {
                throw new InvalidOperationException();
            }

            var body = ParseBlock(Next(), oneStatement: false);
            var ast  = new ast.Program(body);

            t = Next();
            if (t.Id != TokenId.Eof)
            {
                throw new ParseError(t, "Expected end of file");
            }

            return(ast);
        }