Hi Patrick,
Using the official SableCC 3 version, I get the AST shown below which
seems fine to me. I've attached the Java source code for the Main class
producing this output.
I guess that, if there is a problem, it must be in the alternative
output back-end. Which language are you targeting? I've heard of minor
bugs in the C# target.
Start:
AGrammar:
AProgramHeading:
*TTsm: "TSM :"
ASingleTsmList:
*TTsmId: "{1,1,7}"
*TSemicolon: ";"
AMainStatementPart:
AFullStatement:
*TLabel: "BOUCLE:"
*TConditions: "AL"
AAssignStatement:
AFifoSimpleResultResultDest:
*TFifoSimpleResult: "(F,3,0,1)"
*TEqual: "="
ASourceFifoSimpleLSourceNode:
*TSourceFifoSimple: "r0"
*TOperator: "op1"
ARSourceNode:
ASourceFifoDeepLSourceNode:
*TSourceFifoDeep: "(r1,0)"
*TSemicolon: ";"
AFullStatement:
*TConditions: "AL"
AJumpStatement:
*TJump: "jump"
*TIdentifier: "BOUCLE"
*TSemicolon: ";"
*EOF: ""
Have fun,
Etienne
That is the long part :) Here it is! Thank yo again for the help you
will be able to provide to me :)
[...]
--
Etienne M. Gagnon, Ph.D.
SableCC:http://sablecc.org
import java.io.*;
import lexer.*;
import node.*;
import parser.*;
import analysis.*;
public class Main {
public static void main(
String[] args)
throws FileNotFoundException, ParserException, LexerException,
IOException {
Node ast = new Parser(new Lexer(new PushbackReader(new BufferedReader(
new FileReader("test.in")), 1024))).parse();
ast.apply(new DepthFirstAdapter() {
String indent = "";
@Override
public void defaultIn(
Node node) {
System.out.println(this.indent
+ node.getClass().getSimpleName() + ":");
this.indent += " ";
}
@Override
public void defaultOut(
Node node) {
this.indent = this.indent.substring(2);
}
@Override
public void defaultCase(
Node node) {
System.out.println(this.indent + "*"
+ node.getClass().getSimpleName() + ": \""
+ ((Token) node).getText() + "\"");
}
});
}
}
_______________________________________________
SableCC-Discussion mailing list
[email protected]
http://lists.sablecc.org/listinfo/sablecc-discussion