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

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

http://github.com/nddrylliog/ooc
Java | 33 lines | 26 code | 7 blank | 0 comment | 4 complexity | 32fccd55d5511cf23b6c0917c1a71352 MD5 | raw file
 1package org.ooc.frontend.parser;
 2
 3import org.ooc.frontend.model.Module;
 4import org.ooc.frontend.model.Type;
 5import org.ooc.frontend.model.TypeAccess;
 6import org.ooc.frontend.model.VariableAccess;
 7import org.ooc.frontend.model.tokens.Token;
 8import org.ooc.frontend.model.tokens.TokenReader;
 9import org.ubi.SourceReader;
10
11public class AccessParser {
12
13	public static VariableAccess parse(Module module, SourceReader sReader, TokenReader reader) {
14		int mark = reader.mark();
15		
16		Token token = reader.peek();
17		if(token.isNameToken()) {
18			Type type = TypeParser.parse(module, sReader, reader);
19			if(type != null && type.getTypeParams().size() > 0) {
20				return new TypeAccess(type, token);
21			}
22			
23			reader.reset(mark);
24			reader.skip();
25			String name = token.get(sReader);
26			return new VariableAccess(name, token);
27		}
28		
29		reader.reset(mark);
30		return null;
31	}
32	
33}