summaryrefslogtreecommitdiff
path: root/src/ast/nodes/ImportNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/nodes/ImportNode.java')
-rw-r--r--src/ast/nodes/ImportNode.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/ast/nodes/ImportNode.java b/src/ast/nodes/ImportNode.java
index 97e3404..1f797f8 100644
--- a/src/ast/nodes/ImportNode.java
+++ b/src/ast/nodes/ImportNode.java
@@ -58,14 +58,14 @@ public class ImportNode implements Node {
}
@Override
- public String toPrint(String prefix) {
+ public String printAST(String prefix) {
String str = prefix + "Import\n";
prefix += " ";
if (isFrom) {
- str += prefix + " From\n" + dottedName.toPrint(prefix + " ");
+ str += prefix + " From\n" + dottedName.printAST(prefix + " ");
} else {
- str += dottedName.toPrint(prefix);
+ str += dottedName.printAST(prefix);
}
if (importAs) {
@@ -88,4 +88,27 @@ public class ImportNode implements Node {
return str;
}
+ @Override
+ public String toPrint(String prefix) {
+ String str = prefix;
+
+ if (isFrom) {
+ str += "from " + dottedName.toPrint("") + " import ";
+ if (importAll) {
+ str += "*";
+ } else {
+ str += names.get(0);
+ for (int i = 1; i < names.size(); ++i) {
+ str += ", " + names.get(i);
+ }
+ }
+ } else {
+ str += "import " + dottedName.toPrint("");
+ if (importAs) {
+ str += " as " + names.get(0);
+ }
+ }
+ return str;
+ }
+
}