Skip to content

Commit

Permalink
Merge pull request #1311 from sebkur/allow_path_in_token_vocab
Browse files Browse the repository at this point in the history
Allow paths as tokenVocab option
  • Loading branch information
parrt authored Nov 19, 2016
2 parents 144baa9 + 961f087 commit 10ce5d2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tool/src/org/antlr/v4/Tool.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,19 @@ public List<GrammarRootAST> sortGrammarByTokenVocab(List<String> fileNames) {
// Make grammars depend on any tokenVocab options
if ( tokenVocabNode!=null ) {
String vocabName = tokenVocabNode.getText();
// Strip quote characters if any
int len = vocabName.length();
int firstChar = vocabName.charAt(0);
int lastChar = vocabName.charAt(len - 1);
if (len >= 2 && firstChar == '\'' && lastChar == '\'') {
vocabName = vocabName.substring(1, len-1);
}
// If the name contains a path delimited by forward slashes,
// use only the part after the last slash as the name
int lastSlash = vocabName.lastIndexOf('/');
if (lastSlash >= 0) {
vocabName = vocabName.substring(lastSlash + 1);
}
g.addEdge(grammarName, vocabName);
}
// add cycle to graph so we always process a grammar if no error
Expand Down

0 comments on commit 10ce5d2

Please sign in to comment.