PageRenderTime 22ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/org/ooc/frontend/parser/DeclarationParser.java

http://github.com/nddrylliog/ooc
Java | 37 lines | 27 code | 10 blank | 0 comment | 10 complexity | f18a970ec40f20c7bfee2157f493b0ac MD5 | raw file
 1package org.ooc.frontend.parser;
 2
 3import org.ooc.frontend.model.ClassDecl;
 4import org.ooc.frontend.model.CoverDecl;
 5import org.ooc.frontend.model.Declaration;
 6import org.ooc.frontend.model.FunctionDecl;
 7import org.ooc.frontend.model.Module;
 8import org.ooc.frontend.model.OpDecl;
 9import org.ooc.frontend.model.VariableDecl;
10import org.ooc.frontend.model.tokens.TokenReader;
11import org.ubi.SourceReader;
12
13public class DeclarationParser {
14
15	public static Declaration parse(Module module, SourceReader sReader, TokenReader reader) {
16		int mark = reader.mark();
17		
18		VariableDecl varDecl = VariableDeclParser.parseSingle(module, sReader, reader);
19		if(varDecl != null) return varDecl;
20		
21		OpDecl opDecl = OpDeclParser.parse(module, sReader, reader);
22		if(opDecl != null) return opDecl;
23		
24		FunctionDecl funcDecl = FunctionDeclParser.parse(module, sReader, reader, false);
25		if(funcDecl != null) return funcDecl;
26		
27		ClassDecl classDecl = ClassDeclParser.parse(module, sReader, reader);
28		if(classDecl != null) return classDecl;
29		
30		CoverDecl coverDecl = CoverDeclParser.parse(module, sReader, reader);
31		if(coverDecl != null) return coverDecl;
32		
33		reader.reset(mark);
34		return null;
35	}
36	
37}