PageRenderTime 293ms CodeModel.GetById 140ms app.highlight 3ms RepoModel.GetById 148ms app.codeStats 0ms

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

http://github.com/nddrylliog/ooc
Java | 32 lines | 26 code | 6 blank | 0 comment | 7 complexity | d813bd9dd579a75bfcf422703380bb14 MD5 | raw file
 1package org.ooc.frontend.parser;
 2
 3import org.ooc.frontend.model.tokens.Token;
 4import org.ooc.frontend.model.tokens.TokenReader;
 5import org.ooc.frontend.model.tokens.Token.TokenType;
 6import org.ubi.CompilationFailedError;
 7import org.ubi.SourceReader;
 8
 9public class UnmangledParser {
10
11	public static String parse(SourceReader sReader, TokenReader reader) throws CompilationFailedError {
12		
13		String unmangledName = null;
14		
15		if(reader.peek().type == TokenType.UNMANGLED_KW) {
16			reader.skip();
17			if(reader.peek().type == TokenType.OPEN_PAREN) {
18				reader.skip();
19				Token nameToken = reader.read();
20				unmangledName = nameToken.get(sReader);
21				if(reader.read().type != TokenType.CLOS_PAREN) {
22					throw new CompilationFailedError(null,
23							"Expected closing parenthesis after unmangled specification, but got "+reader.peek());
24				}
25			} else {
26				unmangledName = "";
27			}
28		}
29		return unmangledName;
30	}
31	
32}