Skip to content

Commit

Permalink
fixed #34 translate "!" in Xtext terminals to "~" in ANTLR
Browse files Browse the repository at this point in the history
  • Loading branch information
Amine Lajmi committed Dec 9, 2016
1 parent 659a974 commit 73ae102
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ class GenGrammar extends AbstractGenerator {
val Pattern p = Pattern::compile("\\{(.+?)\\}")
val Matcher m = p.matcher(text)
while (m.find()) {
val group = m.group
if (!(group.substring(1, 2) == '\''))
text = text.replace(group, "")
val group = m.group
if (!(group.substring(1, 2) == '\''))
text = text.replace(group, "")
}
//EOF
if (rules.get(0).equals(pr))
Expand Down Expand Up @@ -194,6 +194,13 @@ class GenGrammar extends AbstractGenerator {
if (!covered.contains(terminal.name)) {
var text = grammarDefinition.serializer.serialize(terminal, SaveOptions::defaultOptions)
text = text.replace("terminal ", "");
// ! => ~
val Pattern p = Pattern::compile("!\\(.+\\)")
val Matcher m = p.matcher(text)
while (m.find()) {
val group = m.group
text = text.replace(group, group.replaceFirst("!", "~"))
}
appendable.newLine.append(text + "\n");
}
}
Expand Down

0 comments on commit 73ae102

Please sign in to comment.