1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Rook
.Compiler
.Services
.Default
20 using Castle
.Rook
.Compiler
.Parser
;
21 using Castle
.Rook
.Compiler
.AST
;
24 public class RookParser
: IParser
26 public IErrorReport errorReport
;
28 public RookParser(IErrorReport errorReport
)
30 this.errorReport
= errorReport
;
33 #region IParser Members
35 public SourceUnit
Parse(CompilationUnit unit
, TextReader reader
)
37 RookLexer lexer
= new RookLexer(reader
);
39 RookBaseParser parser
= new RookBaseParser(lexer
);
40 parser
.ErrorReport
= errorReport
;
42 return parser
.sourceUnit(unit
);
45 public SourceUnit
Parse(CompilationUnit unit
, String contents
)
47 return Parse(unit
, new StringReader(contents
+ "\r\n"));
51 /// Handy for the test cases
53 public SourceUnit
Parse(String contents
)
55 CompilationUnit unit
= new CompilationUnit();
57 return Parse(unit
, new StringReader(contents
));