Numerous test fixes

This commit is contained in:
Peter Boyer 2016-01-08 09:28:38 -05:00
parent b53e85afd2
commit 857600be43
15 changed files with 201 additions and 124 deletions

View File

@ -72,7 +72,7 @@
<includes>
<!--<include>**/csharp/Test*.java</include>-->
<include>**/java/Test*.java</include>
<!--<include>**/java/Test*.java</include>-->
<include>**/go/Test*.java</include>
<!--<include>**/javascript/node/Test*.java</include>-->
<!--<include>**/python2/Test*.java</include> -->

View File

@ -173,9 +173,9 @@ AssertIsList(v) ::= "List\<?> __ttt__ = <v>;" // just use type system
AssignLocal(s,v) ::= "<s> = <v>;"
InitIntMember(n,v) ::= <%var <n> int = <v>; var _ int = <n>; // to disable unused var %>
InitIntMember(n,v) ::= <%var <n> int = <v>; var _ int = <n>; %>
InitBooleanMember(n,v) ::= <%var <n> bool= <v>; var _ bool = <n>; // to disable unused var %>
InitBooleanMember(n,v) ::= <%var <n> bool= <v>; var _ bool = <n>; %>
GetMember(n) ::= <%this.<n>%>
@ -213,13 +213,13 @@ TextEquals(a) ::= <%l.GetText() == "<a>"%>
PlusText(a) ::= <%"<a>" + l.GetText()%>
InputText() ::= "p.GetInput().GetText()"
InputText() ::= "p.GetTokenStream().GetAllText()"
LTEquals(i, v) ::= <%p.GetTokenStream().LT(<i>).GetText() == <v>%>
LANotEquals(i, v) ::= <%p.GetTokenStream().LA(<i>)!=<v>%>
TokenStartColumnEquals(i) ::= <%this._tokenStartCharPositionInLine==<i>%>
TokenStartColumnEquals(i) ::= <%this.TokenStartCharPositionInLine==<i>%>
ImportListener(X) ::= ""
@ -321,10 +321,10 @@ func NewPositionAdjustingLexerATNSimulator(recog antlr4.Lexer, atn *antlr4.ATN,
}
func (this *NewPositionAdjustingLexerATNSimulator) ResetAcceptPosition(input CharStream, index, line, charPositionInLine int) {
this.input.seek(index);
this.line = line;
this.charPositionInLine = charPositionInLine;
this.consume(input);
this.GetInputStream().Seek(index);
this.Line = line;
this.CharPositionInLine = charPositionInLine;
this.Consume(input);
}
>>
@ -447,7 +447,7 @@ func foo() {
Invoke_foo() ::= "foo()"
Declare_pred() ::= <<
bool pred(bool v) {
func pred(v bool) bool {
fmt.Println("eval="+fmt.Sprint(v))
return v
}

View File

@ -379,7 +379,7 @@ public class TestCompositeParsers extends BaseTest {
mkdir(parserpkgdir);
String slave_S =
"parser grammar S;\n" +
"a @after {var x int = 0; var _ int = x; // to disable unused var } : B;";
"a @after {var x int = 0; var _ int = x; } : B;";
writeFile(parserpkgdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(62);

View File

@ -4625,7 +4625,7 @@ public class TestLexerExec extends BaseTest {
public void testPositionAdjustingLexer() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(3026);
StringBuilder grammarBuilder = new StringBuilder(3037);
grammarBuilder.append("lexer grammar PositionAdjustingLexer;\n");
grammarBuilder.append("\n");
grammarBuilder.append("@members {\n");
@ -4712,10 +4712,10 @@ public class TestLexerExec extends BaseTest {
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("func (this *NewPositionAdjustingLexerATNSimulator) ResetAcceptPosition(input CharStream, index, line, charPositionInLine int) {\n");
grammarBuilder.append(" this.input.seek(index);\n");
grammarBuilder.append(" this.line = line;\n");
grammarBuilder.append(" this.charPositionInLine = charPositionInLine;\n");
grammarBuilder.append(" this.consume(input);\n");
grammarBuilder.append(" this.GetInputStream().Seek(index);\n");
grammarBuilder.append(" this.Line = line;\n");
grammarBuilder.append(" this.CharPositionInLine = charPositionInLine;\n");
grammarBuilder.append(" this.Consume(input);\n");
grammarBuilder.append("}\n");
grammarBuilder.append("\n");
grammarBuilder.append("}\n");

View File

@ -113,10 +113,10 @@ public class TestSemPredEvalLexer extends BaseTest {
public void testIndent() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(153);
StringBuilder grammarBuilder = new StringBuilder(152);
grammarBuilder.append("lexer grammar L;\n");
grammarBuilder.append("ID : [a-z]+ ;\n");
grammarBuilder.append("INDENT : [ \\t]+ { this._tokenStartCharPositionInLine==0 }?\n");
grammarBuilder.append("INDENT : [ \\t]+ { this.TokenStartCharPositionInLine==0 }?\n");
grammarBuilder.append(" { fmt.Println(\"INDENT\") } ;\n");
grammarBuilder.append("NL : '\\n';\n");
grammarBuilder.append("WS : [ \\t]+ ;");

View File

@ -74,9 +74,9 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testActionHidesPreds() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(268);
StringBuilder grammarBuilder = new StringBuilder(243);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; // to disable unused var }\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; }\n");
grammarBuilder.append("s : a+ ;\n");
grammarBuilder.append("a : {this.i = 1;} ID {this.i == 1}? {fmt.Println(\"alt 1\")}\n");
grammarBuilder.append(" | {this.i = 2;} ID {this.i == 2}? {fmt.Println(\"alt 2\")}\n");
@ -100,10 +100,10 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testActionsHidePredsInGlobalFOLLOW() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(280);
StringBuilder grammarBuilder = new StringBuilder(285);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {\n");
grammarBuilder.append("bool pred(bool v) {\n");
grammarBuilder.append("func pred(v bool) bool {\n");
grammarBuilder.append(" fmt.Println(\"eval=\"+fmt.Sprint(v))\n");
grammarBuilder.append(" return v\n");
grammarBuilder.append("}\n");
@ -148,10 +148,10 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testDepedentPredsInGlobalFOLLOW() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(303);
StringBuilder grammarBuilder = new StringBuilder(308);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {\n");
grammarBuilder.append("bool pred(bool v) {\n");
grammarBuilder.append("func pred(v bool) bool {\n");
grammarBuilder.append(" fmt.Println(\"eval=\"+fmt.Sprint(v))\n");
grammarBuilder.append(" return v\n");
grammarBuilder.append("}\n");
@ -352,9 +352,9 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testPredTestedEvenWhenUnAmbig_1() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(254);
StringBuilder grammarBuilder = new StringBuilder(229);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {var enumKeyword bool= true; var _ bool = enumKeyword; // to disable unused var }\n");
grammarBuilder.append("@members {var enumKeyword bool= true; var _ bool = enumKeyword; }\n");
grammarBuilder.append("primary\n");
grammarBuilder.append(" : ID {fmt.Println(\"ID \"+$ID.text)}\n");
grammarBuilder.append(" | {!this.enumKeyword}? 'enum' {fmt.Println(\"enum\")}\n");
@ -374,9 +374,9 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testPredTestedEvenWhenUnAmbig_2() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(254);
StringBuilder grammarBuilder = new StringBuilder(229);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {var enumKeyword bool= true; var _ bool = enumKeyword; // to disable unused var }\n");
grammarBuilder.append("@members {var enumKeyword bool= true; var _ bool = enumKeyword; }\n");
grammarBuilder.append("primary\n");
grammarBuilder.append(" : ID {fmt.Println(\"ID \"+$ID.text)}\n");
grammarBuilder.append(" | {!this.enumKeyword}? 'enum' {fmt.Println(\"enum\")}\n");
@ -397,9 +397,9 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testPredicateDependentOnArg() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(243);
StringBuilder grammarBuilder = new StringBuilder(218);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; // to disable unused var }\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; }\n");
grammarBuilder.append("s : a[2] a[1];\n");
grammarBuilder.append("a[int i]\n");
grammarBuilder.append(" : {$i==1}? ID {fmt.Println(\"alt 1\")}\n");
@ -423,9 +423,9 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testPredicateDependentOnArg2() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(199);
StringBuilder grammarBuilder = new StringBuilder(174);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; // to disable unused var }\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; }\n");
grammarBuilder.append("s : a[2] a[1];\n");
grammarBuilder.append("a[int i]\n");
grammarBuilder.append(" : {$i==1}? ID \n");
@ -447,10 +447,10 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testPredsInGlobalFOLLOW() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(274);
StringBuilder grammarBuilder = new StringBuilder(279);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {\n");
grammarBuilder.append("bool pred(bool v) {\n");
grammarBuilder.append("func pred(v bool) bool {\n");
grammarBuilder.append(" fmt.Println(\"eval=\"+fmt.Sprint(v))\n");
grammarBuilder.append(" return v\n");
grammarBuilder.append("}\n");
@ -599,9 +599,9 @@ public class TestSemPredEvalParser extends BaseTest {
@Test
public void testToLeftWithVaryingPredicate() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(292);
StringBuilder grammarBuilder = new StringBuilder(267);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; // to disable unused var }\n");
grammarBuilder.append("@members {var i int = 0; var _ int = i; }\n");
grammarBuilder.append("s : ({this.i += 1;\n");
grammarBuilder.append("fmt.Println(\"i=\" + this.i)} a)+ ;\n");
grammarBuilder.append("a : {this.i % 2 == 0}? ID {fmt.Println(\"alt 1\")}\n");

View File

@ -54,9 +54,9 @@ public class TestSets extends BaseTest {
@Test
public void testLexerOptionalSet() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(77);
StringBuilder grammarBuilder = new StringBuilder(86);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("A : ('a'|'b')? 'c' ;");
String grammar = grammarBuilder.toString();
String input ="ac";
@ -71,9 +71,9 @@ public class TestSets extends BaseTest {
@Test
public void testLexerPlusSet() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(77);
StringBuilder grammarBuilder = new StringBuilder(86);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("A : ('a'|'b')+ 'c' ;");
String grammar = grammarBuilder.toString();
String input ="abaac";
@ -88,9 +88,9 @@ public class TestSets extends BaseTest {
@Test
public void testLexerStarSet() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(77);
StringBuilder grammarBuilder = new StringBuilder(86);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("A : ('a'|'b')* 'c' ;");
String grammar = grammarBuilder.toString();
String input ="abaac";
@ -175,9 +175,9 @@ public class TestSets extends BaseTest {
@Test
public void testOptionalLexerSingleElement() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(71);
StringBuilder grammarBuilder = new StringBuilder(80);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("A : 'b'? 'c' ;");
String grammar = grammarBuilder.toString();
String input ="bc";
@ -192,9 +192,9 @@ public class TestSets extends BaseTest {
@Test
public void testOptionalSet() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(69);
StringBuilder grammarBuilder = new StringBuilder(78);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : ('a'|'b')? 'c' {fmt.Println(p.GetInput().GetText())} ;");
grammarBuilder.append("a : ('a'|'b')? 'c' {fmt.Println(p.GetTokenStream().GetAllText())} ;");
String grammar = grammarBuilder.toString();
String input ="ac";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -208,9 +208,9 @@ public class TestSets extends BaseTest {
@Test
public void testOptionalSingleElement() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(71);
StringBuilder grammarBuilder = new StringBuilder(80);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : A? 'c' {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : A? 'c' {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("A : 'b' ;");
String grammar = grammarBuilder.toString();
String input ="bc";
@ -241,9 +241,9 @@ public class TestSets extends BaseTest {
@Test
public void testParserNotToken() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(63);
StringBuilder grammarBuilder = new StringBuilder(72);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : ~'x' 'z' {fmt.Println(p.GetInput().GetText())} ;");
grammarBuilder.append("a : ~'x' 'z' {fmt.Println(p.GetTokenStream().GetAllText())} ;");
String grammar = grammarBuilder.toString();
String input ="zz";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -289,9 +289,9 @@ public class TestSets extends BaseTest {
@Test
public void testPlusLexerSingleElement() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(71);
StringBuilder grammarBuilder = new StringBuilder(80);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("A : 'b'+ 'c' ;");
String grammar = grammarBuilder.toString();
String input ="bbbbc";
@ -306,9 +306,9 @@ public class TestSets extends BaseTest {
@Test
public void testPlusSet() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(69);
StringBuilder grammarBuilder = new StringBuilder(78);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : ('a'|'b')+ 'c' {fmt.Println(p.GetInput().GetText())} ;");
grammarBuilder.append("a : ('a'|'b')+ 'c' {fmt.Println(p.GetTokenStream().GetAllText())} ;");
String grammar = grammarBuilder.toString();
String input ="abaac";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -322,9 +322,9 @@ public class TestSets extends BaseTest {
@Test
public void testRuleAsSet() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(76);
StringBuilder grammarBuilder = new StringBuilder(85);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a @after {fmt.Println(p.GetInput().GetText())} : 'a' | 'b' |'c' ;");
grammarBuilder.append("a @after {fmt.Println(p.GetTokenStream().GetAllText())} : 'a' | 'b' |'c' ;");
String grammar = grammarBuilder.toString();
String input ="b";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -338,9 +338,9 @@ public class TestSets extends BaseTest {
@Test
public void testSeqDoesNotBecomeSet() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(113);
StringBuilder grammarBuilder = new StringBuilder(122);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : C {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : C {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("fragment A : '1' | '2';\n");
grammarBuilder.append("fragment B : '3' '4';\n");
grammarBuilder.append("C : A | B;");
@ -357,9 +357,9 @@ public class TestSets extends BaseTest {
@Test
public void testStarLexerSingleElement_1() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(71);
StringBuilder grammarBuilder = new StringBuilder(80);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("A : 'b'* 'c' ;");
String grammar = grammarBuilder.toString();
String input ="bbbbc";
@ -374,9 +374,9 @@ public class TestSets extends BaseTest {
@Test
public void testStarLexerSingleElement_2() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(71);
StringBuilder grammarBuilder = new StringBuilder(80);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetInput().GetText())} ;\n");
grammarBuilder.append("a : A {fmt.Println(p.GetTokenStream().GetAllText())} ;\n");
grammarBuilder.append("A : 'b'* 'c' ;");
String grammar = grammarBuilder.toString();
String input ="c";
@ -391,9 +391,9 @@ public class TestSets extends BaseTest {
@Test
public void testStarSet() throws Exception {
mkdir(parserpkgdir);
StringBuilder grammarBuilder = new StringBuilder(69);
StringBuilder grammarBuilder = new StringBuilder(78);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("a : ('a'|'b')* 'c' {fmt.Println(p.GetInput().GetText())} ;");
grammarBuilder.append("a : ('a'|'b')* 'c' {fmt.Println(p.GetTokenStream().GetAllText())} ;");
String grammar = grammarBuilder.toString();
String input ="abaac";
String found = execParser("T.g4", grammar, "TParser", "TLexer",

View File

@ -6,7 +6,7 @@ import (
//
// This implementation of {@link ANTLRErrorListener} can be used to identify
// certain potential correctness and performance problems in grammars. "Reports"
// certain potential correctness and performance problems in grammars. "reports"
// are made by calling {@link Parser//NotifyErrorListeners} with the appropriate
// message.
//
@ -42,7 +42,7 @@ func (this *DiagnosticErrorListener) ReportAmbiguity(recognizer Parser, dfa *DFA
if this.exactOnly && !exact {
return
}
var msg = "ReportAmbiguity d=" +
var msg = "reportAmbiguity d=" +
this.getDecisionDescription(recognizer, dfa) +
": ambigAlts=" +
this.getConflictingAlts(ambigAlts, configs).String() +
@ -53,7 +53,7 @@ func (this *DiagnosticErrorListener) ReportAmbiguity(recognizer Parser, dfa *DFA
func (this *DiagnosticErrorListener) ReportAttemptingFullContext(recognizer Parser, dfa *DFA, startIndex, stopIndex int, conflictingAlts *BitSet, configs ATNConfigSet) {
var msg = "ReportAttemptingFullContext d=" +
var msg = "reportAttemptingFullContext d=" +
this.getDecisionDescription(recognizer, dfa) +
", input='" +
recognizer.GetTokenStream().GetTextFromInterval(NewInterval(startIndex, stopIndex)) + "'"
@ -61,7 +61,7 @@ func (this *DiagnosticErrorListener) ReportAttemptingFullContext(recognizer Pars
}
func (this *DiagnosticErrorListener) ReportContextSensitivity(recognizer Parser, dfa *DFA, startIndex, stopIndex, prediction int, configs ATNConfigSet) {
var msg = "ReportContextSensitivity d=" +
var msg = "reportContextSensitivity d=" +
this.getDecisionDescription(recognizer, dfa) +
", input='" +
recognizer.GetTokenStream().GetTextFromInterval(NewInterval(startIndex, stopIndex)) + "'"

View File

@ -3,6 +3,7 @@ package antlr4
import (
"fmt"
"strconv"
"os"
)
// Provides an empty default implementation of {@link ANTLRErrorListener}. The
@ -73,7 +74,7 @@ var ConsoleErrorListenerINSTANCE = NewConsoleErrorListener()
// </pre>
//
func (this *ConsoleErrorListener) SyntaxError(recognizer Recognizer, offendingSymbol interface{}, line, column int, msg string, e RecognitionException) {
fmt.Println("line " + strconv.Itoa(line) + ":" + strconv.Itoa(column) + " " + msg)
fmt.Fprintln(os.Stderr, "line " + strconv.Itoa(line) + ":" + strconv.Itoa(column) + " " + msg)
}
type ProxyErrorListener struct {

View File

@ -538,10 +538,16 @@ func (this *DefaultErrorStrategy) getMissingSymbol(recognizer Parser) Token {
var expecting = this.getExpectedTokens(recognizer)
var expectedTokenType = expecting.first()
var tokenText string
if expectedTokenType == TokenEOF {
tokenText = "<missing EOF>"
} else {
tokenText = "<missing " + recognizer.GetLiteralNames()[expectedTokenType] + ">"
ln := recognizer.GetLiteralNames()
if expectedTokenType > 0 && expectedTokenType < len(ln) {
tokenText = "<missing " + recognizer.GetLiteralNames()[expectedTokenType] + ">"
} else {
tokenText = "<missing undefined>" // TODO matches the JS impl
}
}
var current = currentSymbol
var lookback = recognizer.GetTokenStream().LT(-1)

View File

@ -340,7 +340,7 @@ func (l *BaseLexer) getCharIndex() int {
// Return the text Matched so far for the current token or any text override.
//Set the complete text of l token it wipes any previous changes to the text.
func (l *BaseLexer) text() string {
func (l *BaseLexer) GetText() string {
if l._text != "" {
return l._text
} else {
@ -348,7 +348,7 @@ func (l *BaseLexer) text() string {
}
}
func (l *BaseLexer) setText(text string) {
func (l *BaseLexer) SetText(text string) {
l._text = text
}

View File

@ -314,6 +314,7 @@ type OR struct {
}
func NewOR(a, b SemanticContext) *OR {
var operands = NewSet(nil, nil)
if aa, ok := a.(*OR); ok {
for _, o := range aa.opnds {
@ -345,6 +346,7 @@ func NewOR(a, b SemanticContext) *OR {
}
vs := operands.values()
opnds := make([]SemanticContext, len(vs))
for i, v := range vs {
vs[i] = v.(SemanticContext)

View File

@ -8,6 +8,7 @@ import (
// "regexp"
// "bytes"
// "encoding/gob"
"strconv"
)
func intMin(a, b int) int {
@ -151,7 +152,7 @@ func (this *Set) contains(value interface{}) bool {
}
func (this *Set) values() []interface{} {
var l = make([]interface{}, len(this.data))
var l = make([]interface{}, 0)
for key, _ := range this.data {
if strings.Index(key, "hash_") == 0 {
@ -252,7 +253,13 @@ func (this *BitSet) length() int {
}
func (this *BitSet) String() string {
return fmt.Sprint(this.data)
vals := this.values()
valsS := make([]string, len(vals))
for i,val := range vals {
valsS[i] = strconv.Itoa(val)
}
return "{" + strings.Join(valsS, ", ") + "}";
}
type AltDict struct {

View File

@ -22,10 +22,6 @@ var _ = fmt.Printf
var _ = reflect.Copy
var _ = strconv.Itoa
// Stopgap to shadow the Java types of the same name
type String string
<namedActions.header>
<parser>
@ -174,7 +170,9 @@ const (
func (p *<parser.name>) Sempred(localctx antlr4.RuleContext, ruleIndex, predIndex int) bool {
switch ruleIndex {
<parser.sempredFuncs.values:{f | case <f.ruleIndex>:
return p.<f.name; format="cap">_Sempred(localctx.(*<f.name; format="cap">Context), predIndex)}; separator="\n">
var t *<f.name; format="cap">Context = nil
if localctx != nil { t = localctx.(*<f.name; format="cap">Context) \}
return p.<f.name; format="cap">_Sempred(t, predIndex)}; separator="\n">
default:
panic("No predicate with index:" + fmt.Sprint(ruleIndex))
}
@ -189,10 +187,14 @@ dumpActions(recog, argFuncs, actionFuncs, sempredFuncs) ::= <<
<if(actionFuncs)>
func (l *<lexer.name>) Action(localctx antlr4.RuleContext, ruleIndex, actionIndex int) {
switch ruleIndex {
<recog.actionFuncs.values:{f|
case <f.ruleIndex>:
l.<f.name; format="cap">_Action(localctx<if(!f.isRuleContext)>.(*<f.ctxType>)<endif>, actionIndex)
}; separator="\n">
<recog.actionFuncs.values:{f| case <f.ruleIndex>:
<if(!f.isRuleContext)>
var t *<f.name; format="cap">Context = nil
if localctx != nil { t = localctx.(*<f.ctxType>) \}
return l.<f.name>_Action(t, actionIndex)
<else>
return l.<f.name>_Action(t, actionIndex)
<endif>}; separator="\n">
default:
panic("No registered action for:" + fmt.Sprint(ruleIndex))
}
@ -204,7 +206,13 @@ case <f.ruleIndex>:
func (l *<lexer.name>) Sempred(localctx antlr4.RuleContext, ruleIndex, predIndex int) bool {
switch ruleIndex {
<recog.sempredFuncs.values:{f| case <f.ruleIndex>:
return l.<f.name>_Sempred(localctx<if(!f.isRuleContext)>.(*<f.ctxType>)<endif>, predIndex);}; separator="\n">
<if(!f.isRuleContext)>
var t *<f.name; format="cap">Context = nil
if localctx != nil { t = localctx.(*<f.ctxType>) \}
return l.<f.name>_Sempred(t, predIndex);
<else>
return l.<f.name>_Sempred(t, predIndex);
<endif>}; separator="\n">
default:
panic("No registered predicate for:" + fmt.Sprint(ruleIndex))
}
@ -535,7 +543,7 @@ p.SetState(<m.stateNumber>)
Wildcard(w) ::= <<
p.SetState(<w.stateNumber>)
<if(w.labels)><w.labels:{l | <labelref(l)> = }><endif>MatchWildcard()
<if(w.labels)><w.labels:{l | <labelref(l)> = }><endif>p.MatchWildcard()
>>
// ACTION STUFF
@ -570,33 +578,33 @@ LexerPushModeCommand(arg) ::= "p.PushMode(<arg>)"
ActionText(t) ::= "<t.text>"
ActionTemplate(t) ::= "<t.st>"
ArgRef(a) ::= "localctx.<a.name>"
LocalRef(a) ::= "localctx.<a.name>"
RetValueRef(a) ::= "localctx.<a.name>"
QRetValueRef(a) ::= "<ctx(a)>.<a.dict>.<a.name>"
ArgRef(a) ::= "<ctx(a)>.<a.name>"
LocalRef(a) ::= "<ctx(a)>.<a.name>"
RetValueRef(a) ::= "<ctx(a)>.<a.name>"
QRetValueRef(a) ::= "<ctx(a)>.get<a.dict;format={cap}>().get<a.name;format={cap}>()"
/** How to translate $tokenLabel */
TokenRef(t) ::= "<ctx(t)>.<t.name>"
LabelRef(t) ::= "<ctx(t)>.<t.name>"
ListLabelRef(t) ::= "<ctx(t)>.<ListLabelName(t.name)>"
TokenRef(t) ::= "<ctx(t)>.get<t.name;format={cap}>()"
LabelRef(t) ::= "<ctx(t)>.get<t.name;format={cap}>()"
ListLabelRef(t) ::= "<ctx(t)>.get<ListLabelName(t.name);format={cap}>"
SetAttr(s,rhsChunks) ::= "<ctx(s)>.set<s.name; format={cap}>(<rhsChunks>)"
TokenLabelType() ::= "<file.TokenLabelType; null={antlr4.Token}>"
InputSymbolType() ::= "<file.InputSymbolType; null={antlr4.Token}>"
TokenPropertyRef_text(t) ::= "(func() string { if <ctx(t)>.<t.label> == nil { return \"\" } else { return <ctx(t)>.<t.label>.GetText() }}())"
TokenPropertyRef_type(t) ::= "(func() int { if <ctx(t)>.<t.label> == nil { return 0 } else { return <ctx(t)>.<t.label>.GetTokenType() }}())"
TokenPropertyRef_line(t) ::= "(func() int { if <ctx(t)>.<t.label> == nil { return 0 } else { return <ctx(t)>.<t.label>.GetLine() }}())"
TokenPropertyRef_pos(t) ::= "(func() int { if <ctx(t)>.<t.label> == nil { return 0 } else { return <ctx(t)>.<t.label>.GetColumn() }}())"
TokenPropertyRef_channel(t) ::= "(func() int { if <ctx(t)>.<t.label> == nil { return 0 } else { return <ctx(t)>.<t.label>.GetChannel() }}())"
TokenPropertyRef_index(t) ::= "(func() int { if <ctx(t)>.<t.label> == nil { return 0 } else { return <ctx(t)>.<t.label>.GetTokenIndex() }}())"
TokenPropertyRef_int(t) ::= "(func() int { if <ctx(t)>.<t.label> == nil { return 0 } else { return strconv.Atoi(<ctx(t)>.<t.label>.GetText()) }}())"
TokenPropertyRef_text(t) ::= "(func() string { if <ctx(t)>.get<t.label; format={cap}>() == nil { return \"\" } else { return <ctx(t)>.get<t.label; format={cap}>().GetText() }}())"
TokenPropertyRef_type(t) ::= "(func() int { if <ctx(t)>.get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.get<t.label; format={cap}>().GetTokenType() }}())"
TokenPropertyRef_line(t) ::= "(func() int { if <ctx(t)>.get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.get<t.label; format={cap}>().GetLine() }}())"
TokenPropertyRef_pos(t) ::= "(func() int { if <ctx(t)>.get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.get<t.label; format={cap}>().GetColumn() }}())"
TokenPropertyRef_channel(t) ::= "(func() int { if <ctx(t)>.get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.get<t.label; format={cap}>().GetChannel() }}())"
TokenPropertyRef_index(t) ::= "(func() int { if <ctx(t)>.get<t.label; format={cap}>() == nil { return 0 } else { return <ctx(t)>.get<t.label; format={cap}>().GetTokenIndex() }}())"
TokenPropertyRef_int(t) ::= "(func() int { if <ctx(t)>.get<t.label; format={cap}>() == nil { return 0 } else { return strconv.Atoi(<ctx(t)>.get<t.label; format={cap}>().GetText()) }}())"
RulePropertyRef_start(r) ::= "(func() antlr4.Token { if <ctx(r)>.<r.label> == nil { return nil } else { return <ctx(r)>.<r.label>.GetStart() }}())"
RulePropertyRef_stop(r) ::= "(func() antlr4.Token { if <ctx(r)>.<r.label> == nil { return nil } else { return <ctx(r)>.<r.label>.GetStop() }}())"
RulePropertyRef_text(r) ::= "(func() string { if <ctx(r)>.<r.label> == nil { return \"\" } else { return p.GetTokenStream().GetTextFromInterval( antlr4.NewInterval( <ctx(r)>.<r.label>.GetStart().GetTokenIndex(),<ctx(r)>.<r.label>.GetStop().GetTokenIndex())) }}())"
RulePropertyRef_ctx(r) ::= "<ctx(r)>.<r.label>"
RulePropertyRef_start(r) ::= "(func() antlr4.Token { if <ctx(r)>.get<r.label;format={cap}>() == nil { return nil } else { return <ctx(r)>.get<r.label;format={cap}>().GetStart() }}())"
RulePropertyRef_stop(r) ::= "(func() antlr4.Token { if <ctx(r)>.get<r.label;format={cap}>() == nil { return nil } else { return <ctx(r)>.get<r.label;format={cap}>().GetStop() }}())"
RulePropertyRef_text(r) ::= "(func() string { if <ctx(r)>.get<r.label;format={cap}>() == nil { return \"\" } else { return p.GetTokenStream().GetTextFromInterval( antlr4.NewInterval( <ctx(r)>.get<r.label;format={cap}>().GetStart().GetTokenIndex(),<ctx(r)>.<r.label>.GetStop().GetTokenIndex())) }}())"
RulePropertyRef_ctx(r) ::= "<ctx(r)>.get<r.label;format={cap}>()"
RulePropertyRef_parser(r) ::= "p"
ThisRulePropertyRef_start(r) ::= "localctx.GetStart()"
@ -608,14 +616,16 @@ ThisRulePropertyRef_parser(r) ::= "p"
NonLocalAttrRef(s) ::= "GetInvokingContext(<s.ruleIndex>).<s.name>"
SetNonLocalAttr(s, rhsChunks) ::= "GetInvokingContext(<s.ruleIndex>).<s.name> = <rhsChunks>"
AddToLabelList(a) ::= "<ctx(a.label)>.(*<a.label.ctx.name>).<a.listName> = append(<ctx(a.label)>.(*<a.label.ctx.name>).<a.listName>, <labelref(a.label)>)"
AddToLabelList(a) ::= "<ctx(a.label)>.<a.listName> = append(<ctx(a.label)>.<a.listName>, <labelref(a.label)>)"
TokenDecl(t) ::= "<t.name> <TokenLabelType()>"
TokenTypeDecl(t) ::= "<t.name> int"
TokenListDecl(t) ::= "<t.name> antlr4.Token[] // = make([]<TokenLabelType()>, 0)"
TokenListDecl(t) ::= "<t.name> antlr4.Token[]"
RuleContextDecl(r) ::= "<r.name> I<r.ctxName>"
RuleContextListDecl(rdecl) ::= "<rdecl.name> []I<rdecl.ctxName> // = make([]*<rdecl.ctxName>, 0)"
RuleContextListDecl(rdecl) ::= "<rdecl.name> []I<rdecl.ctxName>"
AttributeDecl(d) ::= "<d.name> <d.type;format={lower}><if(d.initValue)>// TODO = <d.initValue><endif>"
ContextTokenGetterDecl(t) ::= <<
<t.name; format="cap">() interface{} {
@ -677,8 +687,8 @@ ListLabelName(label) ::= "<label>"
CaptureNextToken(d) ::= "<d.varName> = p.GetTokenStream().LT(1)"
CaptureNextTokenType(d) ::= "<d.varName> = p.GetTokenStream().LA(1);"
StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMembers,
superClass={ParserRuleContext}) ::= <<
StructDecl(struct,ctorAttrs,attrs,getters,dispatchMethods,interfaces,extensionMembers,tokenDecls,tokenTypeDecls,
tokenListDecls,ruleContextDecls,ruleContextListDecls,attributeDecls,superClass={ParserRuleContext}) ::= <<
// an interface to support dynamic dispatch (subclassing)
@ -686,6 +696,19 @@ type I<struct.name> interface {
antlr4.ParserRuleContext
getParser() antlr4.Parser
<struct.tokenDecls:{a | get<a.name; format="cap">() <TokenLabelType()> }; separator="\n">
<struct.tokenDecls:{a | set<a.name; format="cap">(<TokenLabelType()>) }; separator="\n">
<struct.tokenTypeDecls:{a | get<a.name; format="cap">() int }; separator="\n">
<struct.tokenTypeDecls:{a | set<a.name; format="cap">(int) }; separator="\n">
<struct.tokenListDecls:{a | get<a.name; format="cap">() []<TokenLabelType()>}; separator="\n">
<struct.tokenListDecls:{a | set<a.name; format="cap">([]<TokenLabelType()>)}; separator="\n">
<struct.ruleContextDecls:{a | get<a.name; format="cap">() I<a.ctxName>}; separator="\n">
<struct.ruleContextDecls:{a | set<a.name; format="cap">(I<a.ctxName>)}; separator="\n">
<struct.ruleContextListDecls:{a | get<a.name; format="cap">() []I<a.ctxName>}; separator="\n">
<struct.ruleContextListDecls:{a | set<a.name; format="cap">([]I<a.ctxName>) }; separator="\n">
<struct.attributeDecls:{a | get<a.name; format="cap">() <a.type;format="lower">}; separator="\n">
<struct.attributeDecls:{a | set<a.name; format="cap">(<a.type;format="lower">)}; separator="\n">
}
type <struct.name> struct {
@ -702,7 +725,7 @@ func NewEmpty<struct.name>() *<struct.name> {
return p
}
func New<struct.name>(parser antlr4.Parser, parent antlr4.ParserRuleContext, invokingState int<struct.ctorAttrs:{a | , <a.name> <a.type>}>) *<struct.name> {
func New<struct.name>(parser antlr4.Parser, parent antlr4.ParserRuleContext, invokingState int<struct.ctorAttrs:{a | , <a.name> <a.type;format="lower">}>) *<struct.name> {
var p = new(<struct.name>)
@ -711,15 +734,25 @@ func New<struct.name>(parser antlr4.Parser, parent antlr4.ParserRuleContext, inv
p.parser = parser
p.RuleIndex = <parser.name>RULE_<struct.derivedFromName>
// TODO initialize list attrs
<struct.ctorAttrs:{a | p.<a.name> = <a.name>}; separator="\n">
return p
}
func (s *<struct.name>) getParser() antlr4.Parser { return s.parser }
<struct.tokenDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() <TokenLabelType()> { return s.<a.name> \} }; separator="\n">
<struct.tokenDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v <TokenLabelType()>) { s.<a.name> = v \} }; separator="\n">
<struct.tokenTypeDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() int { return s.<a.name> \} }; separator="\n">
<struct.tokenTypeDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v int) { s.<a.name> = v \} }; separator="\n">
<struct.tokenListDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() []<TokenLabelType()> { return s.<a.name> \} }; separator="\n">
<struct.tokenListDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v []<TokenLabelType()>) { s.<a.name> = v \}}; separator="\n">
<struct.ruleContextDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() I<a.ctxName> { return s.<a.name> \} }; separator="\n">
<struct.ruleContextDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v I<a.ctxName>) { s.<a.name> = v \}}; separator="\n">
<struct.ruleContextListDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() []I<a.ctxName> { return s.<a.name> \} }; separator="\n">
<struct.ruleContextListDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v []I<a.ctxName>) { s.<a.name> = v \} }; separator="\n">
<struct.attributeDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() <a.type;format="lower"> { return s.<a.name> \} }; separator="\n">
<struct.attributeDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v <a.type;format="lower">) { s.<a.name> = v \}}; separator="\n">
<getters:{g | func (s *<struct.name>) <g>}; separator="\n\n">
<if(struct.provideCopyFrom)> <! don't need unless we have subclasses !>
@ -730,17 +763,15 @@ func (s *<struct.name>) CopyFrom(ctx *<struct.name>) {
}
<endif>
func (s *<struct.name>) GetRuleContext() antlr4.RuleContext {
// Go does not truly support inheritance nor virtual method calls, so we need to implement this directly
return s
}
func (s *<struct.name>) GetRuleContext() antlr4.RuleContext { return s }
<dispatchMethods; separator="\n">
<extensionMembers; separator="\n">
>>
AltLabelStructDecl(struct,attrs,getters,dispatchMethods) ::= <<
AltLabelStructDecl(struct,attrs,getters,dispatchMethods,tokenDecls,tokenTypeDecls,
tokenListDecls,ruleContextDecls,ruleContextListDecls,attributeDecls) ::= <<
type <struct.name> struct {
*<currentRule.name; format="cap">Context
@ -759,10 +790,20 @@ func New<struct.name>(parser antlr4.Parser, ctx antlr4.ParserRuleContext) *<stru
return p
}
func (s *<struct.name>) GetRuleContext() antlr4.RuleContext {
// Go does not truly support inheritance nor virtual method calls, so we need to implement this directly
return s
}
<struct.tokenDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() <TokenLabelType()> { return s.<a.name> \} }; separator="\n">
<struct.tokenDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v <TokenLabelType()>) { s.<a.name> = v \} }; separator="\n">
<struct.tokenTypeDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() int { return s.<a.name> \} }; separator="\n">
<struct.tokenTypeDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v int) { s.<a.name> = v \} }; separator="\n">
<struct.tokenListDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() []<TokenLabelType()> { return s.<a.name> \} }; separator="\n">
<struct.tokenListDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v []<TokenLabelType()>) { s.<a.name> = v \}}; separator="\n">
<struct.ruleContextDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() I<a.ctxName> { return s.<a.name> \} }; separator="\n">
<struct.ruleContextDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v I<a.ctxName>) { s.<a.name> = v \}}; separator="\n">
<struct.ruleContextListDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() []I<a.ctxName> { return s.<a.name> \} }; separator="\n">
<struct.ruleContextListDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v []I<a.ctxName>) { s.<a.name> = v \} }; separator="\n">
<struct.attributeDecls:{a | func (s *<struct.name>) get<a.name; format="cap">() <a.type;format="lower"> { return s.<a.name> \} }; separator="\n">
<struct.attributeDecls:{a | func (s *<struct.name>) set<a.name; format="cap">(v <a.type;format="lower">) { s.<a.name> = v \}}; separator="\n">
func (s *<struct.name>) GetRuleContext() antlr4.RuleContext { return s }
<getters:{g | func (s *<struct.name>) <g>}; separator="\n\n">
<dispatchMethods; separator="\n">
@ -788,13 +829,12 @@ func (s *<struct.name>) Accept(visitor antlr4.ParseTreeVisitor) interface{} {
}
>>
AttributeDecl(d) ::= "<d.name> <d.type><if(d.initValue)>// TODO = <d.initValue><endif>"
/** If we don't know location of label def x, use this template */
labelref(x) ::= "<if(!x.isLocal)>localctx.(*<x.ctx.name>).<endif><x.name>"
/** For any action chunk, what is correctly-typed context struct ptr? */
ctx(actionChunk) ::= "localctx"
ctx(actionChunk) ::= "localctx.(*<actionChunk.ctx.name>)"
// used for left-recursive rules
recRuleAltPredicate(ruleName,opPrec) ::= "p.Precpred(p.GetParserRuleContext(), <opPrec>)"
@ -915,7 +955,6 @@ SerializedATN(model) ::= <<
>>
/**
* strings.Join( []string{ "<model.serialized; wrap={",<\n> "}>" }, "" )
* Using a type to init value map, try to init a type; if not in table
* must be an object, default value is "nil".
*/

View File

@ -57,6 +57,13 @@ public class StructDecl extends Decl {
@ModelElement public List<OutputModelObject> interfaces;
@ModelElement public List<OutputModelObject> extensionMembers;
@ModelElement public OrderedHashSet<Decl> tokenDecls = new OrderedHashSet<Decl>();
@ModelElement public OrderedHashSet<Decl> tokenTypeDecls = new OrderedHashSet<Decl>();
@ModelElement public OrderedHashSet<Decl> tokenListDecls = new OrderedHashSet<Decl>();
@ModelElement public OrderedHashSet<Decl> ruleContextDecls = new OrderedHashSet<Decl>();
@ModelElement public OrderedHashSet<Decl> ruleContextListDecls = new OrderedHashSet<Decl>();
@ModelElement public OrderedHashSet<Decl> attributeDecls = new OrderedHashSet<Decl>();
public StructDecl(OutputModelFactory factory, Rule r) {
super(factory, factory.getGenerator().getTarget().getRuleFunctionContextStructName(r));
addDispatchMethods(r);
@ -80,8 +87,23 @@ public class StructDecl extends Decl {
public void addDecl(Decl d) {
d.ctx = this;
if ( d instanceof ContextGetterDecl ) getters.add(d);
else attrs.add(d);
if (d instanceof TokenTypeDecl ) {
tokenTypeDecls.add(d);
} else if (d instanceof TokenListDecl ) {
tokenListDecls.add(d);
} else if (d instanceof TokenDecl){
tokenDecls.add(d);
} else if (d instanceof RuleContextListDecl ) {
ruleContextListDecls.add(d);
} else if (d instanceof RuleContextDecl ) {
ruleContextDecls.add(d);
} else if (d instanceof AttributeDecl ){
attributeDecls.add(d);
}
}
public void addDecl(Attribute a) {