Commit fa53f8d2 authored by Johannes Roith's avatar Johannes Roith

Fix bug where the special code blocks would not be traversed in-order in the AST.

parent 596a488b
......@@ -441,12 +441,12 @@ action_code_part ::=
int debug_id = get_new_debug_id();
// TODO: attach inner range! based on user_codexleft, user_codexright
parserResult.actionCode = new SpecialCodeBlock(
parserResult.appendActionCode (new SpecialCodeBlock(
debug_id,
SpecialCodeBlock.BlockType.Action,
user_code,
new Range(Position.fromLocation(actxleft),
Position.fromLocation(smixright)));
Position.fromLocation(smixright))));
}
:}
;
......@@ -463,12 +463,12 @@ parser_code_part ::=
else { /* save the user included code string */
context.parser_code = user_code;
int debug_id = get_new_debug_id();
parserResult.parserCode = new SpecialCodeBlock(
parserResult.appendParserCode (new SpecialCodeBlock(
debug_id,
SpecialCodeBlock.BlockType.Parser,
user_code,
new Range(Position.fromLocation(prsxleft),
Position.fromLocation(smixright)));
Position.fromLocation(smixright))));
}
:}
;
......@@ -484,12 +484,12 @@ init_code ::=
else {/* save the user code */
context.init_code = user_code;
int debug_id = get_new_debug_id();
parserResult.initCode = new SpecialCodeBlock(
parserResult.appendInitCode(new SpecialCodeBlock(
debug_id,
SpecialCodeBlock.BlockType.Init,
user_code,
new Range(Position.fromLocation(initxleft),
Position.fromLocation(smixright)));
Position.fromLocation(smixright))));
}
:}
;
......@@ -506,12 +506,12 @@ scan_code ::=
/* save the user code */
context.scan_code = user_code;
int debug_id = get_new_debug_id();
parserResult.scanCode = new SpecialCodeBlock(
parserResult.appendScanCode (new SpecialCodeBlock(
debug_id,
SpecialCodeBlock.BlockType.Scan,
user_code,
new Range(Position.fromLocation(scanxleft),
Position.fromLocation(smixright)));
Position.fromLocation(smixright))));
}
:}
......
......@@ -19,11 +19,48 @@ public class ParserResult extends AbstractNode {
public ClassName className;
// TODO: these must be ordered as they occur, using a list!!
public CodeBlock actionCode;
public CodeBlock parserCode;
public CodeBlock initCode;
public CodeBlock scanCode;
private CodeBlock actionCode;
private CodeBlock parserCode;
private CodeBlock initCode;
private CodeBlock scanCode;
public CodeBlock getActionCode() {
return actionCode;
}
public CodeBlock getParserCode() {
return parserCode;
}
public CodeBlock getInitCode() {
return initCode;
}
public CodeBlock getScanCode() {
return scanCode;
}
public void appendActionCode(SpecialCodeBlock scb) {
this.actionCode = scb;
specialCodeBlocks.add(scb);
}
public void appendParserCode(SpecialCodeBlock scb) {
this.parserCode = scb;
specialCodeBlocks.add(scb);
}
public void appendInitCode(SpecialCodeBlock scb) {
this.initCode = scb;
specialCodeBlocks.add(scb);
}
public void appendScanCode(SpecialCodeBlock scb) {
this.scanCode = scb;
specialCodeBlocks.add(scb);
}
private List<CodeBlock> specialCodeBlocks = new ArrayList<CodeBlock>();
public List<SymbolDeclaration> symbols = new ArrayList<SymbolDeclaration> ();
public List<Precedence> precedences = new ArrayList<Precedence> ();
......@@ -81,17 +118,8 @@ public class ParserResult extends AbstractNode {
if (className != null)
className.accept(visitor, childArg);
if (actionCode != null)
actionCode.accept(visitor, childArg);
if (parserCode != null)
parserCode.accept(visitor, childArg);
if (initCode != null)
initCode.accept(visitor, childArg);
if (scanCode != null)
scanCode.accept(visitor, childArg);
for (CodeBlock cb : specialCodeBlocks)
cb.accept(visitor, childArg);
if (symbols != null)
for (SymbolDeclaration s : symbols)
......
package de.in.tum.www2.cup.internal;
import de.in.tum.www2.cup.ast.AbstractNode;
import de.in.tum.www2.cup.ast.NonTerminal;
import de.in.tum.www2.cup.ast.Symbol;
/** This abstract class serves as the base class for grammar symbols (i.e.,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment