private void chewIndents() { // Chew up end-of-lines. while (match(Token.Kind.INDENT) != null) ; } }
private void indent() { if (match(Token.Kind.INDENT, Token.Kind.INDENT) != null) { // ERROR! } }
private void chewEols() { // Chew up end-of-lines. while (match(Token.Kind.EOL) != null) ; }
/** * classifier := LPAREN IDENT RPAREN */ private String classifier() { if (match(Token.Kind.LPAREN) == null) { return null; } List<Token> classifier = match(Token.Kind.IDENT); if (classifier == null) { log.severe("Expected identifier after '(' in classifier clause"); return null; } if (match(Token.Kind.RPAREN) == null) { log.severe("Expected ')' in classifier clause before end of line"); return null; } return classifier.get(0).value; }
private String relativePath() { StringBuilder fragment = new StringBuilder(); if (match(Token.Kind.DOT) != null) { fragment.append("."); } if (match(Token.Kind.DOT) != null) { fragment.append("."); } List<Token> idFragment; while ((idFragment = match(Token.Kind.IDENT)) != null) { fragment.append(idFragment.get(0).value); if (match(Token.Kind.DOT) != null) { fragment.append('.'); } } return fragment.toString(); }
private Property property() { String key = idFragment(); if (key == null) { return null; } // Now expect a colon. if (match(Token.Kind.COLON) == null) { return null; } List<Token> value = match(Kind.STRING); if (value == null) { return null; } String actual = stripQuotes(value.get(0).value); return new Property(key, actual); }
)) != null) { fragment.append(idFragment.value); if (match(Token.Kind.DOT) != null) { fragment.append('.'); if (match(Token.Kind.DASH) != null) { fragment.append('-'); List<Token> startOfExpr = match(Kind.LBRACE); if (startOfExpr == null) return null; parseException("Expected a property expression after ${"); if (match(Kind.RBRACE) == null) parseException("Expected '}' after property expression");
private Id id(boolean allowNullVersion) { String groupId = idFragment(); if (groupId == null) { return null; } // Now expect a colon. if (match(Token.Kind.COLON) == null) { return null; } String artifactId = idFragment(); if (artifactId == null) { return null; } // Now expect a colon. String version; if (match(Token.Kind.COLON) == null && !allowNullVersion) { return null; } else { version = idFragment(); if (version == null && !allowNullVersion) { return null; } } return new Id(groupId, artifactId, StringUtils.isEmpty(version) ? null : version); }
if (match(Token.Kind.SRCS, Token.Kind.COLON, Token.Kind.LBRACKET) == null) { return null; // No dirs! List<Token> aMatch = match(Token.Kind.IDENT); if (aMatch == null) { parseException("Expected 'src' or 'test'"); if (null == match(Token.Kind.COLON)) { parseException("Expected : after src"); List<Token> srcDirToken = match(Token.Kind.STRING); if (null == srcDirToken) { parseException("Expected string after src:"); aMatch = match(Token.Kind.IDENT); if (null == match(Token.Kind.COLON)) { parseException("Expected : after test"); List<Token> testDirToken = match(Token.Kind.STRING); if (null == testDirToken) { parseException("Expected string after test:"); dirs.put("test", stripQuotes(testDir)); if (match(Token.Kind.RBRACKET) == null) { parseException("Expected ] after srcs list");
private ScmElement scm() { chewIndents(); if (match(Token.Kind.SCM, Token.Kind.COLON, Token.Kind.LBRACKET) == null) { return null; // no scm element while ((ident = match(Token.Kind.IDENT)) != null) { String label = ident.get(0).value; if (match(Token.Kind.COLON) == null) { parseException("Expected : after label"); List<Token> valueToken = match(Token.Kind.STRING); if (null == valueToken) { parseException("Expected String after :"); if (match(Token.Kind.RBRACKET) == null) { parseException("Expected ] after srcs list");
if (match(Token.Kind.REPOSITORIES, Token.Kind.LEFT_WAVE) == null) { return null; List<Token> repositories = match(Token.Kind.STRING); if (repositories == null) { repoUrls.add(validateUrl(url)); while ((repositories = match(Token.Kind.COMMA)) != null) { chewEols(); chewIndents(); repositories = match(Token.Kind.STRING); chewEols(); chewIndents();
while ((propKey = match(Kind.IDENT, Kind.COLON)) != null) { List<Token> tokens = match(Kind.STRING); if (tokens != null) atom = tokens.get(0).value; match(Kind.EOL); } else { chewEols(); chewIndents(); if (match(Kind.RBRACKET) == null && match(Kind.RBRACE) == null) parseException("Expected ']' after configuration properties");
private List<String> modules() { indent(); if (match(Token.Kind.MODULES, Token.Kind.COLON, Token.Kind.LBRACKET) == null) { return null; // no properties. } List<String> modules = new ArrayList<String>(); chewEols(); chewIndents(); String module; while ((module = idFragment()) != null) { chewEols(); chewIndents(); modules.add(module); } if (match(Token.Kind.RBRACKET) == null) { // ERROR! parseException("Expected ]"); } return modules; }
private List<Property> properties(Token.Kind kind) { indent(); if (match(kind, Token.Kind.COLON, Token.Kind.LBRACKET) == null) { return null; // no properties. } List<Property> properties = new ArrayList<Property>(); chewEols(); chewIndents(); Property p; while ((p = property()) != null) { chewEols(); chewIndents(); properties.add(p); } if (match(Token.Kind.RBRACKET) == null) { // ERROR! parseException("Expected ]"); } return properties; }
private Parent parent() { if (match(Kind.PARENT) == null) return null; if (match(Kind.COLON) == null) { log.severe("Expected ':' after 'inherits'"); return null; } Id parentId = id(true); if (parentId == null) { log.severe("Expected complete artifact identifier in 'parent' clause"); return null; } String relativePath = "../pom.atom"; if (match(Token.Kind.COLON) != null) { relativePath = relativePath(); if (relativePath == null) { return null; } } Parent parent = new Parent(); parent.setGroupId(parentId.getGroup()); parent.setArtifactId(parentId.getArtifact()); parent.setVersion(parentId.getVersion()); parent.setRelativePath(relativePath); return parent; }
private Plugin plugin(Kind keyword) { if (match(keyword) == null) return null; if (match(Kind.EOL) == null) { parseException("Expected newline after 'plugin' keyword"); if (match(Kind.ID, Kind.COLON) == null) { log.severe("Plugin declaration is missing an 'id' tag"); return null; if (match(Kind.EOL) == null) { log.severe("Expected newline after plugin id declaration"); return null;
/** * Dependencies of a project. The real meat of it. */ private List<Id> dependencies(Token.Kind kind, boolean allowNullVersion) { indent(); if (match(kind, Token.Kind.COLON, Token.Kind.LBRACKET) == null) { return null; // no deps. } List<Id> deps = new ArrayList<Id>(); chewEols(); chewIndents(); // Slurp up the dep ids. Id id; while ((id = id(allowNullVersion)) != null) { // Optional additional params at the end. String classifier = classifier(); if (null != classifier) { id.setClassifier(classifier); } chewEols(); chewIndents(); deps.add(id); } if (match(Token.Kind.RBRACKET) == null) { // ERROR! parseException("Expected ]"); } return deps; }
if (match(Token.Kind.PROJECT) == null) { return null; List<Token> signature = match(Token.Kind.STRING); if (null == signature) { log.severe("Expected string describing project after 'project'."); String projectUrl = null; signature = match(Token.Kind.AT, Token.Kind.STRING); if (null != signature) { projectUrl = signature.get(1).value; List<Token> packagingTokens = match(Kind.PACKAGING, Kind.IDENT); String packaging = null; if (null != packagingTokens) { if (match(Token.Kind.EOL) == null) { log.severe("Expected end of line after project declaration"); return null; if (match(Token.Kind.ID) == null) { log.severe("Expected 'id' after project declaration"); return null; if (match(Token.Kind.COLON) == null) { log.severe("Expected ':' after 'id'"); return null;
private void chewIndents() { // Chew up end-of-lines. while (match(Token.Kind.INDENT) != null) ; } }
private void chewEols() { // Chew up end-of-lines. while (match(Token.Kind.EOL) != null) ; }