From 368f5ed404383d9e6adb954a803a2c760e326975 Mon Sep 17 00:00:00 2001 From: Lucas Kramer Date: Thu, 9 Nov 2023 19:30:30 -0600 Subject: [PATCH 01/64] Add debugger stub function --- runtime/java/src/common/Debug.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 runtime/java/src/common/Debug.java diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java new file mode 100644 index 000000000..765d97d15 --- /dev/null +++ b/runtime/java/src/common/Debug.java @@ -0,0 +1,11 @@ +package common; + +public class Debug { + + public static DecoratedNode runDebug(DecoratedNode tree) { + // Do interactive debug stuff + + // Return the original tree when the user exits + return tree; + } +} From e71f4d52685b9ae5fcdaa2aefde6a4c7a8602a6e Mon Sep 17 00:00:00 2001 From: Lucas Kramer Date: Thu, 9 Nov 2023 19:35:05 -0600 Subject: [PATCH 02/64] Add debug function --- grammars/silver/core/Debug.sv | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 grammars/silver/core/Debug.sv diff --git a/grammars/silver/core/Debug.sv b/grammars/silver/core/Debug.sv new file mode 100644 index 000000000..486f9b8d9 --- /dev/null +++ b/grammars/silver/core/Debug.sv @@ -0,0 +1,12 @@ +grammar silver:core; + +@{- + - Launch an interactive debug session to explore a tree. + -} +function debug +Decorated a with i ::= tree::Decorated a with i +{ + return error("foreign function"); +} foreign { + "java" : return "common.Debug.runDebug(%tree%)"; +} From 56922362641787aed897e0eb30c9fd32193f0fb2 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 7 Dec 2023 09:28:48 -0600 Subject: [PATCH 03/64] demo missing view --- runtime/java/src/common/Debug.java | 378 ++++++++++++++++++++- runtime/java/src/common/DecoratedNode.java | 12 +- runtime/java/src/common/RTTIManager.java | 10 +- 3 files changed, 393 insertions(+), 7 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 765d97d15..d9cc02163 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -1,11 +1,379 @@ package common; +import java.util.HashMap; +import java.util.Scanner; +import java.util.Set; + +import org.w3c.dom.Node; + +import common.RTTIManager.Nonterminalton; + public class Debug { - - public static DecoratedNode runDebug(DecoratedNode tree) { + public static DecoratedNode runDebug(DecoratedNode tree) + { + Debug debug = new Debug(); + debug.runingDebug(tree); + return tree; + } + + public void runingDebug(DecoratedNode tree) { // Do interactive debug stuff + Scanner inp = new Scanner(System.in); + + System.out.println("Enter characters, " + + " and 'q' to quit."); + String userInput; + String[] userInputList; + this.root = tree; + this.currentNode = tree; - // Return the original tree when the user exits - return tree; + //COntrol loop + loop: do { + userInput = inp.nextLine(); + userInputList = userInput.split(" "); + switch (userInputList[0]) { + case "up": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: up<>"); + }else{ + //FIXME: Should prevent the root form going up but does not work + if (currentNode.getParent() != null){ + currentNode = currentNode.getParent(); + System.out.println("going to parent"); + }else{ + System.out.println("Node has no parent"); + } + } + break; + case "down": + if (userInputList.length != 2) { + System.out.println("invalid, correct usage: down"); + }else{ + DecoratedNode childNode = down(Integer.parseInt(userInputList[1])); + if(childNode == null){ + System.out.println("invalid child number"); + } + else{ + System.out.println("going down"); + currentNode = childNode; + } + } + break; + case "forwards": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: forwards<>"); + }else{ + DecoratedNode childNode = forwards(currentNode); + if(childNode == null){ + System.out.println("invalid no node to forward"); + } + else{ + System.out.println("going forward"); + currentNode = childNode; + } + } + break; + case "backtrack": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: backtrack<>"); + }else{ + + DecoratedNode childNode = forwards(currentNode); + if(childNode == null){ + System.out.println("invalid no node to backtrack to"); + } + else{ + System.out.println("going backwrds"); + currentNode = childNode; + } + } + break; + //Display the production + case "prod": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: prod<>"); + }else{ + String partent_type = currentNode.undecorate().getProdleton().getName(); + String child_types[] = currentNode.undecorate().getProdleton().getChildTypes(); + System.out.println(partent_type); + for (int i = 0; i < child_types.length; i++){ + System.out.println(child_types[i]); + } + } + break; + //TODO:Implement this - use genericShow + case "eq": + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: eq"); + }else{ + System.out.println("do the eq stuff"); + + } + break; + //List synthesized attributes + case "listSynth": + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: listSynth"); + }else{ + if(listSynth(currentNode) == 0){ + System.out.println("no synthesized attributes"); + } + } + break; + //List inherited attributes + case "listInher": + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: listInher"); + }else{ + if(listInher(currentNode) == 0){ + System.out.println("no inherited attributes"); + } + } + break; + //list all attributes + case "list": + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: list"); + }else{ + if(listSynth(currentNode) + listInher(currentNode) == 0){ + System.out.println("no attributes"); + } + } + break; + //TODO: Implement this + case "view": + if (userInputList.length != 3) { + System.out.println("invalid, correct usage: view"); + }else{ + System.out.println("do the view list"); + } + break; + case "help": + System.out.println("up<>"); + System.out.println("down"); + System.out.println("view"); + System.out.println("forwards<>"); + System.out.println("backtrack<>"); + System.out.println("prod<>"); + System.out.println("eq"); + System.out.println("listSynth"); + System.out.println("listInher"); + System.out.println("list"); + System.out.println("exit"); + break; + //Many ways to leave + case "exit": + case "q": + case "quit": + System.out.println("debugger out"); + break loop; + default: + System.out.println("invalid input call help for legal inputs"); + break; + } + } while(true); + } + private DecoratedNode root; + private DecoratedNode currentNode; + HashMap currentNodeSynthAttrs; + HashMap currentNodeInhAttrs; + HashMap currentNodeLocalAttrs; + private int currentLine; + private int currentColumn; + // public Debugger(DecoratedNode root) + // { + // this.root = root; + // this.currentNode = root; + // this.currentLine = 0; + // this.currentColumn = 0; + // } + public void setCurrentNode(DecoratedNode node) + { + currentNodeSynthAttrs = null; + currentNodeInhAttrs = null; + currentNodeLocalAttrs = null; + currentNode = node; + } + public DecoratedNode up() + { + if (currentNode.getParent() != null) + { + currentNode = (DecoratedNode) currentNode.getParent(); + return currentNode; + } + return null; + } + public DecoratedNode down(int child) + { + if (currentNode.getNode().getNumberOfChildren() > child) + { + DecoratedNode childNode = currentNode.childDecorated(child); + return childNode; + } + return null; + } + public DecoratedNode forwards(DecoratedNode Node) + { + if (Node.getNode().hasForward()){ + currentNode = Node.forward(); + return currentNode; + } + return null; + } + public DecoratedNode backtrack(DecoratedNode Node) + { + currentNode = Node.getForwardParent(); + return currentNode; + + } + // ask erik how this works again + public void printProduction() + { + currentNode.getNode().getProdleton().getName(); + } + // Prints out the equation of the specified attr. + // If attr is not specified, prints out the equations for all the attributes on the current node. + // via eric we can just add equations as an attribute within our AG + public void eqSynth(int attribute) + { + + } + public void eqInher(int attribute) + { + + } + // no optional params in java, could use overloading or just pass in null + public int listSynth(DecoratedNode node) + { + // Node undecorated = node.undecorate(); + // int count = undecorated.getNumberOfSynAttrs(); + // HashMap hash = new HashMap(); + // for(int i = 0; i < count; i++) + // { + // Lazy attribute = node.getSynthesized(i); + // // do whatever printing, no method getSynAttrValue + // hash.put(i, new StringObjectPair(currentNode.getNameOfSynAttr(i), currentNode.evalSyn(i))); + // } + // currentNodeSynthAttrs = hash; + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + Set synAttrSet = nonterminalton.getAllSynth(); + int num_attr = 0; + + for (String synAttr : synAttrSet) + { + System.out.println("Attribute = " + synAttr); + num_attr++; + } + return num_attr; + } + public int listInher(DecoratedNode node) + { + // Node undecorated = node.undecorate(); + // int count = undecorated.getNumberOfInhAttrs(); + // HashMap hash = new HashMap(); + // for(int i = 0; i < count; i++) + // { + // // no getInherited method; + // // Lazy attribute = node.getInherited(i); + // Lazy attribute = node.inherited(i); + // } + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + Set inhAttrSet = nonterminalton.getAllInh(); + int num_attr = 0; + + for (String inhAttr : inhAttrSet) + { + System.out.println("Attribute = " + inhAttr); + num_attr++; + } + return num_attr; + } + /* + public void listLocalAttrs(DecoratedNode node) + { + // Node undecorated = node.undecorate(); + // int count = undecorated.getNumberOfLocalAttrs(); + // HashMap hash = new HashMap(); + // for(int i = 0; i < count; i++) + // { + // Lazy attribute = node.getLocal(i); + // // do whatever printing + // hash.put(i, new StringObjectPair(currentNode.getNameOfLocalAttr(i), currentNode.evalLocalDecorated(i))); + // System.out.println("Attribute = " + entry.getKey() + + // ", Index = " + entry.getValue()) + // } + // currentNodeLocalAttrs = hash; + int count = node.getNumberOfLocalAttrs(); + for(int i = 0; i < count; i++) + { + Lazy attribute = node.getLocal(i); + // do whatever printing + System.out.println("Attribute = " + currentNode.getNameOfLocalAttr(i) + + ", Index = " + Integer.toString(i)); + } + } + */ + /* + // may want to rethink this such that view prints representation of attribute on current node, + // or allow an int to be passed in as the index of the child whose attribute you'd like to print info for + public void viewSynth(String attribute) + { + // if(currentNodeSynthAttrs == null) + // { + // System.out.println("No synthesized attributes to view"); + // return; + // } + // StringObjectPair pair = currentNodeSynthAttrs.get(attribute); + // if(pair == null) + // { + // System.out.println("No synthesized attribute with name " + attribute); + // return; + // } + // System.out.println("Attribute = " + pair.getString() + + // ", Value = " + pair.getObject().toString()); + // return; + Nonterminalton nonterminalton = RTTIManager.getNonterminalton(currentNode.getName()); + int index = nonterminalton.getSynOccursIndex(attribute); + Lazy attribute = currentNode.getSynthesized(index); + System.out.println("Attribute = " + attribute.getName() + + ", Value = " + attribute.eval(currentNode).toString()); + } + + public void viewInher(DecoratedNode node, int attribute) + { + Nonterminalton nonterminalton = RTTIManager.getNonterminalton(currentNode.getName()); + int index = nonterminalton.getInhOccursIndex(attribute); + Lazy attribute = currentNode.getInherited(index); + System.out.println("Attribute = " + attribute.getName() + + ", Value = " + attribute.eval(currentNode).toString()); + + } + */ + public void viewLocals(DecoratedNode node, int attribute) + { + + } + public boolean isContractum() + { + return false; + } + public static class StringObjectPair { + private String stringValue; + private Object objectValue; + + public StringObjectPair(String stringValue, Object objectValue) { + this.stringValue = stringValue; + this.objectValue = objectValue; + } + + public String getString() { + return stringValue; + } + + public Object getObject() { + return objectValue; + } } -} +} \ No newline at end of file diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index ba5916cb1..dea9024db 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -219,6 +219,16 @@ public final Node undecorate() { } } + public DecoratedNode getParent() + { + return parent; + } + + public DecoratedNode getForwardParent() + { + return forwardParent; + } + /** * Decorate this (unique decorated) node with additional inherited attributes. * This has no effect if the node already has a forward parent. @@ -831,4 +841,4 @@ public final String getDebugID() { public final String toString() { return getDebugID(); } -} +} \ No newline at end of file diff --git a/runtime/java/src/common/RTTIManager.java b/runtime/java/src/common/RTTIManager.java index 2f2f1f5b8..700e6479f 100644 --- a/runtime/java/src/common/RTTIManager.java +++ b/runtime/java/src/common/RTTIManager.java @@ -129,6 +129,14 @@ public final int getSynOccursIndex(String attrName) { } return synOccursIndices.get(attrName); } + // write a getAllInh() and getAllSyn() that return the keySet of each of these maps + public Set getAllInh() { + return inhOccursIndices.keySet(); + } + + public Set getAllSynth() { + return synOccursIndices.keySet(); + } } -} +} \ No newline at end of file From 3b3e665ae7789dd1e3909dcc3852e3ce2fc22303 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 7 Dec 2023 10:06:34 -0600 Subject: [PATCH 04/64] fixed going up on root --- runtime/java/src/common/Debug.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index d9cc02163..c9b05f14a 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -36,8 +36,7 @@ public void runingDebug(DecoratedNode tree) { if (userInputList.length != 1) { System.out.println("invalid, correct usage: up<>"); }else{ - //FIXME: Should prevent the root form going up but does not work - if (currentNode.getParent() != null){ + if (currentNode.getParent() instanceof TopNode ){ currentNode = currentNode.getParent(); System.out.println("going to parent"); }else{ From 6843dcc5db63f04af7573399b3161f3b8346494a Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 14 Dec 2023 03:14:11 -0600 Subject: [PATCH 05/64] implemented view --- runtime/java/src/common/Debug.java | 116 ++++++++++++++------- runtime/java/src/common/DecoratedNode.java | 14 +++ runtime/java/src/common/RTTIManager.java | 8 ++ 3 files changed, 102 insertions(+), 36 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index c9b05f14a..f116a6606 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -1,9 +1,13 @@ package common; import java.util.HashMap; +import java.util.Map; import java.util.Scanner; +import java.util.HashSet; import java.util.Set; +import common.Util.*; + import org.w3c.dom.Node; import common.RTTIManager.Nonterminalton; @@ -36,11 +40,13 @@ public void runingDebug(DecoratedNode tree) { if (userInputList.length != 1) { System.out.println("invalid, correct usage: up<>"); }else{ - if (currentNode.getParent() instanceof TopNode ){ + if (currentNode.getParent().getParent() instanceof TopNode || currentNode.getParent() == null){ + System.out.println("Root Node has no parent"); + }else if (currentNode.getParent() == null){ + System.out.println("Null parent"); + }else{ currentNode = currentNode.getParent(); System.out.println("going to parent"); - }else{ - System.out.println("Node has no parent"); } } break; @@ -141,16 +147,17 @@ public void runingDebug(DecoratedNode tree) { break; //TODO: Implement this case "view": - if (userInputList.length != 3) { - System.out.println("invalid, correct usage: view"); + if (userInputList.length != 2) { + System.out.println("invalid, correct usage: view"); }else{ - System.out.println("do the view list"); + // System.out.println("do the view list"); + viewAttr(currentNode, userInputList[1]); } break; case "help": System.out.println("up<>"); System.out.println("down"); - System.out.println("view"); + System.out.println("view"); System.out.println("forwards<>"); System.out.println("backtrack<>"); System.out.println("prod<>"); @@ -266,6 +273,7 @@ public int listSynth(DecoratedNode node) } return num_attr; } + public int listInher(DecoratedNode node) { // Node undecorated = node.undecorate(); @@ -314,42 +322,78 @@ public void listLocalAttrs(DecoratedNode node) } } */ - /* + // may want to rethink this such that view prints representation of attribute on current node, // or allow an int to be passed in as the index of the child whose attribute you'd like to print info for - public void viewSynth(String attribute) + public int viewSynth(DecoratedNode node, String attribute) { - // if(currentNodeSynthAttrs == null) - // { - // System.out.println("No synthesized attributes to view"); - // return; - // } - // StringObjectPair pair = currentNodeSynthAttrs.get(attribute); - // if(pair == null) - // { - // System.out.println("No synthesized attribute with name " + attribute); - // return; - // } - // System.out.println("Attribute = " + pair.getString() + - // ", Value = " + pair.getObject().toString()); - // return; - Nonterminalton nonterminalton = RTTIManager.getNonterminalton(currentNode.getName()); - int index = nonterminalton.getSynOccursIndex(attribute); - Lazy attribute = currentNode.getSynthesized(index); - System.out.println("Attribute = " + attribute.getName() + - ", Value = " + attribute.eval(currentNode).toString()); + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + int index = 0; + if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ + index = nonterminalton.getSynOccursIndex(attribute); + }else{ + System.out.println("Bad input, legal inputs:"); + Set synAttrSet = nonterminalton.getAllSynth(); + System.out.println("Keys: " + synAttrSet); + return -1; + } + Lazy synthAttribute = node.getNode().getSynthesized(index); + Object o = synthAttribute.eval(node); + System.out.println(Util.genericShow(o)); + return 1; } - public void viewInher(DecoratedNode node, int attribute) + public int viewInher(DecoratedNode node, String attribute) { - Nonterminalton nonterminalton = RTTIManager.getNonterminalton(currentNode.getName()); - int index = nonterminalton.getInhOccursIndex(attribute); - Lazy attribute = currentNode.getInherited(index); - System.out.println("Attribute = " + attribute.getName() + - ", Value = " + attribute.eval(currentNode).toString()); - + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + int index = 0; + if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + index = nonterminalton.getInhOccursIndex(attribute); + }else{ + System.out.println("Bad input, legal inputs:"); + Set inhAttrSet = nonterminalton.getAllInh(); + System.out.println("Keys: " + inhAttrSet); + return -1; + } + Object o = node.evalInhSomehowButPublic(index); + System.out.println(Util.genericShow(o)); + return 1; + } + + public int viewAttr(DecoratedNode node, String attribute) + { + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + int index = 0; + boolean isSynth = false; + if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ + index = nonterminalton.getSynOccursIndex(attribute); + isSynth = true; + }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + index = nonterminalton.getInhOccursIndex(attribute); + }else{ + System.out.println("Bad input, legal inputs:"); + Set allInputs = new HashSet(); + Set synAttrSet = nonterminalton.getAllSynth(); + Set inhAttrSet = nonterminalton.getAllInh(); + allInputs.addAll(synAttrSet); + allInputs.addAll(inhAttrSet); + System.out.println("Keys: " + allInputs); + return -1; + } + if(isSynth){ + Lazy synthAttribute = node.getNode().getSynthesized(index); + Object o = synthAttribute.eval(node); + System.out.println(Util.genericShow(o)); + }else{ + Object o = node.evalInhSomehowButPublic(index); + System.out.println(Util.genericShow(o)); + } + return 1; } - */ + public void viewLocals(DecoratedNode node, int attribute) { diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index dea9024db..fc078d004 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -841,4 +841,18 @@ public final String getDebugID() { public final String toString() { return getDebugID(); } + + //curesed function added by Michael who does not know how to get Inherited attributes otherwise + public final Object evalInhSomehowButPublic(final int attribute) { + // We specifically have to check here for inheritedAttributes == null, because + // that's what happens when we don't supply any inherited attributes... + // That is, unlike the unconditional access earlier for inheritedValues[attribute] + // (which could be null if *no inherited attributes occur at all* on this + // node), this could be the result of correctly compiled, but wrongly written user + // code. + if(inheritedAttributes != null && inheritedAttributes[attribute] != null) + return evalInhHere(attribute); + else + return evalInhViaFwdP(attribute); + } } \ No newline at end of file diff --git a/runtime/java/src/common/RTTIManager.java b/runtime/java/src/common/RTTIManager.java index 700e6479f..d7b177330 100644 --- a/runtime/java/src/common/RTTIManager.java +++ b/runtime/java/src/common/RTTIManager.java @@ -137,6 +137,14 @@ public Set getAllInh() { public Set getAllSynth() { return synOccursIndices.keySet(); } + + public Map getSynOccursIndices() { + return synOccursIndices; + } + + public Map getInhOccursIndices() { + return inhOccursIndices; + } } } \ No newline at end of file From 7c107e171dd4c632ede6beecd400bcf791aac90a Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Wed, 24 Jan 2024 17:39:42 -0600 Subject: [PATCH 06/64] downward navigation and viewing attributes is easier also added undo --- runtime/java/src/common/Debug.java | 333 +++++++++++++++-------- runtime/java/src/common/RTTIManager.java | 14 + 2 files changed, 236 insertions(+), 111 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index f116a6606..975c0bddb 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -1,3 +1,5 @@ +//TODO: Error handling is not good right now + package common; import java.util.HashMap; @@ -5,6 +7,10 @@ import java.util.Scanner; import java.util.HashSet; import java.util.Set; +import java.util.Stack; +import java.util.ArrayList; +import java.util.List; + import common.Util.*; @@ -21,22 +27,30 @@ public static DecoratedNode runDebug(DecoratedNode tree) } public void runingDebug(DecoratedNode tree) { - // Do interactive debug stuff Scanner inp = new Scanner(System.in); - - System.out.println("Enter characters, " - + " and 'q' to quit."); + System.out.println("Enter characters, and 'q' to quit."); String userInput; String[] userInputList; + boolean toggleProdDisplay = true; + DecoratedNode childNode; this.root = tree; this.currentNode = tree; + this.nodeStack = new Stack(); + + if(toggleProdDisplay){ + printProduction(currentNode); + } - //COntrol loop + //Control loop loop: do { userInput = inp.nextLine(); userInputList = userInput.split(" "); + + //Each case has a set of conditionals to make everything is in order befor running + //in the final case they call a helper function that does most of the work switch (userInputList[0]) { - case "up": + + case "up": case "u": if (userInputList.length != 1) { System.out.println("invalid, correct usage: up<>"); }else{ @@ -45,67 +59,128 @@ public void runingDebug(DecoratedNode tree) { }else if (currentNode.getParent() == null){ System.out.println("Null parent"); }else{ + nodeStack.push(currentNode); currentNode = currentNode.getParent(); - System.out.println("going to parent"); + //System.out.println("going to parent"); + if(toggleProdDisplay){ + printProduction(currentNode); + } } } break; - case "down": + + case "down": case "d": + int childNum = 0; if (userInputList.length != 2) { - System.out.println("invalid, correct usage: down"); + //System.out.println("invalid, correct usage: down "); + System.out.println("Which child?"); + printChildren(currentNode); + childNum = inp.nextInt(); + inp.nextLine(); }else{ - DecoratedNode childNode = down(Integer.parseInt(userInputList[1])); - if(childNode == null){ - System.out.println("invalid child number"); + childNum = Integer.parseInt(userInputList[1]); + } + + childNode = down(childNum); + if(childNode == null){ + System.out.println("invalid child number"); + } + else{ + nodeStack.push(currentNode); + currentNode = childNode; + //System.out.println("going down"); + if(toggleProdDisplay){ + printProduction(currentNode); + } + } + break; + + case "undo": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: undo<>"); + }else{ + if(nodeStack.empty()){ + System.out.println("invalid no node to undo"); } else{ - System.out.println("going down"); - currentNode = childNode; + DecoratedNode newNode = nodeStack.pop(); + currentNode = newNode; + //System.out.println("undoing last movement"); + if(toggleProdDisplay){ + printProduction(currentNode); + } } } break; + + //TODO: Untested, find good test case case "forwards": if (userInputList.length != 1) { System.out.println("invalid, correct usage: forwards<>"); }else{ - DecoratedNode childNode = forwards(currentNode); + childNode = forwards(currentNode); if(childNode == null){ System.out.println("invalid no node to forward"); - } + } else{ System.out.println("going forward"); currentNode = childNode; + if(toggleProdDisplay){ + printProduction(currentNode); + } } } break; + + //TODO: Untested, find good test case case "backtrack": if (userInputList.length != 1) { System.out.println("invalid, correct usage: backtrack<>"); }else{ - - DecoratedNode childNode = forwards(currentNode); + childNode = backtrack(currentNode); if(childNode == null){ System.out.println("invalid no node to backtrack to"); } else{ System.out.println("going backwrds"); currentNode = childNode; + if(toggleProdDisplay){ + printProduction(currentNode); + } + } + } + break; + + case "toggle": + if (userInputList.length != 2) { + System.out.println("please indicate what you want to toggle ex: 'toggle prodDisplay'"); + }else{ + if(userInputList[1].equals("prodDisplay")){ + if(toggleProdDisplay){ + System.out.println("Production Display off"); + toggleProdDisplay = false; + }else{ + System.out.println("Production Display on"); + toggleProdDisplay = true; + } + } + else{ + System.out.println("legal toggles: prodDisplay"); + System.out.println(userInputList[1]); } } break; + + //Display the production case "prod": if (userInputList.length != 1) { System.out.println("invalid, correct usage: prod<>"); }else{ - String partent_type = currentNode.undecorate().getProdleton().getName(); - String child_types[] = currentNode.undecorate().getProdleton().getChildTypes(); - System.out.println(partent_type); - for (int i = 0; i < child_types.length; i++){ - System.out.println(child_types[i]); - } + printProduction(currentNode); } break; + //TODO:Implement this - use genericShow case "eq": if (userInputList.length != 1 && userInputList.length != 2) { @@ -115,6 +190,7 @@ public void runingDebug(DecoratedNode tree) { } break; + //List synthesized attributes case "listSynth": if (userInputList.length != 1 && userInputList.length != 2) { @@ -125,6 +201,7 @@ public void runingDebug(DecoratedNode tree) { } } break; + //List inherited attributes case "listInher": if (userInputList.length != 1 && userInputList.length != 2) { @@ -135,38 +212,50 @@ public void runingDebug(DecoratedNode tree) { } } break; + //list all attributes - case "list": + case "list": case "l": if (userInputList.length != 1 && userInputList.length != 2) { System.out.println("invalid, correct usage: list"); }else{ - if(listSynth(currentNode) + listInher(currentNode) == 0){ - System.out.println("no attributes"); - } + // if(listSynth(currentNode) + listInher(currentNode) == 0){ + // System.out.println("no attributes"); + // } + printAttributes(currentNode); } break; - //TODO: Implement this - case "view": + + //Show the values of a specific attribute + case "view": case "v": + String attributeName = ""; + Integer attributeNum = 0; if (userInputList.length != 2) { - System.out.println("invalid, correct usage: view"); + System.out.println("Which attribute?"); + printAttributes(currentNode); + attributeNum = inp.nextInt(); + inp.nextLine(); + attributeName = getAttributeNameFromNum(currentNode, attributeNum); }else{ - // System.out.println("do the view list"); - viewAttr(currentNode, userInputList[1]); + attributeNum = Integer.parseInt(userInputList[1]); + attributeName = getAttributeNameFromNum(currentNode, attributeNum); } + printAttrFromName(currentNode, attributeName); break; + case "help": - System.out.println("up<>"); - System.out.println("down"); - System.out.println("view"); - System.out.println("forwards<>"); - System.out.println("backtrack<>"); - System.out.println("prod<>"); - System.out.println("eq"); - System.out.println("listSynth"); - System.out.println("listInher"); - System.out.println("list"); + System.out.println("up"); + System.out.println("down "); + System.out.println("view "); + System.out.println("forwards"); + System.out.println("backtrack"); + System.out.println("prod"); + System.out.println("eq"); + System.out.println("listSynth"); + System.out.println("listInher"); + System.out.println("list"); System.out.println("exit"); break; + //Many ways to leave case "exit": case "q": @@ -175,24 +264,20 @@ public void runingDebug(DecoratedNode tree) { break loop; default: System.out.println("invalid input call help for legal inputs"); + System.out.println(userInput); break; } } while(true); } private DecoratedNode root; private DecoratedNode currentNode; + private Stack nodeStack; HashMap currentNodeSynthAttrs; HashMap currentNodeInhAttrs; HashMap currentNodeLocalAttrs; private int currentLine; private int currentColumn; - // public Debugger(DecoratedNode root) - // { - // this.root = root; - // this.currentNode = root; - // this.currentLine = 0; - // this.currentColumn = 0; - // } + public void setCurrentNode(DecoratedNode node) { currentNodeSynthAttrs = null; @@ -200,6 +285,7 @@ public void setCurrentNode(DecoratedNode node) currentNodeLocalAttrs = null; currentNode = node; } + public DecoratedNode up() { if (currentNode.getParent() != null) @@ -209,6 +295,7 @@ public DecoratedNode up() } return null; } + public DecoratedNode down(int child) { if (currentNode.getNode().getNumberOfChildren() > child) @@ -218,25 +305,41 @@ public DecoratedNode down(int child) } return null; } - public DecoratedNode forwards(DecoratedNode Node) + + public void printChildren(DecoratedNode node) + { + String child_productions[] = node.undecorate().getProdleton().getChildTypes(); + for (int i = 0; i < child_productions.length; i++){ + System.out.println(Integer.toString(i) + ": " + child_productions[i] + " "); + } + } + + public DecoratedNode forwards(DecoratedNode node) { - if (Node.getNode().hasForward()){ - currentNode = Node.forward(); + if (node.getNode().hasForward()){ + currentNode = node.forward(); return currentNode; } return null; } - public DecoratedNode backtrack(DecoratedNode Node) + public DecoratedNode backtrack(DecoratedNode node) { - currentNode = Node.getForwardParent(); + currentNode = node.getForwardParent(); return currentNode; } - // ask erik how this works again - public void printProduction() + + public void printProduction(DecoratedNode node) { - currentNode.getNode().getProdleton().getName(); + String partent_production = node.undecorate().getProdleton().getName(); + String child_productions[] = node.undecorate().getProdleton().getChildTypes(); + System.out.print(partent_production + " "); + for (int i = 0; i < child_productions.length; i++){ + System.out.print(child_productions[i] + " "); + } + System.out.print("\n"); } + // Prints out the equation of the specified attr. // If attr is not specified, prints out the equations for all the attributes on the current node. // via eric we can just add equations as an attribute within our AG @@ -244,23 +347,15 @@ public void eqSynth(int attribute) { } + public void eqInher(int attribute) { } + // no optional params in java, could use overloading or just pass in null public int listSynth(DecoratedNode node) { - // Node undecorated = node.undecorate(); - // int count = undecorated.getNumberOfSynAttrs(); - // HashMap hash = new HashMap(); - // for(int i = 0; i < count; i++) - // { - // Lazy attribute = node.getSynthesized(i); - // // do whatever printing, no method getSynAttrValue - // hash.put(i, new StringObjectPair(currentNode.getNameOfSynAttr(i), currentNode.evalSyn(i))); - // } - // currentNodeSynthAttrs = hash; RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); Set synAttrSet = nonterminalton.getAllSynth(); @@ -276,15 +371,6 @@ public int listSynth(DecoratedNode node) public int listInher(DecoratedNode node) { - // Node undecorated = node.undecorate(); - // int count = undecorated.getNumberOfInhAttrs(); - // HashMap hash = new HashMap(); - // for(int i = 0; i < count; i++) - // { - // // no getInherited method; - // // Lazy attribute = node.getInherited(i); - // Lazy attribute = node.inherited(i); - // } RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); Set inhAttrSet = nonterminalton.getAllInh(); @@ -296,33 +382,29 @@ public int listInher(DecoratedNode node) num_attr++; } return num_attr; - } - /* - public void listLocalAttrs(DecoratedNode node) - { - // Node undecorated = node.undecorate(); - // int count = undecorated.getNumberOfLocalAttrs(); - // HashMap hash = new HashMap(); - // for(int i = 0; i < count; i++) - // { - // Lazy attribute = node.getLocal(i); - // // do whatever printing - // hash.put(i, new StringObjectPair(currentNode.getNameOfLocalAttr(i), currentNode.evalLocalDecorated(i))); - // System.out.println("Attribute = " + entry.getKey() + - // ", Index = " + entry.getValue()) - // } - // currentNodeLocalAttrs = hash; - int count = node.getNumberOfLocalAttrs(); - for(int i = 0; i < count; i++) + } + + public void printAttributes(DecoratedNode node){ + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + List attributeList = nonterminalton.alhpabeticalAttributes(); + int i = 0; + + for (String attribute : attributeList) { - Lazy attribute = node.getLocal(i); - // do whatever printing - System.out.println("Attribute = " + currentNode.getNameOfLocalAttr(i) + - ", Index = " + Integer.toString(i)); + System.out.println(Integer.toString(i) + ": " + attribute); + i++; } } - */ - + + public String getAttributeNameFromNum(DecoratedNode node, Integer attributeNum){ + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + List attributeList = nonterminalton.alhpabeticalAttributes(); + + return attributeList.get(attributeNum); + } + // may want to rethink this such that view prints representation of attribute on current node, // or allow an int to be passed in as the index of the child whose attribute you'd like to print info for public int viewSynth(DecoratedNode node, String attribute) @@ -362,7 +444,7 @@ public int viewInher(DecoratedNode node, String attribute) return 1; } - public int viewAttr(DecoratedNode node, String attribute) + public Integer printAttrFromName(DecoratedNode node, String attribute) { RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); @@ -374,13 +456,13 @@ public int viewAttr(DecoratedNode node, String attribute) }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ index = nonterminalton.getInhOccursIndex(attribute); }else{ - System.out.println("Bad input, legal inputs:"); - Set allInputs = new HashSet(); - Set synAttrSet = nonterminalton.getAllSynth(); - Set inhAttrSet = nonterminalton.getAllInh(); - allInputs.addAll(synAttrSet); - allInputs.addAll(inhAttrSet); - System.out.println("Keys: " + allInputs); + // System.out.println("Bad input, legal inputs:"); + // Set allInputs = new HashSet(); + // Set synAttrSet = nonterminalton.getAllSynth(); + // Set inhAttrSet = nonterminalton.getAllInh(); + // allInputs.addAll(synAttrSet); + // allInputs.addAll(inhAttrSet); + // System.out.println("Keys: " + allInputs); return -1; } if(isSynth){ @@ -398,10 +480,39 @@ public void viewLocals(DecoratedNode node, int attribute) { } - public boolean isContractum() + + //TODO: fix + /* + public void listLocalAttrs(DecoratedNode node) { - return false; + // Node undecorated = node.undecorate(); + // int count = undecorated.getNumberOfLocalAttrs(); + // HashMap hash = new HashMap(); + // for(int i = 0; i < count; i++) + // { + // Lazy attribute = node.getLocal(i); + // // do whatever printing + // hash.put(i, new StringObjectPair(currentNode.getNameOfLocalAttr(i), currentNode.evalLocalDecorated(i))); + // System.out.println("Attribute = " + entry.getKey() + + // ", Index = " + entry.getValue()) + // } + // currentNodeLocalAttrs = hash; + int count = node.getNumberOfLocalAttrs(); + for(int i = 0; i < count; i++) + { + Lazy attribute = node.getLocal(i); + // do whatever printing + System.out.println("Attribute = " + currentNode.getNameOfLocalAttr(i) + + ", Index = " + Integer.toString(i)); + } } + */ + + public boolean isContractum(DecoratedNode node) + { + return node.getNode().hasForward(); + } + public static class StringObjectPair { private String stringValue; private Object objectValue; diff --git a/runtime/java/src/common/RTTIManager.java b/runtime/java/src/common/RTTIManager.java index d7b177330..eb687b5be 100644 --- a/runtime/java/src/common/RTTIManager.java +++ b/runtime/java/src/common/RTTIManager.java @@ -117,6 +117,9 @@ public final boolean hasInh(String attrName) { public final boolean hasSyn(String attrName) { return synOccursIndices.containsKey(attrName); } + public final boolean hasAttribute(String attrName) { + return synOccursIndices.containsKey(attrName) || inhOccursIndices.containsKey(attrName); + } public final int getInhOccursIndex(String attrName) { if (!hasInh(attrName)) { throw new SilverError("Attribute " + attrName + " does not occur on " + getName() + "."); @@ -138,6 +141,17 @@ public Set getAllSynth() { return synOccursIndices.keySet(); } + public List alhpabeticalAttributes() { + Set allAttributesSet = new HashSet<>(); + allAttributesSet.addAll(inhOccursIndices.keySet()); + allAttributesSet.addAll(synOccursIndices.keySet()); + List allAttributesList = new ArrayList<>(); + allAttributesList.addAll(allAttributesSet); + allAttributesList.sort(null); + return allAttributesList; + + } + public Map getSynOccursIndices() { return synOccursIndices; } From 0f518df387136d83a617d8f1817c0170b55fff49 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 1 Feb 2024 16:31:21 -0600 Subject: [PATCH 07/64] locals exist and added TODO comments --- runtime/java/src/common/Debug.java | 37 ++++++++++++++++-------- runtime/java/src/common/RTTIManager.java | 3 +- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 975c0bddb..6f4944a03 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -78,6 +78,7 @@ public void runingDebug(DecoratedNode tree) { childNum = inp.nextInt(); inp.nextLine(); }else{ + //Explodes if the input is not a integer should gracefully exit childNum = Integer.parseInt(userInputList[1]); } @@ -226,6 +227,9 @@ public void runingDebug(DecoratedNode tree) { break; //Show the values of a specific attribute + + //Clear the prefix that is identical + //Print names of children not just types case "view": case "v": String attributeName = ""; Integer attributeNum = 0; @@ -236,12 +240,17 @@ public void runingDebug(DecoratedNode tree) { inp.nextLine(); attributeName = getAttributeNameFromNum(currentNode, attributeNum); }else{ + //Explodes if the input is not a integer should gracefully exit attributeNum = Integer.parseInt(userInputList[1]); attributeName = getAttributeNameFromNum(currentNode, attributeNum); } printAttrFromName(currentNode, attributeName); break; + case "local": + listLocalAttrs(currentNode); + break; + case "help": System.out.println("up"); System.out.println("down "); @@ -481,32 +490,36 @@ public void viewLocals(DecoratedNode node, int attribute) } - //TODO: fix - /* + //TODO: Add to the other attributes + //TODO: Print alst if unique otherwise print entire public void listLocalAttrs(DecoratedNode node) { - // Node undecorated = node.undecorate(); - // int count = undecorated.getNumberOfLocalAttrs(); + // int count = node.getNode().getNumberOfLocalAttrs(); // HashMap hash = new HashMap(); // for(int i = 0; i < count; i++) // { - // Lazy attribute = node.getLocal(i); + // Lazy attribute = node.getNode().getLocal(i); // // do whatever printing // hash.put(i, new StringObjectPair(currentNode.getNameOfLocalAttr(i), currentNode.evalLocalDecorated(i))); // System.out.println("Attribute = " + entry.getKey() + - // ", Index = " + entry.getValue()) + // ", Index = " + entry.getValue()); // } // currentNodeLocalAttrs = hash; - int count = node.getNumberOfLocalAttrs(); + + + + int count = node.getNode().getNumberOfLocalAttrs(); + //System.out.println("Attribute = " + Integer.toString(count)); + for(int i = 0; i < count; i++) { - Lazy attribute = node.getLocal(i); - // do whatever printing - System.out.println("Attribute = " + currentNode.getNameOfLocalAttr(i) + - ", Index = " + Integer.toString(i)); + Lazy attribute = node.getNode().getLocal(i); + Object o = attribute.eval(node); + // System.out.println(); + System.out.println("Attribute = " + node.getNode().getNameOfLocalAttr(i) + + "\nValue = " + Util.genericShow(o)); } } - */ public boolean isContractum(DecoratedNode node) { diff --git a/runtime/java/src/common/RTTIManager.java b/runtime/java/src/common/RTTIManager.java index eb687b5be..c7e605eaf 100644 --- a/runtime/java/src/common/RTTIManager.java +++ b/runtime/java/src/common/RTTIManager.java @@ -149,7 +149,6 @@ public List alhpabeticalAttributes() { allAttributesList.addAll(allAttributesSet); allAttributesList.sort(null); return allAttributesList; - } public Map getSynOccursIndices() { @@ -161,4 +160,6 @@ public Map getInhOccursIndices() { } } + //TODO: Add way to access children names + } \ No newline at end of file From b37720fbcbf1127f1fe9a342f698b27f1017e96b Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Thu, 1 Feb 2024 17:10:30 -0600 Subject: [PATCH 08/64] node to context extraction logic added --- runtime/java/src/common/ContextStack.java | 36 +++ runtime/java/src/common/DecoratedNode.java | 277 ++++++++++++++++++ .../java/src/common/NodeContextMessage.java | 221 ++++++++++++++ 3 files changed, 534 insertions(+) create mode 100644 runtime/java/src/common/ContextStack.java create mode 100644 runtime/java/src/common/NodeContextMessage.java diff --git a/runtime/java/src/common/ContextStack.java b/runtime/java/src/common/ContextStack.java new file mode 100644 index 000000000..78d9dd75f --- /dev/null +++ b/runtime/java/src/common/ContextStack.java @@ -0,0 +1,36 @@ +package common; + +// Wrapped around built-in Java Stack class +// No error handling in current version + +import java.util.Iterator; +import java.util.Stack; + +public class ContextStack { + + public void push(DecoratedNode n) { + this.height++; + NodeContextMessage ncm = new NodeContextMessage(n); + this.stack.push(ncm); + } + + public NodeContextMessage pop() { + this.height--; + return this.stack.pop(); + } + + public NodeContextMessage peak() { + return this.stack.peek(); + } + + public int get_height() { + return this.height; + } + + public Iterator iterator() { + return this.stack.iterator(); + } + + private Stack stack = new Stack(); + private int height = 0; +} diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index fc078d004..423295bd8 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -855,4 +855,281 @@ public final Object evalInhSomehowButPublic(final int attribute) { else return evalInhViaFwdP(attribute); } +} + + + // ************************************************************** + // Functions and attributes added for context message support + + // To add: + // setDebuggingIndex() DONE + // getDebuggingIndex() DONE + // getRedex() DONE + // getIsRedex() DONE + // getContractum() DONE + // getIsContractum() DONE + // getFilename() DONE + // getStartCoordinates()DONE + // getEndCoordinates() DONE + + // getOrigin() DONE + // getIsNew() DONE + + // getPrettyPrint() DONE + + // getIsAttribute() SORT-OF-DONE + + private int debugging_index; + private boolean is_redex; + private boolean is_contractum; + private boolean is_attribute; + private boolean need_set_is_attribute = true; + + private boolean need_compute_redex_contractum = true; + + public void setDebuggingIndex(int i) { + this.debugging_index = i; + } + public int getDebuggingIndex() { + return this.debugging_index; + } + + public boolean getIsRedex() { + if (this.need_compute_redex_contractum) { + this.compute_redex_contractum(); + } + return this.is_redex; + } + public boolean getIsContractum() { + if (this.need_compute_redex_contractum) { + this.compute_redex_contractum(); + } + return this.is_contractum; + } + + private void compute_redex_contractum() { + if (!this.need_compute_redex_contractum) { + return; + } + + // Consider as not mutually exclusive categories for now + // Something could forward to something that forwards again + // e.g. case -> ifthen -> ifthenelse + + // This is a very basic implementation that only looks + // at forwards as the only way to have reduction semantics + + if (this.self.hasForward()) { + this.is_redex = true; + } + else { + this.is_redex = false; + } + + if (this.forwardParent) { + this.is_contractum = true; + } + else { + this.is_contractum = false; + } + this.need_compute_redex_contractum = false; + } + + public DecoratedNode getRedex() { + // Wrapper for recursive helper + return this.getRedexHelper(this); + } + private DecoratedNode getRedexHelper(DecoratedNode dn) { + // For now assume abstract syntax tree root has null parent + // or just that dn.parent repeatedly will eventually find null + + // parent of DecoratedNode root is TopNode. Might need that and not null + if (dn instanceof TopNode) { + return null; + } + + if (dn.is_redex) { + return dn; + } + else { + return getRedexHelper(dn.parent); + } + } + + public DecoratedNode getContractum() { + // Wrapper for recursive helper + return this.getContractumHelper(this); + } + private DecoratedNode getContractumHelper(DecoratedNode dn) { + // For now assume abstract syntax tree root has null parent + // or just that dn.parent repeatedly will eventually find null + if (dn == null) { + return null; + } + + if (dn.is_contractum) { + return dn; + } + else { + return getContractumHelper(dn.parent); + } + } + + public String getFilename() { + if (this.self == null) { + return ""; + } + else if (this.self instanceof silver.core.Alocation) { + DecoratedNode loc = ((silver.core.Alocation)self).getAnno_silver_core_location().decorate(TopNode.singleton, (Lazy[])null); + String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); + return file; + } else { + return ""; + } + } + + public FileCoordinate getStartCoordinates() { + if (this.self == null) { + return null; + } + else if (this.self instanceof silver.core.Alocation) { + DecoratedNode loc = ((silver.core.Alocation)self).getAnno_silver_core_location().decorate(TopNode.singleton, (Lazy[])null); + int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); + int col = (Integer)loc.synthesized(silver.core.Init.silver_core_column__ON__silver_core_Location); + return new FileCoordinate(line, col); + } + else { + return null; + } + } + + public FileCoordinate getEndCoordinates() { + if (this.self == null) { + return null; + } + else if (this.self instanceof silver.core.Alocation) { + DecoratedNode loc = ((silver.core.Alocation)self).getAnno_silver_core_location().decorate(TopNode.singleton, (Lazy[])null); + int line = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); + int col = (Integer)loc.synthesized(silver.core.Init.silver_core_endColumn__ON__silver_core_Location); + return new FileCoordinate(line, col); + } + else { + return null; + } + } + + // Wrapper around OriginUtils.getOriginOrNull() + // for the sake of my naming convention + // Not yet used but probably need for reference attributes + public NOriginInfo getOrigin() { + return OriginUtils.getOriginOrNull(this); + } + + // If not a contractum or redex, + // if getOrigin(this) == getRedex(this) + // implies a node is "newly" created + // like const(0) from neg(x) -> sub(0, x) + public boolean getIsNew() { + // Silver origin tracking does + // not return Nodes or Decorated nodes + // to do == comparison + + // From Lucas on Slack + // "You just want to get the NOriginInfo, + // check if the result is a PoriginOriginInfo + // or PoriginAndRedexOriginInfo, if it is then + // pull out the first child and do .getName() on that" + + NOriginInfo oinfo = OriginUtils.getOriginOrNull(this); + if (oinfo == null) { + return false; + } + if (oinfo instanceof PoriginAndRedexOriginInfo || + oinfo instanceof PoriginOriginInfo) { + + // Might need check types here + // Should get only Nodes from here + Object origin = (Object)oinfo.getChild_origin(); + // I don't know if this is will be a Node or DecoratedNode yet + String child_prod_name = ""; + if (origin instanceof Node) { + child_prod_name = origin.getName(); + } + // Not going to be a DecoratedNode + else if (origin instanceof DecoratedNode) { + child_prod_name = origin.getNode().getName(); + } + else { + System.err.println("ERROR. origin not Node nor DecoratedNode"); + } + // New if different production only + return !child_prod_name.equals(this.self.getName()); + } + return false; + } + + // access pretty print attribute + // through this function (a synthesized attribute) + // "pp" seems to be standard pretty print name + public String getPrettyPrint() { + + // use genericShow(): it accesses pp if it exists + return this.genericShow().toString(); + + // int num_attrs = this.self.getNumberOfSynAttrs(); + // for (int i = 0; i < num_attrs; i++) { + + // // Search until find name that is "pp" + // String name = this.self.getNameOfSynAttr(i); + // if (name.equals("pp")) { + // Lazy l_pp = this.self.getSynthesized(i); + // Object pp = evalSyn(l_pp); + // assert(l_pp != null) + // assert(pp instanceof String) + // return (String)pp; + // } + // } + // System.err.println("No pretty print (pp) attribute defined"); + // return "" + } + + // only set is_attribute once + public boolean getIsAttribute() { + if (this.need_set_is_attribute) { + this.setIsAttribute(); + this.need_set_is_attribute = false; + } + return this.is_attribute; + } + + // For now, assume there is a Silver annotation + // "is-attribute" of type String on + // higher-order attributes that is set to "TRUE" + // when true and not existant or FALSE when false + // https://melt.cs.umn.edu/silver/ref/decl/annotations/ + public void setIsAttribute() { + // Just walk through children of parent. .child() give you decorated node or something else + // just do == comparison. If same object, then child and not local higher-order attribute + + // if (this.need_set_is_attribute) { + // Object o = this.self.getAnno("is-attribute"); + // if (o) { + // String s = (String)o; + // if (s.equals("TRUE")) { + // this.is_attribute = true; + // return; + // } + // } + // this.is_attribute = false; + // } + + for (int i = 0; i < this.parent.childrenValues.length, i++) { + DecoratedNode dn = this.parent.childDecorated(i); + if (dn == this) { + return false; + } + } + return true; + } + } \ No newline at end of file diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java new file mode 100644 index 000000000..96a4c775f --- /dev/null +++ b/runtime/java/src/common/NodeContextMessage.java @@ -0,0 +1,221 @@ +package common; + +// Context implementation. + +// Headers are either TRANSLATION (for contractum) or HIGHER-ORDER +// Uses current label rules of is-contractum, is-redex, is-new, and is-attribute + +public class NodeContextMessage { + + public String GetSection0() { + return Integer.toString(this.num_index); + } + + public String GetSection1() { + String res = ""; + boolean first_set = false; + if (this.is_translation) { + res += "TRANSLATION"; + first_set = true; + } + if (this.is_higher_order) { + if (first_set) { + res += " & "; + } + res += "HIGHER-ORDER"; + } + return res; + } + + public String GetSection2() { + return this.text_repr; + } + + public String GetSection3() { + String res = "prod: " + this.prod_name + "\n" + + this.filename + " lines: " + this.fc_start.getRow() + + ":" + this.fc_start.getCol() + " -> " + this.fc_end.getRow() + + ":" + this.fc_end.getCol(); + return res; + } + + // Not mutually exclusive labels + public String GetSection4() { + String res = ""; + if (this.is_redex) { + res += "*is-redex\n"; + } + if (this.is_contractum) { + res += "*is-contractum of " + this.contractum_of + "\n"; + } + if (this.is_new) { + res += "*is-new\n"; + } + if (this.is_attribute) { + res += "*is-attribute\n"; + } + return res; + } + + // Constructor for NodeContextMessage + public NodeContextMessage(DecoratedNode node) { + // Section 0 + this.set_index(); + + // Try to do all this within java given a node n + + // Section 2 + this.prod_name = node.getName(); + this.fill_in_rows_and_cols(node); + + // Section 4 + this.set_labels(node); + + // Section 1--headers depend on label attributes + this.initialize_headers(node); + + // Section 3. Determine file lines last + // because they depend on computing boolean attributes + if (this.is_translation || this.is_higher_order || + this.is_attribute || this.is_contractum || this.is_new) { + this.text_repr = this.pretty_print(node); + } + else { + this.text_repr = this.pull_filelines(); + } + + this.has_been_initialized = true; + } + + private void set_index() { + next_index = 0; + this.num_index = next++; + } + + // Set is_higher_order and is_translation bools here + // Is there a way to know something is an attribute + // just from its node values? + private void initialize_headers(DecoratedNode node) { + + // Can figure out if translation is hasForward is true on self + // (Node of Decorated Node) + // This is used to set TRANSLATION header flag + if (node.getIsContractum()) { + // Only current way to determine if translation + this.is_translation = true; + } + else { + this.is_translation = false; + } + + // Trickier case is know if something is an attribute + // Rely on getter function that is to be added to Node. + // Basically if go "into" a node and not "down" as in a parent, + // want to set the is_attribute flag to TRUE. The getter + // returns true if the current DecoratedNode n is an attribute or + // if any parent was (recursively, until root was found) + this.is_higher_order = node.getIsAttribute(); + } + + // Use file location method I wrote in DecoratedNode + private void fill_in_rows_and_cols(DecoratedNode node){ + this.fc_start = node.getStartCoordinates(); + this.fc_end = node.getEndCoordinates(); + this.filename = node.getFilename(); + } + + // Big reduction semantics logic goes here + // Simplified now by only allowing forwards + // to be only reduction semantic + private void set_labels(DecoratedNode node) { + + this.is_redex = node.getIsRedex(); + this.is_contractum = node.getIsContractum(); + // Will always work for forwarding. Only use this value if is_contractum + this.contractum_of = node.getDebuggingIndex - 1; + this.is_new = node.getIsNew(); + this.is_attribute = node.getIsAttribute(); + this.attribute_of = node.getIsAttributeOf(); + } + + // access pp attribute if present + private void pretty_print(DecoratedNode node) { + + this.pretty_print = node.getPrettyPrint(); + } + + // probably need some file I/O, but might find it + // in java runtime code. Basically extract file lines + // from row x col y to row x' to y'. + private void pull_filelines() { + + // Currently not the most efficient but should get the job done for now + try (BufferedReader br = new BufferedReader(new FileReader(this.filename))) { + + int row = 0; + int col = 0; + String res = ""; + while (row < this.fc_start.getRow()) { + String line = br.readLine(); + } + // Advance to starting char + while (col < this.fc_start.getCol()) { + //Single char read + char c = br.read(); + } + // reset col to 0 for last read + col = 0; + // Now in correct row to start actually noting down file contents + while (row < this.fc_end.getRow()) { + res += br.readLine(); + } + // Now row = row.end + while (col <= this.fc_end.getCol()) { + res += br.read(); + } + // Done. Can close file now + br.close(); + + // Just set filebytes (text_repr) to res + this.text_repr = res; + + } catch (IOException e) { + System.out.println("ERROR READING FROM FILE " + this.filename); + e.printStackTrace(); + } + } + + @Override + public String toString() { + return this.GetSection0() + "\n" + this.GetSection1() + "\n" + this.GetSection2() + "\n" + this.GetSection3() + "\n" + this.GetSection4(); + } + + // Only perform attribute setting once + private boolean has_been_initialized = false; + + // Section 0. Every context box will have a numeric index label + private int num_index; + private static int next_index = 0; + + // Section 1. Header will contain TRANSLATION and/or HIGHER-ORDER + private boolean is_translation; + private boolean is_higher_order; + + // Section 2. Actual text representation + // (either copied from file or prity print (pp) represenation) + private String text_repr; + + // Section 3. Production name and file lines + private String prod_name; + private String filename; + private FileCoordinate fc_start; + private FileCoordinate fc_end; + + // Section 4. Labels and associated info + private boolean is_redex; + private boolean is_contractum; + private int contractum_of; + private boolean is_new; + private boolean is_attribute; + private int attribute_of; +} \ No newline at end of file From 6885e52b0dde05deb29195f18b51f5d399e40373 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 15 Feb 2024 03:54:12 -0600 Subject: [PATCH 09/64] added local attributes to list and view, also toggleing full attribute names --- runtime/java/src/common/Debug.java | 230 ++++++++++++----------- runtime/java/src/common/RTTIManager.java | 2 +- 2 files changed, 126 insertions(+), 106 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 6f4944a03..5d6b25f59 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -32,6 +32,7 @@ public void runingDebug(DecoratedNode tree) { String userInput; String[] userInputList; boolean toggleProdDisplay = true; + boolean toggleHeadlessAttributes = true; DecoratedNode childNode; this.root = tree; this.currentNode = tree; @@ -165,9 +166,17 @@ public void runingDebug(DecoratedNode tree) { toggleProdDisplay = true; } } + if(userInputList[1].equals("fullAttributeNames")){ + if(toggleHeadlessAttributes){ + System.out.println("Headless Attributes off"); + toggleHeadlessAttributes = false; + }else{ + System.out.println("Headless Attributes on"); + toggleHeadlessAttributes = true; + } + } else{ - System.out.println("legal toggles: prodDisplay"); - System.out.println(userInputList[1]); + System.out.println("legal toggles: prodDisplay, fullAttributeNames"); } } break; @@ -182,7 +191,7 @@ public void runingDebug(DecoratedNode tree) { } break; - //TODO:Implement this - use genericShow + //TODO:Implement this - use genericShow? case "eq": if (userInputList.length != 1 && userInputList.length != 2) { System.out.println("invalid, correct usage: eq"); @@ -222,31 +231,32 @@ public void runingDebug(DecoratedNode tree) { // if(listSynth(currentNode) + listInher(currentNode) == 0){ // System.out.println("no attributes"); // } - printAttributes(currentNode); + printAttributes(currentNode, toggleHeadlessAttributes); } break; //Show the values of a specific attribute - //Clear the prefix that is identical - //Print names of children not just types + //Print names of children not just types -- HARD! case "view": case "v": String attributeName = ""; Integer attributeNum = 0; + List attributeList = allAttributesList(currentNode); if (userInputList.length != 2) { System.out.println("Which attribute?"); - printAttributes(currentNode); + printAttributes(currentNode, toggleHeadlessAttributes); attributeNum = inp.nextInt(); inp.nextLine(); - attributeName = getAttributeNameFromNum(currentNode, attributeNum); + attributeName = attributeList.get(attributeNum); }else{ //Explodes if the input is not a integer should gracefully exit attributeNum = Integer.parseInt(userInputList[1]); - attributeName = getAttributeNameFromNum(currentNode, attributeNum); + attributeName = attributeList.get(attributeNum); } printAttrFromName(currentNode, attributeName); break; + case "local": listLocalAttrs(currentNode); break; @@ -393,132 +403,142 @@ public int listInher(DecoratedNode node) return num_attr; } - public void printAttributes(DecoratedNode node){ - RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); - RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - List attributeList = nonterminalton.alhpabeticalAttributes(); + public void printAttributes(DecoratedNode node, boolean toggleHeadlessAttributes){ + List attributeList = allAttributesList(node); + if(toggleHeadlessAttributes){ + attributeList = removeHeaders(allAttributesList(node)); + } int i = 0; + //int prefixLength = commonPrefixLength(attributeList); for (String attribute : attributeList) { + //String attributeNoPrefix = attribute.substring(prefixLength); System.out.println(Integer.toString(i) + ": " + attribute); i++; } } - public String getAttributeNameFromNum(DecoratedNode node, Integer attributeNum){ - RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); - RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - List attributeList = nonterminalton.alhpabeticalAttributes(); - - return attributeList.get(attributeNum); + //Should this be in Util? -- Also probably no what we want thinking about it a bit more + // public int commonPrefixLength(List stringList){ + // String firstString = stringList.get(0); + + // //i is the prefix lenght we are testing + // for (int i = 0; i < firstString.length(); i++) { + // //look at all the strings and make sure they are all identical to the first at index i + // for (String element : stringList){ + // //If any sting is shorter than we are done + // if (element.length() < i){ + // return i; + // }//If any string is not equal to the first we are done + // else if(element.charAt(i) != firstString.charAt(i)){ + // return i; + // } + // } + // } + // //If we broke out of the loop the first string is the common prefix + // return firstString.length(); + // } + + //Should this be in Util? + public List removeHeaders(List stringList){ + List headlessList = new ArrayList<>(); + for (String element : stringList){ + int lastIndex = element.lastIndexOf(":"); + headlessList.add(element.substring(lastIndex + 1)); + } + return headlessList; } - // may want to rethink this such that view prints representation of attribute on current node, - // or allow an int to be passed in as the index of the child whose attribute you'd like to print info for - public int viewSynth(DecoratedNode node, String attribute) - { + public void printAttrFromName(DecoratedNode node, String printAttribute){ + List attributeList = allAttributesList(node); RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - int index = 0; - if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ - index = nonterminalton.getSynOccursIndex(attribute); - }else{ - System.out.println("Bad input, legal inputs:"); - Set synAttrSet = nonterminalton.getAllSynth(); - System.out.println("Keys: " + synAttrSet); - return -1; + Map attributeMap = new HashMap<>(); + + for(String attribute : attributeList) + { + if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ + Integer index = nonterminalton.getSynOccursIndex(attribute); + Lazy synthAttribute = node.getNode().getSynthesized(index); + Object o = synthAttribute.eval(node); + attributeMap.put(attribute, o); + }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + Integer index = nonterminalton.getInhOccursIndex(attribute); + Object o = node.evalInhSomehowButPublic(index); + attributeMap.put(attribute, o); + }else{ //Should be local + List listLocals = listLocalAttrs(node); + Integer index = listLocals.indexOf(attribute); + Lazy localAttribute = node.getNode().getLocal(index); + Object o = localAttribute.eval(node); + attributeMap.put(attribute, o); + } } - Lazy synthAttribute = node.getNode().getSynthesized(index); - Object o = synthAttribute.eval(node); - System.out.println(Util.genericShow(o)); - return 1; + System.out.println(Util.genericShow(attributeMap.get(printAttribute))); } - public int viewInher(DecoratedNode node, String attribute) + //List of all and only local attributes + public List listLocalAttrs(DecoratedNode node) { - RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); - RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - int index = 0; - if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ - index = nonterminalton.getInhOccursIndex(attribute); - }else{ - System.out.println("Bad input, legal inputs:"); - Set inhAttrSet = nonterminalton.getAllInh(); - System.out.println("Keys: " + inhAttrSet); - return -1; + int count = node.getNode().getNumberOfLocalAttrs(); + List listLocals = new ArrayList<>(); + + for(int i = 0; i < count; i++) + { + Lazy attribute = node.getNode().getLocal(i); + Object o = attribute.eval(node); + listLocals.add(node.getNode().getNameOfLocalAttr(i)); } - Object o = node.evalInhSomehowButPublic(index); - System.out.println(Util.genericShow(o)); - return 1; + return listLocals; } + - public Integer printAttrFromName(DecoratedNode node, String attribute) + //Helper for printAttrFromName + public List allAttributesList(DecoratedNode node) { RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - int index = 0; - boolean isSynth = false; - if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ - index = nonterminalton.getSynOccursIndex(attribute); - isSynth = true; - }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ - index = nonterminalton.getInhOccursIndex(attribute); - }else{ - // System.out.println("Bad input, legal inputs:"); - // Set allInputs = new HashSet(); - // Set synAttrSet = nonterminalton.getAllSynth(); - // Set inhAttrSet = nonterminalton.getAllInh(); - // allInputs.addAll(synAttrSet); - // allInputs.addAll(inhAttrSet); - // System.out.println("Keys: " + allInputs); - return -1; - } - if(isSynth){ - Lazy synthAttribute = node.getNode().getSynthesized(index); - Object o = synthAttribute.eval(node); - System.out.println(Util.genericShow(o)); - }else{ - Object o = node.evalInhSomehowButPublic(index); - System.out.println(Util.genericShow(o)); - } - return 1; - } - - public void viewLocals(DecoratedNode node, int attribute) - { + List attributeList = nonterminalton.alphabeticalAttributes(); + List localAttributeList = listLocalAttrs(node); + + attributeList.addAll(localAttributeList); + attributeList.sort(null); + return attributeList; } - //TODO: Add to the other attributes - //TODO: Print alst if unique otherwise print entire - public void listLocalAttrs(DecoratedNode node) + // Another Helper Currently not used but might be important later + public Map allAttributesObjectMap(DecoratedNode node) { - // int count = node.getNode().getNumberOfLocalAttrs(); - // HashMap hash = new HashMap(); - // for(int i = 0; i < count; i++) - // { - // Lazy attribute = node.getNode().getLocal(i); - // // do whatever printing - // hash.put(i, new StringObjectPair(currentNode.getNameOfLocalAttr(i), currentNode.evalLocalDecorated(i))); - // System.out.println("Attribute = " + entry.getKey() + - // ", Index = " + entry.getValue()); - // } - // currentNodeLocalAttrs = hash; - - - - int count = node.getNode().getNumberOfLocalAttrs(); - //System.out.println("Attribute = " + Integer.toString(count)); + List attributeList = allAttributesList(node); + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + Map attributeMap = new HashMap<>(); - for(int i = 0; i < count; i++) + for(String attribute : attributeList) { - Lazy attribute = node.getNode().getLocal(i); - Object o = attribute.eval(node); - // System.out.println(); - System.out.println("Attribute = " + node.getNode().getNameOfLocalAttr(i) + - "\nValue = " + Util.genericShow(o)); + if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ + //System.out.println("Synthisized!!!"); + Integer index = nonterminalton.getSynOccursIndex(attribute); + Lazy synthAttribute = node.getNode().getSynthesized(index); + Object o = synthAttribute.eval(node); + attributeMap.put(attribute, o); + }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + //System.out.println("Inherited!!!"); + Integer index = nonterminalton.getInhOccursIndex(attribute); + Object o = node.evalInhSomehowButPublic(index); + attributeMap.put(attribute, o); + }else{ //Should be local + //System.out.println("local!!!"); + List listLocals = listLocalAttrs(node); + Integer index = listLocals.indexOf(attribute); + Lazy localAttribute = node.getNode().getLocal(index); + Object o = localAttribute.eval(node); + attributeMap.put(attribute, o); + } } + return attributeMap; } public boolean isContractum(DecoratedNode node) diff --git a/runtime/java/src/common/RTTIManager.java b/runtime/java/src/common/RTTIManager.java index c7e605eaf..c6ab44915 100644 --- a/runtime/java/src/common/RTTIManager.java +++ b/runtime/java/src/common/RTTIManager.java @@ -141,7 +141,7 @@ public Set getAllSynth() { return synOccursIndices.keySet(); } - public List alhpabeticalAttributes() { + public List alphabeticalAttributes() { Set allAttributesSet = new HashSet<>(); allAttributesSet.addAll(inhOccursIndices.keySet()); allAttributesSet.addAll(synOccursIndices.keySet()); From 087c0394c9dbf9bad8f25f7adc03e4460a5c3fa8 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 22 Feb 2024 16:25:13 -0600 Subject: [PATCH 10/64] Indent for user input, forwarding/bactraking is tested and attribute object map is its own function --- runtime/java/src/common/Debug.java | 47 +++++++++++++----------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 5d6b25f59..c16b86165 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -1,4 +1,5 @@ //TODO: Error handling is not good right now +//Thing to remeber: ./silver_compile --forced-origins --clean package common; @@ -43,7 +44,9 @@ public void runingDebug(DecoratedNode tree) { } //Control loop + //TODO: Horizontal seperator between user inut and $ for inputs loop: do { + System.out.print(" $"); userInput = inp.nextLine(); userInputList = userInput.split(" "); @@ -76,6 +79,7 @@ public void runingDebug(DecoratedNode tree) { //System.out.println("invalid, correct usage: down "); System.out.println("Which child?"); printChildren(currentNode); + System.out.print(" $"); childNum = inp.nextInt(); inp.nextLine(); }else{ @@ -115,7 +119,7 @@ public void runingDebug(DecoratedNode tree) { } break; - //TODO: Untested, find good test case + //TODO: Works but known bug view is weird a forward nodes case "forwards": if (userInputList.length != 1) { System.out.println("invalid, correct usage: forwards<>"); @@ -244,7 +248,8 @@ public void runingDebug(DecoratedNode tree) { List attributeList = allAttributesList(currentNode); if (userInputList.length != 2) { System.out.println("Which attribute?"); - printAttributes(currentNode, toggleHeadlessAttributes); + printAttributes(currentNode, toggleHeadlessAttributes); + System.out.print(" $"); attributeNum = inp.nextInt(); inp.nextLine(); attributeName = attributeList.get(attributeNum); @@ -409,48 +414,29 @@ public void printAttributes(DecoratedNode node, boolean toggleHeadlessAttributes attributeList = removeHeaders(allAttributesList(node)); } int i = 0; - //int prefixLength = commonPrefixLength(attributeList); for (String attribute : attributeList) { - //String attributeNoPrefix = attribute.substring(prefixLength); System.out.println(Integer.toString(i) + ": " + attribute); i++; } } - //Should this be in Util? -- Also probably no what we want thinking about it a bit more - // public int commonPrefixLength(List stringList){ - // String firstString = stringList.get(0); - - // //i is the prefix lenght we are testing - // for (int i = 0; i < firstString.length(); i++) { - // //look at all the strings and make sure they are all identical to the first at index i - // for (String element : stringList){ - // //If any sting is shorter than we are done - // if (element.length() < i){ - // return i; - // }//If any string is not equal to the first we are done - // else if(element.charAt(i) != firstString.charAt(i)){ - // return i; - // } - // } - // } - // //If we broke out of the loop the first string is the common prefix - // return firstString.length(); - // } - //Should this be in Util? public List removeHeaders(List stringList){ List headlessList = new ArrayList<>(); for (String element : stringList){ int lastIndex = element.lastIndexOf(":"); - headlessList.add(element.substring(lastIndex + 1)); + if(lastIndex == -1){ + headlessList.add(element); + }else{ + headlessList.add(element.substring(lastIndex + 1)); + } } return headlessList; } - public void printAttrFromName(DecoratedNode node, String printAttribute){ + public Map attriburteNameObjectMap(DecoratedNode node){ List attributeList = allAttributesList(node); RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); @@ -475,6 +461,11 @@ public void printAttrFromName(DecoratedNode node, String printAttribute){ attributeMap.put(attribute, o); } } + return attributeMap; + } + + public void printAttrFromName(DecoratedNode node, String printAttribute){ + Map attributeMap = attriburteNameObjectMap(node); System.out.println(Util.genericShow(attributeMap.get(printAttribute))); } @@ -492,6 +483,8 @@ public List listLocalAttrs(DecoratedNode node) } return listLocals; } + + //TODO: Add access to higher order attriburte //Helper for printAttrFromName From ad9d0f4cd15228b5d4beddda4646589e57a43b83 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Thu, 22 Feb 2024 17:20:08 -0600 Subject: [PATCH 11/64] first version of contextualization. Origin tracking needs to be done for is-new label only --- .../src/common/CMDContextVisualization.java | 52 ++ runtime/java/src/common/ContextStack.java | 28 + .../java/src/common/ContextVisualization.java | 38 ++ runtime/java/src/common/Debug.java | 34 +- runtime/java/src/common/Debug.java.my | 574 ++++++++++++++++++ runtime/java/src/common/DecoratedNode.java | 250 +++++--- .../src/common/FileContextVisualization.java | 30 + runtime/java/src/common/FileCoordinate.java | 63 ++ runtime/java/src/common/FileRange.java | 87 +++ .../src/common/HTMLContextVisualization.java | 39 ++ .../java/src/common/NodeContextMessage.java | 99 ++- 11 files changed, 1147 insertions(+), 147 deletions(-) create mode 100644 runtime/java/src/common/CMDContextVisualization.java create mode 100644 runtime/java/src/common/ContextVisualization.java create mode 100644 runtime/java/src/common/Debug.java.my create mode 100644 runtime/java/src/common/FileContextVisualization.java create mode 100644 runtime/java/src/common/FileCoordinate.java create mode 100644 runtime/java/src/common/FileRange.java create mode 100644 runtime/java/src/common/HTMLContextVisualization.java diff --git a/runtime/java/src/common/CMDContextVisualization.java b/runtime/java/src/common/CMDContextVisualization.java new file mode 100644 index 000000000..9e0c5acc0 --- /dev/null +++ b/runtime/java/src/common/CMDContextVisualization.java @@ -0,0 +1,52 @@ +package common; + +import java.util.Iterator; + +public class CMDContextVisualization extends ContextVisualization { + private final String printFormat = "%s\n%s\n%s\n"; + private String border; + + public CMDContextVisualization(String border) { + super(); + + this.border = border; + } + + @Override + public void show() { + // for(NodeContextMessage nodeContextMessage : this.contextStack.iterator()) { + // System.out.printf(this.printFormat, this.border, nodeContextMessage.toString(), this.border); + // } + + Iterator iterator = this.contextStack.iterator(); + while (iterator.hasNext()) { + NodeContextMessage nodeContextMessage = iterator.next(); + System.out.printf(this.printFormat, this.border, nodeContextMessage.toString(), this.border); + } + } +} + + +// public class CMDContextVisualization extends ContextVisualization { +// private final String printFormat = "%s\n%s\n%s\n"; +// private String border; + +// public CMDContextVisualization(String border) { +// super(); + +// this.border = border; +// } + +// @Override +// public void show() { +// // for(NodeContextMessage nodeContextMessage : this.contextStack.iterator()) { +// // System.out.printf(this.printFormat, this.border, nodeContextMessage.toString(), this.border); +// // } + +// Iterator iterator = this.contextStack.iterator(); +// while (iterator.hasNext()) { +// Integer nodeContextMessage = iterator.next(); +// System.out.printf(this.printFormat, this.border, nodeContextMessage.toString(), this.border); +// } +// } +// } \ No newline at end of file diff --git a/runtime/java/src/common/ContextStack.java b/runtime/java/src/common/ContextStack.java index 78d9dd75f..fb0f373a5 100644 --- a/runtime/java/src/common/ContextStack.java +++ b/runtime/java/src/common/ContextStack.java @@ -34,3 +34,31 @@ public Iterator iterator() { private Stack stack = new Stack(); private int height = 0; } + +// public class ContextStack { + +// public void push(Integer n) { +// this.height++; +// this.stack.push(n); +// } + +// public Integer pop() { +// this.height--; +// return this.stack.pop(); +// } + +// public Integer peak() { +// return this.stack.peek(); +// } + +// public int get_height() { +// return this.height; +// } + +// public Iterator iterator() { +// return this.stack.iterator(); +// } + +// private Stack stack = new Stack(); +// private int height = 0; +// } diff --git a/runtime/java/src/common/ContextVisualization.java b/runtime/java/src/common/ContextVisualization.java new file mode 100644 index 000000000..931286088 --- /dev/null +++ b/runtime/java/src/common/ContextVisualization.java @@ -0,0 +1,38 @@ +package common; + +public abstract class ContextVisualization { + protected ContextStack contextStack; + + public ContextVisualization() { + this.contextStack = new ContextStack(); + } + + public void push(DecoratedNode decoratedNode) { + this.contextStack.push(decoratedNode); + } + + public NodeContextMessage pop() { + return this.contextStack.pop(); + } + + public abstract void show(); +} + + +// public abstract class ContextVisualization { +// protected ContextStack contextStack; + +// public ContextVisualization() { +// this.contextStack = new ContextStack(); +// } + +// public void push(Integer decoratedNode) { +// this.contextStack.push(decoratedNode); +// } + +// public Integer pop() { +// return this.contextStack.pop(); +// } + +// public abstract void show(); +// } diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index c16b86165..d0d1993ec 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -43,6 +43,15 @@ public void runingDebug(DecoratedNode tree) { printProduction(currentNode); } + // creating a context stack when we run the debugger + CMDContextVisualization cStack = new CMDContextVisualization("********************************"); + // if we want a file visualization: + // FileContextVisualization cStack = new FileContextVisualization(); + // if we want an HTML visualization: + // HTMLContextVisualization cStack = new HTMLContextVisualization(); + cStack.push(currentNode); + cStack.show(); + //Control loop //TODO: Horizontal seperator between user inut and $ for inputs loop: do { @@ -69,6 +78,10 @@ public void runingDebug(DecoratedNode tree) { if(toggleProdDisplay){ printProduction(currentNode); } + // if we navigate up to a parent, push it on to the stack (?) + cStack.pop(); + // when we push, update and show the context + cStack.show(); } } break; @@ -98,6 +111,10 @@ public void runingDebug(DecoratedNode tree) { if(toggleProdDisplay){ printProduction(currentNode); } + // if we navigate down to a child, push it on to the stack + cStack.push(currentNode); + // when we push, update and show the context + cStack.show(); } break; @@ -115,6 +132,9 @@ public void runingDebug(DecoratedNode tree) { if(toggleProdDisplay){ printProduction(currentNode); } + // remove from the stack + cStack.pop(); + cStack.show(); } } break; @@ -134,6 +154,10 @@ public void runingDebug(DecoratedNode tree) { if(toggleProdDisplay){ printProduction(currentNode); } + // if we navigate to a forward, push it on to the stack + cStack.push(currentNode); + // when we push, update and show the context + cStack.show(); } } break; @@ -153,6 +177,10 @@ public void runingDebug(DecoratedNode tree) { if(toggleProdDisplay){ printProduction(currentNode); } + // if we navigate backwards, push it on to the stack (?) + cStack.push(currentNode); + // when we push, update and show the context + cStack.show(); } } break; @@ -470,7 +498,7 @@ public void printAttrFromName(DecoratedNode node, String printAttribute){ } //List of all and only local attributes - public List listLocalAttrs(DecoratedNode node) + public static List listLocalAttrs(DecoratedNode node) { int count = node.getNode().getNumberOfLocalAttrs(); List listLocals = new ArrayList<>(); @@ -488,7 +516,7 @@ public List listLocalAttrs(DecoratedNode node) //Helper for printAttrFromName - public List allAttributesList(DecoratedNode node) + public static List allAttributesList(DecoratedNode node) { RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); @@ -502,7 +530,7 @@ public List allAttributesList(DecoratedNode node) } // Another Helper Currently not used but might be important later - public Map allAttributesObjectMap(DecoratedNode node) + public static Map allAttributesObjectMap(DecoratedNode node) { List attributeList = allAttributesList(node); RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); diff --git a/runtime/java/src/common/Debug.java.my b/runtime/java/src/common/Debug.java.my new file mode 100644 index 000000000..1f63016d6 --- /dev/null +++ b/runtime/java/src/common/Debug.java.my @@ -0,0 +1,574 @@ +//TODO: Error handling is not good right now + +package common; + +import java.util.HashMap; +import java.util.Map; +import java.util.Scanner; +import java.util.HashSet; +import java.util.Set; +import java.util.Stack; +import java.util.ArrayList; +import java.util.List; + + +import common.Util.*; + +import org.w3c.dom.Node; + +import common.RTTIManager.Nonterminalton; + +public class Debug { + public static DecoratedNode runDebug(DecoratedNode tree) + { + Debug debug = new Debug(); + debug.runingDebug(tree); + return tree; + } + + public void runingDebug(DecoratedNode tree) { + Scanner inp = new Scanner(System.in); + System.out.println("Enter characters, and 'q' to quit."); + String userInput; + String[] userInputList; + boolean toggleProdDisplay = true; + DecoratedNode childNode; + this.root = tree; + this.currentNode = tree; + this.nodeStack = new Stack(); + + if(toggleProdDisplay){ + printProduction(currentNode); + } + + // creating a context stack when we run the debugger + // CMDContextVisualization cStack = new CMDContextVisualization("****************"); + // // if we want a file visualization: + // // FileContextVisualization cStack = new FileContextVisualization(); + // // if we want an HTML visualization: + // // HTMLContextVisualization cStack = new HTMLContextVisualization(); + // cStack.push(currentNode); + // cStack.show(); + + //Control loop + loop: do { + userInput = inp.nextLine(); + userInputList = userInput.split(" "); + + //Each case has a set of conditionals to make everything is in order befor running + //in the final case they call a helper function that does most of the work + switch (userInputList[0]) { + + case "up": case "u": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: up<>"); + }else{ + if (currentNode.getParent().getParent() instanceof TopNode || currentNode.getParent() == null){ + System.out.println("Root Node has no parent"); + }else if (currentNode.getParent() == null){ + System.out.println("Null parent"); + }else{ + nodeStack.push(currentNode); + currentNode = currentNode.getParent(); + //System.out.println("going to parent"); + if(toggleProdDisplay){ + printProduction(currentNode); + } + // if we navigate up to a parent, push it on to the stack (?) + // cStack.pop(); + // when we push, update and show the context + // cStack.show(); + } + } + break; + + case "down": case "d": + int childNum = 0; + if (userInputList.length != 2) { + //System.out.println("invalid, correct usage: down "); + System.out.println("Which child?"); + printChildren(currentNode); + childNum = inp.nextInt(); + inp.nextLine(); + }else{ + //Explodes if the input is not a integer should gracefully exit + childNum = Integer.parseInt(userInputList[1]); + } + + childNode = down(childNum); + if(childNode == null){ + System.out.println("invalid child number"); + } + else{ + nodeStack.push(currentNode); + currentNode = childNode; + //System.out.println("going down"); + if(toggleProdDisplay){ + printProduction(currentNode); + } + // if we navigate down to a child, push it on to the stack + // cStack.push(currentNode); + // when we push, update and show the context + // cStack.show(); + } + break; + + case "undo": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: undo<>"); + }else{ + if(nodeStack.empty()){ + System.out.println("invalid no node to undo"); + } + else{ + DecoratedNode newNode = nodeStack.pop(); + currentNode = newNode; + //System.out.println("undoing last movement"); + if(toggleProdDisplay){ + printProduction(currentNode); + } + // remove from the stack + // cStack.pop(); + // cStack.show(); + } + } + break; + + //TODO: Untested, find good test case + case "forwards": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: forwards<>"); + }else{ + childNode = forwards(currentNode); + if(childNode == null){ + System.out.println("invalid no node to forward"); + } + else{ + System.out.println("going forward"); + currentNode = childNode; + if(toggleProdDisplay){ + printProduction(currentNode); + } + // if we navigate to a forward, push it on to the stack + // cStack.push(currentNode); + // when we push, update and show the context + // cStack.show(); + } + } + break; + + //TODO: Untested, find good test case + case "backtrack": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: backtrack<>"); + }else{ + childNode = backtrack(currentNode); + if(childNode == null){ + System.out.println("invalid no node to backtrack to"); + } + else{ + System.out.println("going backwrds"); + currentNode = childNode; + if(toggleProdDisplay){ + printProduction(currentNode); + } + // if we navigate backwards, push it on to the stack (?) + // cStack.push(currentNode); + // when we push, update and show the context + // cStack.show(); + } + } + break; + + case "toggle": + if (userInputList.length != 2) { + System.out.println("please indicate what you want to toggle ex: 'toggle prodDisplay'"); + }else{ + if(userInputList[1].equals("prodDisplay")){ + if(toggleProdDisplay){ + System.out.println("Production Display off"); + toggleProdDisplay = false; + }else{ + System.out.println("Production Display on"); + toggleProdDisplay = true; + } + } + else{ + System.out.println("legal toggles: prodDisplay"); + System.out.println(userInputList[1]); + } + } + break; + + + //Display the production + case "prod": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: prod<>"); + }else{ + printProduction(currentNode); + } + break; + + //TODO:Implement this - use genericShow + case "eq": + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: eq"); + }else{ + System.out.println("do the eq stuff"); + + } + break; + + //List synthesized attributes + case "listSynth": + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: listSynth"); + }else{ + if(listSynth(currentNode) == 0){ + System.out.println("no synthesized attributes"); + } + } + break; + + //List inherited attributes + case "listInher": + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: listInher"); + }else{ + if(listInher(currentNode) == 0){ + System.out.println("no inherited attributes"); + } + } + break; + + //list all attributes + case "list": case "l": + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: list"); + }else{ + // if(listSynth(currentNode) + listInher(currentNode) == 0){ + // System.out.println("no attributes"); + // } + printAttributes(currentNode); + } + break; + + //Show the values of a specific attribute + + //Clear the prefix that is identical + //Print names of children not just types + case "view": case "v": + String attributeName = ""; + Integer attributeNum = 0; + if (userInputList.length != 2) { + System.out.println("Which attribute?"); + printAttributes(currentNode); + attributeNum = inp.nextInt(); + inp.nextLine(); + attributeName = getAttributeNameFromNum(currentNode, attributeNum); + }else{ + //Explodes if the input is not a integer should gracefully exit + attributeNum = Integer.parseInt(userInputList[1]); + attributeName = getAttributeNameFromNum(currentNode, attributeNum); + } + printAttrFromName(currentNode, attributeName); + break; + + case "local": + listLocalAttrs(currentNode); + break; + + case "help": + System.out.println("up"); + System.out.println("down "); + System.out.println("view "); + System.out.println("forwards"); + System.out.println("backtrack"); + System.out.println("prod"); + System.out.println("eq"); + System.out.println("listSynth"); + System.out.println("listInher"); + System.out.println("list"); + System.out.println("exit"); + break; + + //Many ways to leave + case "exit": + case "q": + case "quit": + System.out.println("debugger out"); + break loop; + default: + System.out.println("invalid input call help for legal inputs"); + System.out.println(userInput); + break; + } + } while(true); + } + private DecoratedNode root; + private DecoratedNode currentNode; + private Stack nodeStack; + HashMap currentNodeSynthAttrs; + HashMap currentNodeInhAttrs; + HashMap currentNodeLocalAttrs; + private int currentLine; + private int currentColumn; + + public void setCurrentNode(DecoratedNode node) + { + currentNodeSynthAttrs = null; + currentNodeInhAttrs = null; + currentNodeLocalAttrs = null; + currentNode = node; + } + + public DecoratedNode up() + { + if (currentNode.getParent() != null) + { + currentNode = (DecoratedNode) currentNode.getParent(); + return currentNode; + } + return null; + } + + public DecoratedNode down(int child) + { + if (currentNode.getNode().getNumberOfChildren() > child) + { + DecoratedNode childNode = currentNode.childDecorated(child); + return childNode; + } + return null; + } + + public void printChildren(DecoratedNode node) + { + String child_productions[] = node.undecorate().getProdleton().getChildTypes(); + for (int i = 0; i < child_productions.length; i++){ + System.out.println(Integer.toString(i) + ": " + child_productions[i] + " "); + } + } + + public DecoratedNode forwards(DecoratedNode node) + { + if (node.getNode().hasForward()){ + currentNode = node.forward(); + return currentNode; + } + return null; + } + public DecoratedNode backtrack(DecoratedNode node) + { + currentNode = node.getForwardParent(); + return currentNode; + + } + + public void printProduction(DecoratedNode node) + { + String partent_production = node.undecorate().getProdleton().getName(); + String child_productions[] = node.undecorate().getProdleton().getChildTypes(); + System.out.print(partent_production + " "); + for (int i = 0; i < child_productions.length; i++){ + System.out.print(child_productions[i] + " "); + } + System.out.print("\n"); + } + + // Prints out the equation of the specified attr. + // If attr is not specified, prints out the equations for all the attributes on the current node. + // via eric we can just add equations as an attribute within our AG + public void eqSynth(int attribute) + { + + } + + public void eqInher(int attribute) + { + + } + + // no optional params in java, could use overloading or just pass in null + public int listSynth(DecoratedNode node) + { + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + Set synAttrSet = nonterminalton.getAllSynth(); + int num_attr = 0; + + for (String synAttr : synAttrSet) + { + System.out.println("Attribute = " + synAttr); + num_attr++; + } + return num_attr; + } + + public int listInher(DecoratedNode node) + { + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + Set inhAttrSet = nonterminalton.getAllInh(); + int num_attr = 0; + + for (String inhAttr : inhAttrSet) + { + System.out.println("Attribute = " + inhAttr); + num_attr++; + } + return num_attr; + } + + public void printAttributes(DecoratedNode node){ + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + List attributeList = nonterminalton.alhpabeticalAttributes(); + int i = 0; + + for (String attribute : attributeList) + { + System.out.println(Integer.toString(i) + ": " + attribute); + i++; + } + } + + public String getAttributeNameFromNum(DecoratedNode node, Integer attributeNum){ + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + List attributeList = nonterminalton.alhpabeticalAttributes(); + + return attributeList.get(attributeNum); + } + + // may want to rethink this such that view prints representation of attribute on current node, + // or allow an int to be passed in as the index of the child whose attribute you'd like to print info for + public int viewSynth(DecoratedNode node, String attribute) + { + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + int index = 0; + if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ + index = nonterminalton.getSynOccursIndex(attribute); + }else{ + System.out.println("Bad input, legal inputs:"); + Set synAttrSet = nonterminalton.getAllSynth(); + System.out.println("Keys: " + synAttrSet); + return -1; + } + Lazy synthAttribute = node.getNode().getSynthesized(index); + Object o = synthAttribute.eval(node); + System.out.println(Util.genericShow(o)); + return 1; + } + + public int viewInher(DecoratedNode node, String attribute) + { + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + int index = 0; + if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + index = nonterminalton.getInhOccursIndex(attribute); + }else{ + System.out.println("Bad input, legal inputs:"); + Set inhAttrSet = nonterminalton.getAllInh(); + System.out.println("Keys: " + inhAttrSet); + return -1; + } + Object o = node.evalInhSomehowButPublic(index); + System.out.println(Util.genericShow(o)); + return 1; + } + + public Integer printAttrFromName(DecoratedNode node, String attribute) + { + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + int index = 0; + boolean isSynth = false; + if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ + index = nonterminalton.getSynOccursIndex(attribute); + isSynth = true; + }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + index = nonterminalton.getInhOccursIndex(attribute); + }else{ + // System.out.println("Bad input, legal inputs:"); + // Set allInputs = new HashSet(); + // Set synAttrSet = nonterminalton.getAllSynth(); + // Set inhAttrSet = nonterminalton.getAllInh(); + // allInputs.addAll(synAttrSet); + // allInputs.addAll(inhAttrSet); + // System.out.println("Keys: " + allInputs); + return -1; + } + if(isSynth){ + Lazy synthAttribute = node.getNode().getSynthesized(index); + Object o = synthAttribute.eval(node); + System.out.println(Util.genericShow(o)); + }else{ + Object o = node.evalInhSomehowButPublic(index); + System.out.println(Util.genericShow(o)); + } + return 1; + } + + public void viewLocals(DecoratedNode node, int attribute) + { + + } + + //TODO: Add to the other attributes + //TODO: Print alst if unique otherwise print entire + public void listLocalAttrs(DecoratedNode node) + { + // int count = node.getNode().getNumberOfLocalAttrs(); + // HashMap hash = new HashMap(); + // for(int i = 0; i < count; i++) + // { + // Lazy attribute = node.getNode().getLocal(i); + // // do whatever printing + // hash.put(i, new StringObjectPair(currentNode.getNameOfLocalAttr(i), currentNode.evalLocalDecorated(i))); + // System.out.println("Attribute = " + entry.getKey() + + // ", Index = " + entry.getValue()); + // } + // currentNodeLocalAttrs = hash; + + + + int count = node.getNode().getNumberOfLocalAttrs(); + //System.out.println("Attribute = " + Integer.toString(count)); + + for(int i = 0; i < count; i++) + { + Lazy attribute = node.getNode().getLocal(i); + Object o = attribute.eval(node); + // System.out.println(); + System.out.println("Attribute = " + node.getNode().getNameOfLocalAttr(i) + + "\nValue = " + Util.genericShow(o)); + } + } + + public boolean isContractum(DecoratedNode node) + { + return node.getNode().hasForward(); + } + + public static class StringObjectPair { + private String stringValue; + private Object objectValue; + + public StringObjectPair(String stringValue, Object objectValue) { + this.stringValue = stringValue; + this.objectValue = objectValue; + } + + public String getString() { + return stringValue; + } + + public Object getObject() { + return objectValue; + } + } +} \ No newline at end of file diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 423295bd8..bfd8c76a6 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -1,6 +1,13 @@ package common; import java.util.Arrays; +import java.util.Collection; +import java.util.Map; + +import silver.core.NOriginInfo; +// import silver.core.OriginsUtils; +import silver.core.PoriginOriginInfo; +import silver.core.PoriginAndRedexOriginInfo; import common.exceptions.MissingDefinitionException; import common.exceptions.SilverException; @@ -855,10 +862,9 @@ public final Object evalInhSomehowButPublic(final int attribute) { else return evalInhViaFwdP(attribute); } -} - // ************************************************************** + // ************************************************************** // Functions and attributes added for context message support // To add: @@ -873,17 +879,19 @@ public final Object evalInhSomehowButPublic(final int attribute) { // getEndCoordinates() DONE // getOrigin() DONE - // getIsNew() DONE + // getIsNew() TODO // getPrettyPrint() DONE // getIsAttribute() SORT-OF-DONE + + // getIsTranslation() SORT-OF-DONE private int debugging_index; private boolean is_redex; private boolean is_contractum; - private boolean is_attribute; - private boolean need_set_is_attribute = true; + private boolean is_attribute_root; + private boolean need_set_is_attribute_root = true; private boolean need_compute_redex_contractum = true; @@ -926,7 +934,7 @@ private void compute_redex_contractum() { this.is_redex = false; } - if (this.forwardParent) { + if (this.forwardParent != null) { this.is_contractum = true; } else { @@ -975,54 +983,86 @@ private DecoratedNode getContractumHelper(DecoratedNode dn) { } } - public String getFilename() { - if (this.self == null) { - return ""; - } - else if (this.self instanceof silver.core.Alocation) { - DecoratedNode loc = ((silver.core.Alocation)self).getAnno_silver_core_location().decorate(TopNode.singleton, (Lazy[])null); + public String getFilename() { + + boolean res = this.self instanceof silver.core.Alocation; + // System.out.println("IS ALOCATION? " + res); + res = this.self instanceof Tracked; + // System.out.println("IS TRACKED? " + res); + + if(self == null) { + return ""; + } + NLocation loc = null; + if(self instanceof silver.core.Alocation) { + loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); + } else if(self instanceof Tracked) { + NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); + if(maybeLoc instanceof silver.core.Pjust) { + loc = (silver.core.NLocation)maybeLoc.getChild(0); + } + } + if(loc != null) { String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); return file; - } else { - return ""; } + + return ""; + } public FileCoordinate getStartCoordinates() { - if (this.self == null) { - return null; - } - else if (this.self instanceof silver.core.Alocation) { - DecoratedNode loc = ((silver.core.Alocation)self).getAnno_silver_core_location().decorate(TopNode.singleton, (Lazy[])null); + + if(self == null) { + return new FileCoordinate(-2, -2); + } + NLocation loc = null; + if(self instanceof silver.core.Alocation) { + loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); + } else if(self instanceof Tracked) { + NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); + if(maybeLoc instanceof silver.core.Pjust) { + loc = (silver.core.NLocation)maybeLoc.getChild(0); + } + } + if(loc != null) { int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); int col = (Integer)loc.synthesized(silver.core.Init.silver_core_column__ON__silver_core_Location); return new FileCoordinate(line, col); - } - else { - return null; } + + return new FileCoordinate(-1, -1); } public FileCoordinate getEndCoordinates() { - if (this.self == null) { - return null; - } - else if (this.self instanceof silver.core.Alocation) { - DecoratedNode loc = ((silver.core.Alocation)self).getAnno_silver_core_location().decorate(TopNode.singleton, (Lazy[])null); + + if(self == null) { + return new FileCoordinate(-2, -2); + } + NLocation loc = null; + if(self instanceof silver.core.Alocation) { + loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); + } else if(self instanceof Tracked) { + NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); + if(maybeLoc instanceof silver.core.Pjust) { + loc = (silver.core.NLocation)maybeLoc.getChild(0); + } + } + if(loc != null) { int line = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); int col = (Integer)loc.synthesized(silver.core.Init.silver_core_endColumn__ON__silver_core_Location); return new FileCoordinate(line, col); - } - else { - return null; } + + return new FileCoordinate(-1, -1); } - // Wrapper around OriginUtils.getOriginOrNull() + // Wrapper around OriginsUtil.getOriginOrNull() // for the sake of my naming convention // Not yet used but probably need for reference attributes public NOriginInfo getOrigin() { - return OriginUtils.getOriginOrNull(this); + // return OriginsUtil.getOriginOrNull(this); + return null; } // If not a contractum or redex, @@ -1040,7 +1080,8 @@ public boolean getIsNew() { // or PoriginAndRedexOriginInfo, if it is then // pull out the first child and do .getName() on that" - NOriginInfo oinfo = OriginUtils.getOriginOrNull(this); + NOriginInfo oinfo = OriginsUtil.getOriginOrNull(this.self); + // System.out.println("NOriginInfo: " + oinfo); if (oinfo == null) { return false; } @@ -1049,21 +1090,21 @@ public boolean getIsNew() { // Might need check types here // Should get only Nodes from here - Object origin = (Object)oinfo.getChild_origin(); - // I don't know if this is will be a Node or DecoratedNode yet - String child_prod_name = ""; - if (origin instanceof Node) { - child_prod_name = origin.getName(); - } - // Not going to be a DecoratedNode - else if (origin instanceof DecoratedNode) { - child_prod_name = origin.getNode().getName(); - } - else { - System.err.println("ERROR. origin not Node nor DecoratedNode"); - } - // New if different production only - return !child_prod_name.equals(this.self.getName()); + // Object origin = oinfo.getChild_origin(); + // // I don't know if this is will be a Node or DecoratedNode yet + // String child_prod_name = ""; + // if (origin instanceof Node) { + // child_prod_name = origin.getName(); + // } + // // Not going to be a DecoratedNode + // else if (origin instanceof DecoratedNode) { + // child_prod_name = origin.getNode().getName(); + // } + // else { + // System.err.println("ERROR. origin not Node nor DecoratedNode"); + // } + // // New if different production only + // return !child_prod_name.equals(this.self.getName()); } return false; } @@ -1074,62 +1115,87 @@ else if (origin instanceof DecoratedNode) { public String getPrettyPrint() { // use genericShow(): it accesses pp if it exists - return this.genericShow().toString(); + // return Util.genericShow(this).toString(); - // int num_attrs = this.self.getNumberOfSynAttrs(); - // for (int i = 0; i < num_attrs; i++) { + int num_attrs = this.self.getNumberOfSynAttrs(); + for (int i = 0; i < num_attrs; i++) { - // // Search until find name that is "pp" - // String name = this.self.getNameOfSynAttr(i); - // if (name.equals("pp")) { - // Lazy l_pp = this.self.getSynthesized(i); - // Object pp = evalSyn(l_pp); - // assert(l_pp != null) - // assert(pp instanceof String) - // return (String)pp; - // } - // } - // System.err.println("No pretty print (pp) attribute defined"); - // return "" + // Search until find name that is "pp" + String name = this.self.getNameOfSynAttr(i); + // Want last three characters to be ":pp" + if (name.substring(name.length() - 3).equals(":pp")) { + Object pp = evalSyn(i); + return pp.toString(); + } + } + System.err.println("No pretty print (pp) attribute defined"); + return ""; } - // only set is_attribute once - public boolean getIsAttribute() { - if (this.need_set_is_attribute) { - this.setIsAttribute(); - this.need_set_is_attribute = false; + // only set is_attribute_root once + public boolean getIsAttributeRoot() { + if (this.need_set_is_attribute_root) { + this.setIsAttributeRoot(); + this.need_set_is_attribute_root = false; + } + return this.is_attribute_root; + } + + + + public int getIsAttribute() { + if (this.isRoot()) { + return 0; + } + else { + if (this.getIsAttributeRoot()) { + return 1 + this.parent.getIsAttribute(); + } + return this.parent.getIsAttribute(); } - return this.is_attribute; } // For now, assume there is a Silver annotation - // "is-attribute" of type String on + // "is-attribute-root" of type String on // higher-order attributes that is set to "TRUE" // when true and not existant or FALSE when false // https://melt.cs.umn.edu/silver/ref/decl/annotations/ - public void setIsAttribute() { - // Just walk through children of parent. .child() give you decorated node or something else - // just do == comparison. If same object, then child and not local higher-order attribute - - // if (this.need_set_is_attribute) { - // Object o = this.self.getAnno("is-attribute"); - // if (o) { - // String s = (String)o; - // if (s.equals("TRUE")) { - // this.is_attribute = true; - // return; - // } - // } - // this.is_attribute = false; - // } + - for (int i = 0; i < this.parent.childrenValues.length, i++) { - DecoratedNode dn = this.parent.childDecorated(i); - if (dn == this) { - return false; + public boolean isRoot() { + return this.getNode().getName().contains("root"); + } + + public void setIsAttributeRoot() { + + if (! this.isRoot()) { + System.out.println("HERE!"); + Map map = Debug.allAttributesObjectMap(this.parent); + Collection values = map.values(); + for (Object obj: values) { + if (obj == this) { + this.is_attribute_root = true; + } } } - return true; + + this.is_attribute_root = false; } - -} \ No newline at end of file + + public int getIsTranslation() { + // See how many parents are contractums + if (this.isRoot()) { + return 0; + } + else if (this.getIsContractum()) { + return 1 + this.parent.getIsTranslation(); + } + else { + return this.parent.getIsTranslation(); + } + } +} + + + + \ No newline at end of file diff --git a/runtime/java/src/common/FileContextVisualization.java b/runtime/java/src/common/FileContextVisualization.java new file mode 100644 index 000000000..8970d254d --- /dev/null +++ b/runtime/java/src/common/FileContextVisualization.java @@ -0,0 +1,30 @@ +package common; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintStream; + +public class FileContextVisualization extends CMDContextVisualization { + protected final String filename; + + public FileContextVisualization(String filename, String border) { + super(border); + + this.filename = filename; + } + + @Override + public void show() { + File file = new File(this.filename); + + try(PrintStream replacementStream = new PrintStream(file)) { + System.setOut(replacementStream); + super.show(); + replacementStream.close(); + + System.setOut(System.out); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } +} diff --git a/runtime/java/src/common/FileCoordinate.java b/runtime/java/src/common/FileCoordinate.java new file mode 100644 index 000000000..6c941233e --- /dev/null +++ b/runtime/java/src/common/FileCoordinate.java @@ -0,0 +1,63 @@ +//package agnosis-context.libs.visualization; +package common; +import static java.lang.Math.max; + +/** + * A FileCoordinate object represents a coordinate in a file as a point (character) in a file + * specified by a row and a column. + */ +public class FileCoordinate { + private final int row, col; + + /** + * Constucts a FileCoordinate object with a row and column + * + * @param row the row of the coordinate + * @param col the column of the coordinate + */ + public FileCoordinate(int row, int col) { + if(row < 0 || col < 0) { + this.row = max(row, 0); + this.col = max(col, 0); + } else { + this.row = row; + this.col = col; + } + } + + /** + * Returns the row of the coordinate + * + * @return the row of the coordinate + */ + public int getRow() { + return row; + } + + /** + * Returns the column of the coordinate + * + * @return the column of the coordinate + */ + public int getCol() { + return col; + } + + @Override + public boolean equals(Object obj) { + if(this == obj) { + return true; + } else if(obj.getClass() != FileCoordinate.class) { + return false; + } + + FileCoordinate objFileCoordinate = (FileCoordinate) obj; + + return this.row == objFileCoordinate.row && this.col == objFileCoordinate.col; + } + + @Override + public String toString() { + return String.format("(%d,%d)", this.row, this.col); + } +} diff --git a/runtime/java/src/common/FileRange.java b/runtime/java/src/common/FileRange.java new file mode 100644 index 000000000..ec21decaf --- /dev/null +++ b/runtime/java/src/common/FileRange.java @@ -0,0 +1,87 @@ +//package agnosis-context.libs.visualization; +package common; + +import static java.lang.Math.min; +import static java.lang.Math.max; + +/** + * A FileRange object represents a range of file coordinate between two FileCoordinate objects + */ +public class FileRange { + private final FileCoordinate coord1, coord2; + + /** + * Constructs a FileRange object with the bounds of two file coordinates. + * The file coordinates need not be supplied in a particular order. + * + * @param coord1 the first file coordinate bound + * @param coord2 the second file coordinate bound + */ + public FileRange(FileCoordinate coord1, FileCoordinate coord2) { + this.coord1 = coord1; + this.coord2 = coord2; + } + + /** + * Returns if the file range is contained inside of the file range represented + * by this object. + * + * @param range the range to be checked if it is contained + * @return if the range is contained in the range represented by this object + */ + public boolean contains(FileRange range) { + return this.contains(range.coord1) && this.contains(range.coord2); + } + + /** + * Returns if the file coordinate is contained inside of the file range represented + * by this object. + * + * @param coord the coordinate to be checked if it is contained + * @return if the coordinate is contained in the range represented by this object + */ + public boolean contains(FileCoordinate coord) { + FileCoordinate topLeft = this.getTopLeft(); + FileCoordinate bottomRight = this.getBottomRight(); + + if(coord.getRow() < topLeft.getRow() || coord.getRow() > bottomRight.getRow()) return false; + if(coord.getCol() < topLeft.getCol() || coord.getCol() > bottomRight.getCol()) return false; + + return true; + } + + /** + * Returns the file coordinate that represents the top left coordinate of the range. + * + * @return the file coordinate that represents the top left coordinate of the range + */ + public FileCoordinate getTopLeft() { + int row = min(coord1.getRow(), coord2.getRow()); + int col = min(coord1.getCol(), coord2.getCol()); + + if(coord1.getRow() == row && coord1.getCol() == col) return coord1; + if(coord2.getRow() == row && coord2.getCol() == col) return coord2; + + return new FileCoordinate(row, col); + } + + /** + * Returns the file coordinate that represents the bottom right coordinate of the range. + * + * @return the file coordinate that represents the bottom right coordinate of the range + */ + public FileCoordinate getBottomRight() { + int row = max(coord1.getRow(), coord2.getRow()); + int col = max(coord1.getCol(), coord2.getCol()); + + if(coord1.getRow() == row && coord1.getCol() == col) return coord1; + if(coord2.getRow() == row && coord2.getCol() == col) return coord2; + + return new FileCoordinate(row, col); + } + + @Override + public String toString() { + return String.format("%s -> %s", this.getTopLeft(), this.getBottomRight()); + } +} diff --git a/runtime/java/src/common/HTMLContextVisualization.java b/runtime/java/src/common/HTMLContextVisualization.java new file mode 100644 index 000000000..f97a6216a --- /dev/null +++ b/runtime/java/src/common/HTMLContextVisualization.java @@ -0,0 +1,39 @@ +package common; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Scanner; + +public class HTMLContextVisualization extends FileContextVisualization { + private final String documentFormat = "\n\n\nContext Visualization\n\n\n

%s

\n\n"; + + public HTMLContextVisualization(String filename, String border) { + super(filename, border); + } + + public HTMLContextVisualization(String border) { + super("context.html", border); + } + + @Override + public void show() { + super.show(); + + try { + String content = new Scanner(new File(this.filename)).useDelimiter("\\Z").next(); + + File file = new File(this.filename); + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + writer.write(String.format(this.documentFormat, content)); + + writer.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index 96a4c775f..28ec1483d 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -1,5 +1,9 @@ package common; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + // Context implementation. // Headers are either TRANSLATION (for contractum) or HIGHER-ORDER @@ -14,15 +18,15 @@ public String GetSection0() { public String GetSection1() { String res = ""; boolean first_set = false; - if (this.is_translation) { - res += "TRANSLATION"; + if (this.translation_x > 0) { + res += "TRANSLATION-" + this.translation_x; first_set = true; } - if (this.is_higher_order) { + if (this.higher_order_y > 0) { if (first_set) { res += " & "; } - res += "HIGHER-ORDER"; + res += "HIGHER-ORDER-" + this.higher_order_y; } return res; } @@ -51,8 +55,8 @@ public String GetSection4() { if (this.is_new) { res += "*is-new\n"; } - if (this.is_attribute) { - res += "*is-attribute\n"; + if (this.is_attribute_root) { + res += "*is-attribute_root\n"; } return res; } @@ -65,7 +69,7 @@ public NodeContextMessage(DecoratedNode node) { // Try to do all this within java given a node n // Section 2 - this.prod_name = node.getName(); + this.prod_name = node.getNode().getName(); this.fill_in_rows_and_cols(node); // Section 4 @@ -76,45 +80,29 @@ public NodeContextMessage(DecoratedNode node) { // Section 3. Determine file lines last // because they depend on computing boolean attributes - if (this.is_translation || this.is_higher_order || - this.is_attribute || this.is_contractum || this.is_new) { - this.text_repr = this.pretty_print(node); + if ((this.translation_x > 0) || (this.higher_order_y > 0) || + this.is_attribute_root || this.is_contractum || this.is_new) { + this.pretty_print(node); } else { - this.text_repr = this.pull_filelines(); + this.pull_filelines(); } this.has_been_initialized = true; } private void set_index() { - next_index = 0; - this.num_index = next++; + next_index++; + this.num_index = next_index; } - // Set is_higher_order and is_translation bools here + // Set translation_x and translation_x bools here // Is there a way to know something is an attribute // just from its node values? private void initialize_headers(DecoratedNode node) { - // Can figure out if translation is hasForward is true on self - // (Node of Decorated Node) - // This is used to set TRANSLATION header flag - if (node.getIsContractum()) { - // Only current way to determine if translation - this.is_translation = true; - } - else { - this.is_translation = false; - } - - // Trickier case is know if something is an attribute - // Rely on getter function that is to be added to Node. - // Basically if go "into" a node and not "down" as in a parent, - // want to set the is_attribute flag to TRUE. The getter - // returns true if the current DecoratedNode n is an attribute or - // if any parent was (recursively, until root was found) - this.is_higher_order = node.getIsAttribute(); + this.translation_x = node.getIsTranslation(); + this.higher_order_y = node.getIsAttribute(); } // Use file location method I wrote in DecoratedNode @@ -132,16 +120,16 @@ private void set_labels(DecoratedNode node) { this.is_redex = node.getIsRedex(); this.is_contractum = node.getIsContractum(); // Will always work for forwarding. Only use this value if is_contractum - this.contractum_of = node.getDebuggingIndex - 1; + this.contractum_of = node.getDebuggingIndex() - 1; this.is_new = node.getIsNew(); - this.is_attribute = node.getIsAttribute(); - this.attribute_of = node.getIsAttributeOf(); + this.is_attribute_root = node.getIsAttributeRoot(); + this.attribute_of = node.getDebuggingIndex() - 1; } // access pp attribute if present private void pretty_print(DecoratedNode node) { - this.pretty_print = node.getPrettyPrint(); + this.text_repr = node.getPrettyPrint(); } // probably need some file I/O, but might find it @@ -149,37 +137,44 @@ private void pretty_print(DecoratedNode node) { // from row x col y to row x' to y'. private void pull_filelines() { - // Currently not the most efficient but should get the job done for now + // Currently not the most efficient but should get the job done for now try (BufferedReader br = new BufferedReader(new FileReader(this.filename))) { - int row = 0; - int col = 0; + int row = 1; + int col = 1; String res = ""; - while (row < this.fc_start.getRow()) { + for (; row < this.fc_start.getRow(); row++) { + // System.out.println("skipping row: " + row); String line = br.readLine(); } // Advance to starting char - while (col < this.fc_start.getCol()) { + for (; col < this.fc_start.getCol(); col++) { //Single char read - char c = br.read(); + // System.out.println("skipping col: " + col); + int c = br.read(); } // reset col to 0 for last read - col = 0; + // col = 1; // Now in correct row to start actually noting down file contents - while (row < this.fc_end.getRow()) { + + // Get whole lines here + for (; row < this.fc_end.getRow(); row++) { + // System.out.println("reading row: " + row); res += br.readLine(); } // Now row = row.end - while (col <= this.fc_end.getCol()) { - res += br.read(); + for (; col <= this.fc_end.getCol(); col++) { + // System.out.println("reading col: " + col); + char c = (char)br.read(); + res += Character.toString(c); } // Done. Can close file now br.close(); // Just set filebytes (text_repr) to res this.text_repr = res; - - } catch (IOException e) { + } + catch (IOException e) { System.out.println("ERROR READING FROM FILE " + this.filename); e.printStackTrace(); } @@ -194,12 +189,12 @@ public String toString() { private boolean has_been_initialized = false; // Section 0. Every context box will have a numeric index label - private int num_index; + private int num_index = 0; private static int next_index = 0; // Section 1. Header will contain TRANSLATION and/or HIGHER-ORDER - private boolean is_translation; - private boolean is_higher_order; + private int translation_x; + private int higher_order_y; // Section 2. Actual text representation // (either copied from file or prity print (pp) represenation) @@ -216,6 +211,6 @@ public String toString() { private boolean is_contractum; private int contractum_of; private boolean is_new; - private boolean is_attribute; + private boolean is_attribute_root; private int attribute_of; } \ No newline at end of file From eec88611f6b227fd9d8c386d1fbd3e7f063f78eb Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Mon, 26 Feb 2024 22:45:19 -0600 Subject: [PATCH 12/64] apart from origin tracking, isMain() hack means contextualization works on everything in translator grammar --- .vscode/settings.json | 3 +- .../.settings/org.eclipse.jdt.core.prefs | 2 +- .../src/common/CMDContextVisualization.java | 24 ----- runtime/java/src/common/ContextStack.java | 32 +------ .../java/src/common/ContextVisualization.java | 19 ---- runtime/java/src/common/DecoratedNode.java | 89 +++++++++++-------- .../java/src/common/NodeContextMessage.java | 28 ++++-- 7 files changed, 76 insertions(+), 121 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f00dd1501..86b1fe3c2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "silver.jvmArgs": "-Xmx10G -Xss40M", "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable", - "silver.compilerJar": "jars/silver.compiler.composed.Default.jar" + "silver.compilerJar": "jars/silver.compiler.composed.Default.jar", + "java.compile.nullAnalysis.mode": "automatic" } \ No newline at end of file diff --git a/language-server/launcher/.settings/org.eclipse.jdt.core.prefs b/language-server/launcher/.settings/org.eclipse.jdt.core.prefs index cbcd33000..6bf842e11 100644 --- a/language-server/launcher/.settings/org.eclipse.jdt.core.prefs +++ b/language-server/launcher/.settings/org.eclipse.jdt.core.prefs @@ -33,7 +33,7 @@ org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=javax.annotation.ParametersAreNonnullByDefault org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullable.secondary= diff --git a/runtime/java/src/common/CMDContextVisualization.java b/runtime/java/src/common/CMDContextVisualization.java index 9e0c5acc0..2ab9c90be 100644 --- a/runtime/java/src/common/CMDContextVisualization.java +++ b/runtime/java/src/common/CMDContextVisualization.java @@ -26,27 +26,3 @@ public void show() { } } - -// public class CMDContextVisualization extends ContextVisualization { -// private final String printFormat = "%s\n%s\n%s\n"; -// private String border; - -// public CMDContextVisualization(String border) { -// super(); - -// this.border = border; -// } - -// @Override -// public void show() { -// // for(NodeContextMessage nodeContextMessage : this.contextStack.iterator()) { -// // System.out.printf(this.printFormat, this.border, nodeContextMessage.toString(), this.border); -// // } - -// Iterator iterator = this.contextStack.iterator(); -// while (iterator.hasNext()) { -// Integer nodeContextMessage = iterator.next(); -// System.out.printf(this.printFormat, this.border, nodeContextMessage.toString(), this.border); -// } -// } -// } \ No newline at end of file diff --git a/runtime/java/src/common/ContextStack.java b/runtime/java/src/common/ContextStack.java index fb0f373a5..385485501 100644 --- a/runtime/java/src/common/ContextStack.java +++ b/runtime/java/src/common/ContextStack.java @@ -10,7 +10,7 @@ public class ContextStack { public void push(DecoratedNode n) { this.height++; - NodeContextMessage ncm = new NodeContextMessage(n); + NodeContextMessage ncm = new NodeContextMessage(n, this.next_index++); this.stack.push(ncm); } @@ -33,32 +33,6 @@ public Iterator iterator() { private Stack stack = new Stack(); private int height = 0; + // Used for indices + private int next_index = 1; } - -// public class ContextStack { - -// public void push(Integer n) { -// this.height++; -// this.stack.push(n); -// } - -// public Integer pop() { -// this.height--; -// return this.stack.pop(); -// } - -// public Integer peak() { -// return this.stack.peek(); -// } - -// public int get_height() { -// return this.height; -// } - -// public Iterator iterator() { -// return this.stack.iterator(); -// } - -// private Stack stack = new Stack(); -// private int height = 0; -// } diff --git a/runtime/java/src/common/ContextVisualization.java b/runtime/java/src/common/ContextVisualization.java index 931286088..3bbc24f4b 100644 --- a/runtime/java/src/common/ContextVisualization.java +++ b/runtime/java/src/common/ContextVisualization.java @@ -17,22 +17,3 @@ public NodeContextMessage pop() { public abstract void show(); } - - -// public abstract class ContextVisualization { -// protected ContextStack contextStack; - -// public ContextVisualization() { -// this.contextStack = new ContextStack(); -// } - -// public void push(Integer decoratedNode) { -// this.contextStack.push(decoratedNode); -// } - -// public Integer pop() { -// return this.contextStack.pop(); -// } - -// public abstract void show(); -// } diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index bfd8c76a6..ddd017fec 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -952,7 +952,7 @@ private DecoratedNode getRedexHelper(DecoratedNode dn) { // or just that dn.parent repeatedly will eventually find null // parent of DecoratedNode root is TopNode. Might need that and not null - if (dn instanceof TopNode) { + if (dn == null || dn.isRoot() || dn.isMain()) { return null; } @@ -971,7 +971,8 @@ public DecoratedNode getContractum() { private DecoratedNode getContractumHelper(DecoratedNode dn) { // For now assume abstract syntax tree root has null parent // or just that dn.parent repeatedly will eventually find null - if (dn == null) { + if (dn == null || dn instanceof TopNode || dn.isRoot() || dn.isMain()) { + // if (dn == null || dn.isRoot()) { return null; } @@ -1061,8 +1062,8 @@ public FileCoordinate getEndCoordinates() { // for the sake of my naming convention // Not yet used but probably need for reference attributes public NOriginInfo getOrigin() { - // return OriginsUtil.getOriginOrNull(this); - return null; + return OriginsUtil.getOriginOrNull(this); + // return null; } // If not a contractum or redex, @@ -1088,23 +1089,19 @@ public boolean getIsNew() { if (oinfo instanceof PoriginAndRedexOriginInfo || oinfo instanceof PoriginOriginInfo) { + // System.out.println("IS PoriginAndRedexOriginInfo or PoriginOriginInfo"); // Might need check types here // Should get only Nodes from here - // Object origin = oinfo.getChild_origin(); - // // I don't know if this is will be a Node or DecoratedNode yet - // String child_prod_name = ""; - // if (origin instanceof Node) { - // child_prod_name = origin.getName(); - // } - // // Not going to be a DecoratedNode - // else if (origin instanceof DecoratedNode) { - // child_prod_name = origin.getNode().getName(); - // } - // else { - // System.err.println("ERROR. origin not Node nor DecoratedNode"); - // } - // // New if different production only - // return !child_prod_name.equals(this.self.getName()); + Object origin = oinfo.getChild(0); + + // Could do a hacky version with origin.toString() + // since last part of production name will be in there + // and will have a 'c' if concrete syntax (so false if _c@ in) + System.out.println("Origin: " + origin.toString()); + // String prod_name = this.self.getName().sub + } + else { + System.out.println("NO ORIGIN FOUND!!!"); } return false; } @@ -1141,10 +1138,37 @@ public boolean getIsAttributeRoot() { return this.is_attribute_root; } + public boolean isRoot() { + return this.getNode().getName().contains("root"); + } + + public boolean isMain() { + return this.getNode().getName().contains("main"); + } + + public void setIsAttributeRoot() { + + // Had to hack this as well with this.parent.isMain() + if (! (this == null || this.isRoot() || this.isMain() || + this.parent == null || this.parent.isRoot() || this.parent.isMain())) { + + System.out.println("SET-IS-ATTR: " + this.toString()); + Map map = Debug.allAttributesObjectMap(this.parent); + Collection values = map.values(); + for (Object obj: values) { + if (obj == this) { + this.is_attribute_root = true; + } + } + } + + this.is_attribute_root = false; + } + public int getIsAttribute() { - if (this.isRoot()) { + if (this.parent == null || this.isRoot() || this.isMain()) { return 0; } else { @@ -1162,31 +1186,18 @@ public int getIsAttribute() { // https://melt.cs.umn.edu/silver/ref/decl/annotations/ - public boolean isRoot() { - return this.getNode().getName().contains("root"); - } - public void setIsAttributeRoot() { - - if (! this.isRoot()) { - System.out.println("HERE!"); - Map map = Debug.allAttributesObjectMap(this.parent); - Collection values = map.values(); - for (Object obj: values) { - if (obj == this) { - this.is_attribute_root = true; - } - } - } - - this.is_attribute_root = false; - } public int getIsTranslation() { // See how many parents are contractums - if (this.isRoot()) { + // System.out.println("GET-IS-TRANSLATION node:" + this.toString()); + // System.out.println("GET-IS-TRANSLATION has contractum:" + this.self.hasForward()); + if (this.parent == null || this.isRoot() || this.isMain()) { return 0; } + // else if (this.self.hasForward()) { + // return 1 + this.parent.getIsTranslation(); + // } else if (this.getIsContractum()) { return 1 + this.parent.getIsTranslation(); } diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index 28ec1483d..f0f4c0baf 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -62,9 +62,14 @@ public String GetSection4() { } // Constructor for NodeContextMessage - public NodeContextMessage(DecoratedNode node) { + public NodeContextMessage(DecoratedNode node, int num_index) { + + // Set the current index. Keep track of it in the stack + // to make decrementing on pop() easy + this.num_index = num_index; + // Section 0 - this.set_index(); + // this.set_index(); // Try to do all this within java given a node n @@ -91,10 +96,10 @@ public NodeContextMessage(DecoratedNode node) { this.has_been_initialized = true; } - private void set_index() { - next_index++; - this.num_index = next_index; - } + // private void set_index() { + // next_index++; + // this.num_index = next_index; + // } // Set translation_x and translation_x bools here // Is there a way to know something is an attribute @@ -161,6 +166,7 @@ private void pull_filelines() { for (; row < this.fc_end.getRow(); row++) { // System.out.println("reading row: " + row); res += br.readLine(); + res += '\n'; // Since not added with readLine() } // Now row = row.end for (; col <= this.fc_end.getCol(); col++) { @@ -185,12 +191,18 @@ public String toString() { return this.GetSection0() + "\n" + this.GetSection1() + "\n" + this.GetSection2() + "\n" + this.GetSection3() + "\n" + this.GetSection4(); } + // @Override + // protected void finalize() throws Throwable { + // next_index--; + // super.finalize(); + // } + // Only perform attribute setting once private boolean has_been_initialized = false; // Section 0. Every context box will have a numeric index label - private int num_index = 0; - private static int next_index = 0; + private int num_index; + // private static int next_index = 0; // Section 1. Header will contain TRANSLATION and/or HIGHER-ORDER private int translation_x; From 65c3080d0944ba5ec67fe651c6bf01831ccea0d7 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Mon, 26 Feb 2024 22:57:27 -0600 Subject: [PATCH 13/64] removed some comments --- runtime/java/src/common/DecoratedNode.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index ddd017fec..fd76268f6 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -1097,7 +1097,8 @@ public boolean getIsNew() { // Could do a hacky version with origin.toString() // since last part of production name will be in there // and will have a 'c' if concrete syntax (so false if _c@ in) - System.out.println("Origin: " + origin.toString()); + // But these don't seem to work as intended + // System.out.println("Origin: " + origin.toString()); // String prod_name = this.self.getName().sub } else { @@ -1150,9 +1151,9 @@ public void setIsAttributeRoot() { // Had to hack this as well with this.parent.isMain() if (! (this == null || this.isRoot() || this.isMain() || - this.parent == null || this.parent.isRoot() || this.parent.isMain())) { + this.parent == null || this.parent.isMain())) { - System.out.println("SET-IS-ATTR: " + this.toString()); + // System.out.println("SET-IS-ATTR: " + this.toString()); Map map = Debug.allAttributesObjectMap(this.parent); Collection values = map.values(); for (Object obj: values) { From 1531873726466ebda11823fd9dac79764b72f679 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Mon, 26 Feb 2024 23:02:36 -0600 Subject: [PATCH 14/64] return logi fix --- runtime/java/src/common/DecoratedNode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index fd76268f6..af67c00c9 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -1159,6 +1159,7 @@ public void setIsAttributeRoot() { for (Object obj: values) { if (obj == this) { this.is_attribute_root = true; + return; } } } From 7755cf99bff2a7bdea7cee2bd60dafcde61d1335 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 27 Feb 2024 13:04:32 -0600 Subject: [PATCH 15/64] minor fixes + fixed indices decrement --- runtime/java/src/common/ContextStack.java | 1 + runtime/java/src/common/Debug.java | 2 +- runtime/java/src/common/DecoratedNode.java | 16 +++++++++------- runtime/java/src/common/NodeContextMessage.java | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/runtime/java/src/common/ContextStack.java b/runtime/java/src/common/ContextStack.java index 385485501..6922f6a72 100644 --- a/runtime/java/src/common/ContextStack.java +++ b/runtime/java/src/common/ContextStack.java @@ -16,6 +16,7 @@ public void push(DecoratedNode n) { public NodeContextMessage pop() { this.height--; + this.next_index--; return this.stack.pop(); } diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index d0d1993ec..14639e00c 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -55,7 +55,7 @@ public void runingDebug(DecoratedNode tree) { //Control loop //TODO: Horizontal seperator between user inut and $ for inputs loop: do { - System.out.print(" $"); + System.out.print(">DEBUGGER-PROMPT$"); userInput = inp.nextLine(); userInputList = userInput.split(" "); diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index af67c00c9..458beb86f 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -952,7 +952,8 @@ private DecoratedNode getRedexHelper(DecoratedNode dn) { // or just that dn.parent repeatedly will eventually find null // parent of DecoratedNode root is TopNode. Might need that and not null - if (dn == null || dn.isRoot() || dn.isMain()) { + if (dn == null || dn.parent == null || dn.parent instanceof TopNode || + dn.isRoot() || dn.isMain()) { return null; } @@ -971,8 +972,8 @@ public DecoratedNode getContractum() { private DecoratedNode getContractumHelper(DecoratedNode dn) { // For now assume abstract syntax tree root has null parent // or just that dn.parent repeatedly will eventually find null - if (dn == null || dn instanceof TopNode || dn.isRoot() || dn.isMain()) { - // if (dn == null || dn.isRoot()) { + if (dn == null || dn.parent == null || dn.parent instanceof TopNode || + dn.isRoot() || dn.isMain()) { return null; } @@ -1126,8 +1127,8 @@ public String getPrettyPrint() { return pp.toString(); } } - System.err.println("No pretty print (pp) attribute defined"); - return ""; + System.err.println("No pretty print (pp) attribute defined--using genericShow() instead"); + return Util.genericShow(this).toString(); } // only set is_attribute_root once @@ -1150,7 +1151,8 @@ public boolean isMain() { public void setIsAttributeRoot() { // Had to hack this as well with this.parent.isMain() - if (! (this == null || this.isRoot() || this.isMain() || + if (! (this == null || this.parent instanceof TopNode || + this.isRoot() || this.isMain() || this.parent == null || this.parent.isMain())) { // System.out.println("SET-IS-ATTR: " + this.toString()); @@ -1194,7 +1196,7 @@ public int getIsTranslation() { // See how many parents are contractums // System.out.println("GET-IS-TRANSLATION node:" + this.toString()); // System.out.println("GET-IS-TRANSLATION has contractum:" + this.self.hasForward()); - if (this.parent == null || this.isRoot() || this.isMain()) { + if (this.parent == null || this.parent instanceof TopNode || this.isRoot() || this.isMain()) { return 0; } // else if (this.self.hasForward()) { diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index f0f4c0baf..bf83ffe6c 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -125,10 +125,10 @@ private void set_labels(DecoratedNode node) { this.is_redex = node.getIsRedex(); this.is_contractum = node.getIsContractum(); // Will always work for forwarding. Only use this value if is_contractum - this.contractum_of = node.getDebuggingIndex() - 1; + this.contractum_of = this.num_index - 1; this.is_new = node.getIsNew(); this.is_attribute_root = node.getIsAttributeRoot(); - this.attribute_of = node.getDebuggingIndex() - 1; + this.attribute_of = this.num_index - 1; } // access pp attribute if present From a6e587af6ea0d671143fc5705772965d70c77e3c Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 27 Feb 2024 13:44:09 -0600 Subject: [PATCH 16/64] hacky origin tracking now works for is-new --- runtime/java/src/common/DecoratedNode.java | 46 ++++++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 458beb86f..d3b52f273 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -883,9 +883,9 @@ public final Object evalInhSomehowButPublic(final int attribute) { // getPrettyPrint() DONE - // getIsAttribute() SORT-OF-DONE + // getIsAttribute() DONE - // getIsTranslation() SORT-OF-DONE + // getIsTranslation() DONE private int debugging_index; private boolean is_redex; @@ -1095,12 +1095,42 @@ public boolean getIsNew() { // Should get only Nodes from here Object origin = oinfo.getChild(0); - // Could do a hacky version with origin.toString() - // since last part of production name will be in there - // and will have a 'c' if concrete syntax (so false if _c@ in) - // But these don't seem to work as intended - // System.out.println("Origin: " + origin.toString()); - // String prod_name = this.self.getName().sub + // For regular (non-root) nonterminals, there appear to be 2 origins, + // the second of which is just true, so only use the first + + // DecoratedNode dn = (DecoratedNode)origin; + // System.out.println("Origin: " + oinfo.getNumberOfChildren()); + // for (int i = 0; i < oinfo.getNumberOfChildren(); i++) { + // System.out.println("Origin name: " + oinfo.getChild(i).toString()); + // } + + String full_prod_name = this.self.getName(); + int lastIndex = full_prod_name.lastIndexOf(':'); + String prod_name = full_prod_name.substring(lastIndex + 1); + // System.out.println("PROD NAME: " + prod_name); + + // Will do a hacky version with origin.toString() for now + // since last part of production name will be in there between + // P and @ if origin is another node of the same name. + // Also, there will be a '_c@' if concrete syntax (so false if _c@ in) + String ostr = origin.toString(); + // System.out.println("ORIGIN NAME: " + ostr); + // Origin in concrete syntax case + if (ostr.contains("_c@")) { + // Never going to be new + // System.out.println("CONCRETE SYNTAX ORIGIN"); + return false; + } + else if (ostr.contains("P" + prod_name + "@")) { + // System.out.println("ABSTRACT SYNTAX ORIGIN"); + // Not new since same name + return false; + } + else { + // System.out.println("!!!!!!!!IS-NEW!!!!!!!!"); + return true; + } + } else { System.out.println("NO ORIGIN FOUND!!!"); From 0a6102a53fef7f8321440dadbe6d82c097910a0e Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Tue, 27 Feb 2024 23:50:10 -0600 Subject: [PATCH 17/64] fixed a few bugs and found somemore, added toggle for cStack, started into, and created a generic intInput function --- runtime/java/src/common/Debug.java | 214 ++++++++++++++++++++--------- 1 file changed, 150 insertions(+), 64 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 14639e00c..dd979107a 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -33,7 +33,8 @@ public void runingDebug(DecoratedNode tree) { String userInput; String[] userInputList; boolean toggleProdDisplay = true; - boolean toggleHeadlessAttributes = true; + boolean toggleCStackDisplay = true; + boolean toggleHeadlessAttributes = false; DecoratedNode childNode; this.root = tree; this.currentNode = tree; @@ -50,10 +51,11 @@ public void runingDebug(DecoratedNode tree) { // if we want an HTML visualization: // HTMLContextVisualization cStack = new HTMLContextVisualization(); cStack.push(currentNode); - cStack.show(); + if(toggleCStackDisplay){ + cStack.show(); + } //Control loop - //TODO: Horizontal seperator between user inut and $ for inputs loop: do { System.out.print(">DEBUGGER-PROMPT$"); userInput = inp.nextLine(); @@ -81,40 +83,52 @@ public void runingDebug(DecoratedNode tree) { // if we navigate up to a parent, push it on to the stack (?) cStack.pop(); // when we push, update and show the context - cStack.show(); + if(toggleCStackDisplay){ + cStack.show(); + } } } break; case "down": case "d": - int childNum = 0; - if (userInputList.length != 2) { - //System.out.println("invalid, correct usage: down "); + int childNum = -1; + if (userInputList.length == 1) { System.out.println("Which child?"); printChildren(currentNode); - System.out.print(" $"); - childNum = inp.nextInt(); - inp.nextLine(); + childNum = inputInt(inp); + if(childNum == -1){ + break; + } + }else if(userInputList.length == 2){ + try{ + childNum = Integer.parseInt(userInputList[1]); + }catch (NumberFormatException e) { + System.out.println("invalid, correct usage: down "); + break; + } }else{ - //Explodes if the input is not a integer should gracefully exit - childNum = Integer.parseInt(userInputList[1]); + System.out.println("invalid, correct usage: down "); + break; } childNode = down(childNum); + if(childNode == null){ System.out.println("invalid child number"); + break; } else{ nodeStack.push(currentNode); currentNode = childNode; - //System.out.println("going down"); if(toggleProdDisplay){ printProduction(currentNode); } // if we navigate down to a child, push it on to the stack cStack.push(currentNode); // when we push, update and show the context - cStack.show(); + if(toggleCStackDisplay){ + cStack.show(); + } } break; @@ -134,12 +148,15 @@ public void runingDebug(DecoratedNode tree) { } // remove from the stack cStack.pop(); - cStack.show(); + if(toggleCStackDisplay){ + cStack.show(); + } } } break; - //TODO: Works but known bug view is weird a forward nodes + //TODO: Works but known bug view is weird a forward nodes + //bug update: looks like the problem is with getSyhthized called in allAttributesObjectMap not sure how to fix case "forwards": if (userInputList.length != 1) { System.out.println("invalid, correct usage: forwards<>"); @@ -157,12 +174,37 @@ public void runingDebug(DecoratedNode tree) { // if we navigate to a forward, push it on to the stack cStack.push(currentNode); // when we push, update and show the context - cStack.show(); + if(toggleCStackDisplay){ + cStack.show(); + } + } + } + break; + + + //TODO: make a test case + case "into": + if (userInputList.length != 2) { + System.out.println("invalid, correct usage: forwards "); + }else{ + childNode = into(currentNode, userInputList[1]); + if(childNode == null){ + System.out.println("invalid input"); + } + else{ + System.out.println("going inot"); + currentNode = childNode; + // if(toggleProdDisplay){ + // printProduction(currentNode); + // } + // // if we navigate to a forward, push it on to the stack + // cStack.push(currentNode); + // // when we push, update and show the context + // cStack.show(); } } break; - //TODO: Untested, find good test case case "backtrack": if (userInputList.length != 1) { System.out.println("invalid, correct usage: backtrack<>"); @@ -180,7 +222,9 @@ public void runingDebug(DecoratedNode tree) { // if we navigate backwards, push it on to the stack (?) cStack.push(currentNode); // when we push, update and show the context - cStack.show(); + if(toggleCStackDisplay){ + cStack.show(); + } } } break; @@ -206,6 +250,14 @@ public void runingDebug(DecoratedNode tree) { System.out.println("Headless Attributes on"); toggleHeadlessAttributes = true; } + }if(userInputList[1].equals("cStackDisplay")){ + if(toggleCStackDisplay){ + System.out.println("cStack Display off"); + toggleCStackDisplay = false; + }else{ + System.out.println("cStack Display on"); + toggleCStackDisplay = true; + } } else{ System.out.println("legal toggles: prodDisplay, fullAttributeNames"); @@ -274,17 +326,32 @@ public void runingDebug(DecoratedNode tree) { String attributeName = ""; Integer attributeNum = 0; List attributeList = allAttributesList(currentNode); - if (userInputList.length != 2) { + if (userInputList.length == 1) { System.out.println("Which attribute?"); - printAttributes(currentNode, toggleHeadlessAttributes); - System.out.print(" $"); - attributeNum = inp.nextInt(); - inp.nextLine(); - attributeName = attributeList.get(attributeNum); + printAttributes(currentNode, toggleHeadlessAttributes); + attributeNum = inputInt(inp); + if(attributeNum == -1){ + break; + }else if(attributeNum >= attributeList.size()){ + System.out.println("Invaild attribute number"); + break; + }else{ + attributeName = attributeList.get(attributeNum); + } + }else if(userInputList.length == 2){ + try{ + attributeNum = Integer.parseInt(userInputList[1]); + attributeName = attributeList.get(attributeNum); + }catch (NumberFormatException e) { + System.out.println("invalid, correct usage: view "); + break; + }catch (IndexOutOfBoundsException e){ + System.out.println("Index out of bounds"); + break; + } }else{ - //Explodes if the input is not a integer should gracefully exit - attributeNum = Integer.parseInt(userInputList[1]); - attributeName = attributeList.get(attributeNum); + System.out.println("invalid, correct usage: down "); + break; } printAttrFromName(currentNode, attributeName); break; @@ -350,12 +417,50 @@ public DecoratedNode up() public DecoratedNode down(int child) { - if (currentNode.getNode().getNumberOfChildren() > child) - { + String child_productions[] = currentNode.undecorate().getProdleton().getChildTypes(); + //System.out.println("Inside of Down function"); + try{ + System.out.println("null name: " + child_productions[child]); + if(child_productions[child].equals("null")){ + return null; + } DecoratedNode childNode = currentNode.childDecorated(child); return childNode; + }catch(NullPointerException e){ + System.out.println("Null pointer"); + return null; + }catch(IndexOutOfBoundsException e){ + System.out.println("Index out of bound"); + return null; } - return null; + //if (currentNode.getNode().getNumberOfChildren() > child && child >= 0){ + //Might be a bandaid fix not sure I understand why the problem exists + // DecoratedNode childNode = currentNode.childDecorated(child); + // return childNode; + // //} + // return null; + } + + public static int inputInt(Scanner inp){ + boolean continueLoop = true; + int returnInt = -1; + String stopper = ""; + while(continueLoop){ + System.out.print(">DEBUGGER-PROMPT$"); + if (inp.hasNextInt()) { + returnInt = inp.nextInt(); + inp.nextLine(); + continueLoop = false; + }else{ + stopper = inp.nextLine(); + if (stopper.equals("e")){ + continueLoop = false; + }else{ + System.out.println("Please choose an integer or e to exit"); + } + } + } + return returnInt; } public void printChildren(DecoratedNode node) @@ -383,7 +488,7 @@ public DecoratedNode backtrack(DecoratedNode node) public void printProduction(DecoratedNode node) { - String partent_production = node.undecorate().getProdleton().getName(); + String partent_production = node.undecorate().getProdleton().getTypeUnparse(); String child_productions[] = node.undecorate().getProdleton().getChildTypes(); System.out.print(partent_production + " "); for (int i = 0; i < child_productions.length; i++){ @@ -464,36 +569,8 @@ public List removeHeaders(List stringList){ return headlessList; } - public Map attriburteNameObjectMap(DecoratedNode node){ - List attributeList = allAttributesList(node); - RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); - RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - Map attributeMap = new HashMap<>(); - - for(String attribute : attributeList) - { - if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ - Integer index = nonterminalton.getSynOccursIndex(attribute); - Lazy synthAttribute = node.getNode().getSynthesized(index); - Object o = synthAttribute.eval(node); - attributeMap.put(attribute, o); - }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ - Integer index = nonterminalton.getInhOccursIndex(attribute); - Object o = node.evalInhSomehowButPublic(index); - attributeMap.put(attribute, o); - }else{ //Should be local - List listLocals = listLocalAttrs(node); - Integer index = listLocals.indexOf(attribute); - Lazy localAttribute = node.getNode().getLocal(index); - Object o = localAttribute.eval(node); - attributeMap.put(attribute, o); - } - } - return attributeMap; - } - public void printAttrFromName(DecoratedNode node, String printAttribute){ - Map attributeMap = attriburteNameObjectMap(node); + Map attributeMap = allAttributesObjectMap(node); System.out.println(Util.genericShow(attributeMap.get(printAttribute))); } @@ -513,6 +590,15 @@ public static List listLocalAttrs(DecoratedNode node) } //TODO: Add access to higher order attriburte + public DecoratedNode into(DecoratedNode node, String attriburteName){ + Map attributeMap = allAttributesObjectMap(node); + if (attributeMap.containsKey(attriburteName)) { + System.out.println("In into function"); + Object attributeObject = attributeMap.get(attriburteName); + return (DecoratedNode) attributeObject; //Does not work + } + return null; + } //Helper for printAttrFromName @@ -529,7 +615,7 @@ public static List allAttributesList(DecoratedNode node) return attributeList; } - // Another Helper Currently not used but might be important later + // Another Helper public static Map allAttributesObjectMap(DecoratedNode node) { List attributeList = allAttributesList(node); @@ -540,9 +626,9 @@ public static Map allAttributesObjectMap(DecoratedNode node) for(String attribute : attributeList) { if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ - //System.out.println("Synthisized!!!"); + //System.out.println("Synthisized!!! \"" + attribute + "\""); Integer index = nonterminalton.getSynOccursIndex(attribute); - Lazy synthAttribute = node.getNode().getSynthesized(index); + Lazy synthAttribute = node.getNode().getSynthesized(index); //scuffed Object o = synthAttribute.eval(node); attributeMap.put(attribute, o); }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ From 762c28a2013702eaea370fb194d221578338a970 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Wed, 28 Feb 2024 15:59:10 -0600 Subject: [PATCH 18/64] help is more helpful, better comments, and choosing from a list function added --- .../translation/java/core/ProductionDcl.sv | 6 + runtime/java/src/common/Debug.java | 241 ++++++++++++------ runtime/java/src/common/RTTIManager.java | 1 + 3 files changed, 166 insertions(+), 82 deletions(-) diff --git a/grammars/silver/compiler/translation/java/core/ProductionDcl.sv b/grammars/silver/compiler/translation/java/core/ProductionDcl.sv index 6281eea14..1fbb2b1dc 100644 --- a/grammars/silver/compiler/translation/java/core/ProductionDcl.sv +++ b/grammars/silver/compiler/translation/java/core/ProductionDcl.sv @@ -242,6 +242,11 @@ ${if isData then "" else s""" return "${fName}"; } + @Override + public String[] getChildNames() { + return namedSig.inputNames; + } + ${otImpl} @Override @@ -309,6 +314,7 @@ ${body.translation} } public String getName(){ return "${fName}"; } + public String[] getChildNames(){return namedSig.inputNames;} public common.RTTIManager.Nonterminalton<${fnnt}> getNonterminalton(){ return ${fnnt}.nonterminalton; } public String getTypeUnparse() { return "${escapeString(ns.unparse)}"; } diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index dd979107a..7e29ceeef 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -1,5 +1,4 @@ -//TODO: Error handling is not good right now -//Thing to remeber: ./silver_compile --forced-origins --clean +//Thing to remeber: ./silver-compile --force-origins --clean package common; @@ -11,6 +10,7 @@ import java.util.Stack; import java.util.ArrayList; import java.util.List; +import java.util.Arrays; import common.Util.*; @@ -35,12 +35,14 @@ public void runingDebug(DecoratedNode tree) { boolean toggleProdDisplay = true; boolean toggleCStackDisplay = true; boolean toggleHeadlessAttributes = false; + String[] toggleChoices = {"prodDisplay", "cStackDisplay", "fullAttributeNames"}; DecoratedNode childNode; this.root = tree; this.currentNode = tree; this.nodeStack = new Stack(); if(toggleProdDisplay){ + //printNames(currentNode); printProduction(currentNode); } @@ -94,8 +96,7 @@ public void runingDebug(DecoratedNode tree) { int childNum = -1; if (userInputList.length == 1) { System.out.println("Which child?"); - printChildren(currentNode); - childNum = inputInt(inp); + childNum = chooseFormList(inp, currentNode.undecorate().getProdleton().getChildTypes()); if(childNum == -1){ break; } @@ -182,7 +183,7 @@ public void runingDebug(DecoratedNode tree) { break; - //TODO: make a test case + //TODO: known bug, don't know how to represent higher order nodes as decoratedNodes case "into": if (userInputList.length != 2) { System.out.println("invalid, correct usage: forwards "); @@ -192,7 +193,7 @@ public void runingDebug(DecoratedNode tree) { System.out.println("invalid input"); } else{ - System.out.println("going inot"); + System.out.println("going into"); currentNode = childNode; // if(toggleProdDisplay){ // printProduction(currentNode); @@ -230,38 +231,38 @@ public void runingDebug(DecoratedNode tree) { break; case "toggle": - if (userInputList.length != 2) { - System.out.println("please indicate what you want to toggle ex: 'toggle prodDisplay'"); - }else{ - if(userInputList[1].equals("prodDisplay")){ - if(toggleProdDisplay){ - System.out.println("Production Display off"); - toggleProdDisplay = false; - }else{ - System.out.println("Production Display on"); - toggleProdDisplay = true; - } + String toggelChoice = ""; + if (userInputList.length == 1) { + toggelChoice = toggleChoices[chooseFormList(inp, toggleChoices)]; + }else if (userInputList.length == 2){ + toggelChoice = userInputList[1]; + } + if(toggelChoice.equals("prodDisplay")){ + if(toggleProdDisplay){ + System.out.println("Production Display off"); + toggleProdDisplay = false; + }else{ + System.out.println("Production Display on"); + toggleProdDisplay = true; } - if(userInputList[1].equals("fullAttributeNames")){ - if(toggleHeadlessAttributes){ - System.out.println("Headless Attributes off"); - toggleHeadlessAttributes = false; - }else{ - System.out.println("Headless Attributes on"); - toggleHeadlessAttributes = true; - } - }if(userInputList[1].equals("cStackDisplay")){ - if(toggleCStackDisplay){ - System.out.println("cStack Display off"); - toggleCStackDisplay = false; - }else{ - System.out.println("cStack Display on"); - toggleCStackDisplay = true; - } + }else if(toggelChoice.equals("fullAttributeNames")){ + if(toggleHeadlessAttributes){ + System.out.println("Headless Attributes off"); + toggleHeadlessAttributes = false; + }else{ + System.out.println("Headless Attributes on"); + toggleHeadlessAttributes = true; } - else{ - System.out.println("legal toggles: prodDisplay, fullAttributeNames"); + }else if(toggelChoice.equals("cStackDisplay")){ + if(toggleCStackDisplay){ + System.out.println("cStack Display off"); + toggleCStackDisplay = false; + }else{ + System.out.println("cStack Display on"); + toggleCStackDisplay = true; } + }else{ + System.out.println("legal toggles: prodDisplay, fullAttributeNames, cStackDisplay"); } break; @@ -275,7 +276,8 @@ public void runingDebug(DecoratedNode tree) { } break; - //TODO:Implement this - use genericShow? + //TODO:Implement this - use genericShow?, see ProductionDcl in grammer/silver/compiler/translation/java/core + //Somehow this needs to create a new function for RTTI manager but current attempt does not work case "eq": if (userInputList.length != 1 && userInputList.length != 2) { System.out.println("invalid, correct usage: eq"); @@ -299,7 +301,7 @@ public void runingDebug(DecoratedNode tree) { //List inherited attributes case "listInher": if (userInputList.length != 1 && userInputList.length != 2) { - System.out.println("invalid, correct usage: listInher"); + System.out.println("invalid, correct usage: listInher "); }else{ if(listInher(currentNode) == 0){ System.out.println("no inherited attributes"); @@ -328,8 +330,9 @@ public void runingDebug(DecoratedNode tree) { List attributeList = allAttributesList(currentNode); if (userInputList.length == 1) { System.out.println("Which attribute?"); - printAttributes(currentNode, toggleHeadlessAttributes); - attributeNum = inputInt(inp); + List attriburteList = allAttributesList(currentNode); + String[] attriburteArray = attriburteList.toArray(new String[attriburteList.size()]); + attributeNum = chooseFormList(inp, attriburteArray); if(attributeNum == -1){ break; }else if(attributeNum >= attributeList.size()){ @@ -358,21 +361,81 @@ public void runingDebug(DecoratedNode tree) { case "local": - listLocalAttrs(currentNode); + if (userInputList.length != 1 && userInputList.length != 2) { + System.out.println("invalid, correct usage: local "); + }else{ + List listLocals = getLocalAttrs(currentNode); + if(listLocals.size() == 0){ + System.out.println("no inherited attributes"); + }else{ + for (String localAttribute : listLocals){ + System.out.println("Attribute = " + localAttribute); + } + } + } break; case "help": - System.out.println("up"); - System.out.println("down "); - System.out.println("view "); - System.out.println("forwards"); - System.out.println("backtrack"); - System.out.println("prod"); - System.out.println("eq"); - System.out.println("listSynth"); - System.out.println("listInher"); - System.out.println("list"); - System.out.println("exit"); + if (userInputList.length == 1) { + System.out.println("call help with one of these keywords to see its functionality:"); + System.out.println("toggle "); + System.out.println("up"); + System.out.println("down "); + System.out.println("view "); + System.out.println("forwards"); + System.out.println("backtrack"); + System.out.println("prod"); + System.out.println("eq"); + System.out.println("listSynth"); + System.out.println("listInher"); + System.out.println("local"); + System.out.println("list"); + System.out.println("into"); + System.out.println("exit"); + }else if(userInputList.length == 2){ + if(userInputList[1].equals("up")){ + System.out.println("The current node changes to its the parent"); + }else if(userInputList[1].equals("down")){ + System.out.println("The current node changes to its child"); + System.out.println("One optional input is the child number you want to travel to"); + System.out.println("If no input is provided you will be prompted with a choice of child"); + System.out.println("You cn call this function with \"d\""); + }else if(userInputList[1].equals("view")){ + System.out.println("look at the value of an attribute in the current node"); + System.out.println("One optional input is the attribute number you want to view"); + System.out.println("If no input is provided you will be prompted with a choice of attribute"); + System.out.println("You can call this function with \"v\""); + }else if(userInputList[1].equals("forwards")){ + System.out.println("The current node changes to its forward"); + }else if(userInputList[1].equals("backtrack")){ + System.out.println("The current node changes to its backtrack"); + }else if(userInputList[1].equals("prod")){ + System.out.println("prints the production of the current node"); + }else if(userInputList[1].equals("eq")){ + System.out.println("prints the equation of the current node"); + }else if(userInputList[1].equals("listSynth")){ + System.out.println("prints the Synthisized attributes of the current node"); + }else if(userInputList[1].equals("listInher")){ + System.out.println("prints the inherited attributes of the current node"); + }else if(userInputList[1].equals("list")){ + System.out.println("prints the attributes of the current node"); + }else if(userInputList[1].equals("local")){ + System.out.println("prints the local attributes of the current node"); + }else if(userInputList[1].equals("into")){ + System.out.println("The current node changes to its higer order attribute"); + System.out.println("One optional input is the attribute number you want to go into"); + System.out.println("If no input is provided you will be prompted with a choice of attribute"); + }else if(userInputList[1].equals("toggle")){ + System.out.println("Activate or disactivate a feature"); + System.out.println("One input is the feature number you want to toggle"); + System.out.println("If no input is provided you will be prompted with a choice of toggles"); + }else{ + System.out.println("try just calling help"); + } + }else{ + System.out.println("try just calling help"); + + } break; //Many ways to leave @@ -383,7 +446,6 @@ public void runingDebug(DecoratedNode tree) { break loop; default: System.out.println("invalid input call help for legal inputs"); - System.out.println(userInput); break; } } while(true); @@ -418,9 +480,7 @@ public DecoratedNode up() public DecoratedNode down(int child) { String child_productions[] = currentNode.undecorate().getProdleton().getChildTypes(); - //System.out.println("Inside of Down function"); try{ - System.out.println("null name: " + child_productions[child]); if(child_productions[child].equals("null")){ return null; } @@ -440,29 +500,7 @@ public DecoratedNode down(int child) // //} // return null; } - - public static int inputInt(Scanner inp){ - boolean continueLoop = true; - int returnInt = -1; - String stopper = ""; - while(continueLoop){ - System.out.print(">DEBUGGER-PROMPT$"); - if (inp.hasNextInt()) { - returnInt = inp.nextInt(); - inp.nextLine(); - continueLoop = false; - }else{ - stopper = inp.nextLine(); - if (stopper.equals("e")){ - continueLoop = false; - }else{ - System.out.println("Please choose an integer or e to exit"); - } - } - } - return returnInt; - } - + public void printChildren(DecoratedNode node) { String child_productions[] = node.undecorate().getProdleton().getChildTypes(); @@ -497,6 +535,18 @@ public void printProduction(DecoratedNode node) System.out.print("\n"); } + + // public void printNames(DecoratedNode node) + // { + // String partent_production = node.undecorate().getProdleton().getName(); + // String child_productions[] = node.undecorate().getProdleton().getChildNames(); + // System.out.print(partent_production + " "); + // for (int i = 0; i < child_productions.length; i++){ + // System.out.print(child_productions[i] + " "); + // } + // System.out.print("\n"); + // } + // Prints out the equation of the specified attr. // If attr is not specified, prints out the equations for all the attributes on the current node. // via eric we can just add equations as an attribute within our AG @@ -575,7 +625,7 @@ public void printAttrFromName(DecoratedNode node, String printAttribute){ } //List of all and only local attributes - public static List listLocalAttrs(DecoratedNode node) + public static List getLocalAttrs(DecoratedNode node) { int count = node.getNode().getNumberOfLocalAttrs(); List listLocals = new ArrayList<>(); @@ -595,7 +645,7 @@ public DecoratedNode into(DecoratedNode node, String attriburteName){ if (attributeMap.containsKey(attriburteName)) { System.out.println("In into function"); Object attributeObject = attributeMap.get(attriburteName); - return (DecoratedNode) attributeObject; //Does not work + return (DecoratedNode) attributeObject; //Does not work class translator.Pprogram cannot be cast to class common.DecoratedNode } return null; } @@ -607,7 +657,7 @@ public static List allAttributesList(DecoratedNode node) RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); List attributeList = nonterminalton.alphabeticalAttributes(); - List localAttributeList = listLocalAttrs(node); + List localAttributeList = getLocalAttrs(node); attributeList.addAll(localAttributeList); attributeList.sort(null); @@ -628,7 +678,7 @@ public static Map allAttributesObjectMap(DecoratedNode node) if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ //System.out.println("Synthisized!!! \"" + attribute + "\""); Integer index = nonterminalton.getSynOccursIndex(attribute); - Lazy synthAttribute = node.getNode().getSynthesized(index); //scuffed + Lazy synthAttribute = node.getNode().getSynthesized(index); //breaks for forwarded nodes Object o = synthAttribute.eval(node); attributeMap.put(attribute, o); }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ @@ -638,7 +688,7 @@ public static Map allAttributesObjectMap(DecoratedNode node) attributeMap.put(attribute, o); }else{ //Should be local //System.out.println("local!!!"); - List listLocals = listLocalAttrs(node); + List listLocals = getLocalAttrs(node); Integer index = listLocals.indexOf(attribute); Lazy localAttribute = node.getNode().getLocal(index); Object o = localAttribute.eval(node); @@ -647,6 +697,33 @@ public static Map allAttributesObjectMap(DecoratedNode node) } return attributeMap; } + + public static Integer chooseFormList(Scanner inp, String[] list){ + for (int i = 0; i < list.length; i++){ + System.out.println(Integer.toString(i) + ": " + list[i]); + } + + boolean continueLoop = true; + int returnInt = -1; + String stopper = ""; + while(continueLoop){ + System.out.print(">DEBUGGER-PROMPT$"); + if (inp.hasNextInt()) { + returnInt = inp.nextInt(); + inp.nextLine(); + continueLoop = false; + }else{ + stopper = inp.nextLine(); + if (stopper.equals("e")){ + continueLoop = false; + }else{ + System.out.println("Please choose an integer or e to exit"); + } + } + } + return returnInt; + + } public boolean isContractum(DecoratedNode node) { diff --git a/runtime/java/src/common/RTTIManager.java b/runtime/java/src/common/RTTIManager.java index c6ab44915..75c2faa41 100644 --- a/runtime/java/src/common/RTTIManager.java +++ b/runtime/java/src/common/RTTIManager.java @@ -85,6 +85,7 @@ public abstract T constructDirect( final Object[] annos); // NO reify or other checking, used by native[De]Serialize public abstract String getName(); + //public abstract String[] getChildNames(); public abstract Nonterminalton getNonterminalton(); public abstract String getTypeUnparse(); // Nominally opaque representation of the type From 6d5d8c6d1449c69abdbefebb77da29270f2d14d0 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 29 Feb 2024 15:46:51 -0600 Subject: [PATCH 19/64] printProductions changed to printName new comments and into has a slection option --- .../translation/java/core/ProductionDcl.sv | 1 - runtime/java/src/common/Debug.java | 107 ++++++++++++------ 2 files changed, 70 insertions(+), 38 deletions(-) diff --git a/grammars/silver/compiler/translation/java/core/ProductionDcl.sv b/grammars/silver/compiler/translation/java/core/ProductionDcl.sv index 1fbb2b1dc..ad46d3b80 100644 --- a/grammars/silver/compiler/translation/java/core/ProductionDcl.sv +++ b/grammars/silver/compiler/translation/java/core/ProductionDcl.sv @@ -314,7 +314,6 @@ ${body.translation} } public String getName(){ return "${fName}"; } - public String[] getChildNames(){return namedSig.inputNames;} public common.RTTIManager.Nonterminalton<${fnnt}> getNonterminalton(){ return ${fnnt}.nonterminalton; } public String getTypeUnparse() { return "${escapeString(ns.unparse)}"; } diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 7e29ceeef..85b754bb2 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -32,7 +32,7 @@ public void runingDebug(DecoratedNode tree) { System.out.println("Enter characters, and 'q' to quit."); String userInput; String[] userInputList; - boolean toggleProdDisplay = true; + boolean toggleNameDisplay = false; boolean toggleCStackDisplay = true; boolean toggleHeadlessAttributes = false; String[] toggleChoices = {"prodDisplay", "cStackDisplay", "fullAttributeNames"}; @@ -41,9 +41,9 @@ public void runingDebug(DecoratedNode tree) { this.currentNode = tree; this.nodeStack = new Stack(); - if(toggleProdDisplay){ + if(toggleNameDisplay){ //printNames(currentNode); - printProduction(currentNode); + printName(currentNode); } // creating a context stack when we run the debugger @@ -79,8 +79,8 @@ public void runingDebug(DecoratedNode tree) { nodeStack.push(currentNode); currentNode = currentNode.getParent(); //System.out.println("going to parent"); - if(toggleProdDisplay){ - printProduction(currentNode); + if(toggleNameDisplay){ + printName(currentNode); } // if we navigate up to a parent, push it on to the stack (?) cStack.pop(); @@ -121,8 +121,8 @@ public void runingDebug(DecoratedNode tree) { else{ nodeStack.push(currentNode); currentNode = childNode; - if(toggleProdDisplay){ - printProduction(currentNode); + if(toggleNameDisplay){ + printName(currentNode); } // if we navigate down to a child, push it on to the stack cStack.push(currentNode); @@ -144,8 +144,8 @@ public void runingDebug(DecoratedNode tree) { DecoratedNode newNode = nodeStack.pop(); currentNode = newNode; //System.out.println("undoing last movement"); - if(toggleProdDisplay){ - printProduction(currentNode); + if(toggleNameDisplay){ + printName(currentNode); } // remove from the stack cStack.pop(); @@ -169,8 +169,8 @@ public void runingDebug(DecoratedNode tree) { else{ System.out.println("going forward"); currentNode = childNode; - if(toggleProdDisplay){ - printProduction(currentNode); + if(toggleNameDisplay){ + printName(currentNode); } // if we navigate to a forward, push it on to the stack cStack.push(currentNode); @@ -185,24 +185,51 @@ public void runingDebug(DecoratedNode tree) { //TODO: known bug, don't know how to represent higher order nodes as decoratedNodes case "into": - if (userInputList.length != 2) { - System.out.println("invalid, correct usage: forwards "); - }else{ - childNode = into(currentNode, userInputList[1]); - if(childNode == null){ - System.out.println("invalid input"); + //A bit reptative right now but when I get a idea on how to list only the higer order nodes It will be better + String attributeNameinto = ""; + Integer attributeNuminto = 0; + List attributeListinto = allAttributesList(currentNode); + if (userInputList.length == 1) { + System.out.println("Which attribute?"); + String[] attriburteArrayinto = attributeListinto.toArray(new String[attributeListinto.size()]); + attributeNuminto = chooseFormList(inp, attriburteArrayinto); + if(attributeNuminto == -1){ + break; + }else if(attributeNuminto >= attributeListinto.size()){ + System.out.println("Invaild attribute number"); + break; + }else{ + attributeNameinto = attributeListinto.get(attributeNuminto); } - else{ - System.out.println("going into"); - currentNode = childNode; - // if(toggleProdDisplay){ - // printProduction(currentNode); - // } - // // if we navigate to a forward, push it on to the stack - // cStack.push(currentNode); - // // when we push, update and show the context - // cStack.show(); + }else if(userInputList.length == 2){ + try{ + attributeNuminto = Integer.parseInt(userInputList[1]); + attributeNameinto = attributeListinto.get(attributeNuminto); + }catch (NumberFormatException e) { + System.out.println("invalid, correct usage: view "); + break; + }catch (IndexOutOfBoundsException e){ + System.out.println("Index out of bounds"); + break; } + }else{ + System.out.println("invalid, correct usage: into "); + break; + } + childNode = into(currentNode, attributeNameinto); + if(childNode == null){ + System.out.println("invalid input"); + } + else{ + System.out.println("going into"); + currentNode = childNode; + // if(toggleNameDisplay){ + // printName(currentNode); + // } + // // if we navigate to a forward, push it on to the stack + // cStack.push(currentNode); + // // when we push, update and show the context + // cStack.show(); } break; @@ -217,8 +244,8 @@ public void runingDebug(DecoratedNode tree) { else{ System.out.println("going backwrds"); currentNode = childNode; - if(toggleProdDisplay){ - printProduction(currentNode); + if(toggleNameDisplay){ + printName(currentNode); } // if we navigate backwards, push it on to the stack (?) cStack.push(currentNode); @@ -238,12 +265,12 @@ public void runingDebug(DecoratedNode tree) { toggelChoice = userInputList[1]; } if(toggelChoice.equals("prodDisplay")){ - if(toggleProdDisplay){ + if(toggleNameDisplay){ System.out.println("Production Display off"); - toggleProdDisplay = false; + toggleNameDisplay = false; }else{ System.out.println("Production Display on"); - toggleProdDisplay = true; + toggleNameDisplay = true; } }else if(toggelChoice.equals("fullAttributeNames")){ if(toggleHeadlessAttributes){ @@ -278,6 +305,7 @@ public void runingDebug(DecoratedNode tree) { //TODO:Implement this - use genericShow?, see ProductionDcl in grammer/silver/compiler/translation/java/core //Somehow this needs to create a new function for RTTI manager but current attempt does not work + //We want - user defined names (ex: left right), attribute equations (ex: left = parent + 1) and nearby code (filename and linenumber?) case "eq": if (userInputList.length != 1 && userInputList.length != 2) { System.out.println("invalid, correct usage: eq"); @@ -330,8 +358,7 @@ public void runingDebug(DecoratedNode tree) { List attributeList = allAttributesList(currentNode); if (userInputList.length == 1) { System.out.println("Which attribute?"); - List attriburteList = allAttributesList(currentNode); - String[] attriburteArray = attriburteList.toArray(new String[attriburteList.size()]); + String[] attriburteArray = attributeList.toArray(new String[attributeList.size()]); attributeNum = chooseFormList(inp, attriburteArray); if(attributeNum == -1){ break; @@ -353,7 +380,7 @@ public void runingDebug(DecoratedNode tree) { break; } }else{ - System.out.println("invalid, correct usage: down "); + System.out.println("invalid, correct usage: view "); break; } printAttrFromName(currentNode, attributeName); @@ -500,7 +527,7 @@ public DecoratedNode down(int child) // //} // return null; } - + public void printChildren(DecoratedNode node) { String child_productions[] = node.undecorate().getProdleton().getChildTypes(); @@ -535,6 +562,11 @@ public void printProduction(DecoratedNode node) System.out.print("\n"); } + public void printName(DecoratedNode node) + { + String name = node.undecorate().getProdleton().getName(); + System.out.println(name); + } // public void printNames(DecoratedNode node) // { @@ -640,6 +672,7 @@ public static List getLocalAttrs(DecoratedNode node) } //TODO: Add access to higher order attriburte + // Translation attribute or Decorated, locals only locals should all be decorated public DecoratedNode into(DecoratedNode node, String attriburteName){ Map attributeMap = allAttributesObjectMap(node); if (attributeMap.containsKey(attriburteName)) { @@ -679,7 +712,7 @@ public static Map allAttributesObjectMap(DecoratedNode node) //System.out.println("Synthisized!!! \"" + attribute + "\""); Integer index = nonterminalton.getSynOccursIndex(attribute); Lazy synthAttribute = node.getNode().getSynthesized(index); //breaks for forwarded nodes - Object o = synthAttribute.eval(node); + Object o = synthAttribute.eval(node); //.sythisized() found in Decorated node add thunks (.sythisizedlazy() then eval ) attributeMap.put(attribute, o); }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ //System.out.println("Inherited!!!"); From a160e87bfb637cff2bcbcc3cf984212ec60d616b Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Thu, 29 Feb 2024 16:53:55 -0600 Subject: [PATCH 20/64] new comments to improve finding is-new --- runtime/java/src/common/DecoratedNode.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index d3b52f273..50cd4d6bb 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -4,6 +4,8 @@ import java.util.Collection; import java.util.Map; +import javax.sound.midi.SysexMessage; + import silver.core.NOriginInfo; // import silver.core.OriginsUtils; import silver.core.PoriginOriginInfo; @@ -1095,6 +1097,11 @@ public boolean getIsNew() { // Should get only Nodes from here Object origin = oinfo.getChild(0); + if (origin instanceof Node) { + // Use this name + // System.out.println("NAME: " + (((Node)origin).getName())); + } + // For regular (non-root) nonterminals, there appear to be 2 origins, // the second of which is just true, so only use the first @@ -1116,6 +1123,9 @@ public boolean getIsNew() { String ostr = origin.toString(); // System.out.println("ORIGIN NAME: " + ostr); // Origin in concrete syntax case + + + // FIXME: Don't count on this! if (ostr.contains("_c@")) { // Never going to be new // System.out.println("CONCRETE SYNTAX ORIGIN"); From b9435c7be15bf2222b3f2e4d604d6b310c8118b8 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Thu, 29 Feb 2024 17:18:14 -0600 Subject: [PATCH 21/64] "comment changes" --- runtime/java/src/common/DecoratedNode.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 50cd4d6bb..17c5d9cdc 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -949,6 +949,7 @@ public DecoratedNode getRedex() { // Wrapper for recursive helper return this.getRedexHelper(this); } + private DecoratedNode getRedexHelper(DecoratedNode dn) { // For now assume abstract syntax tree root has null parent // or just that dn.parent repeatedly will eventually find null @@ -1162,7 +1163,9 @@ public String getPrettyPrint() { // Search until find name that is "pp" String name = this.self.getNameOfSynAttr(i); // Want last three characters to be ":pp" - if (name.substring(name.length() - 3).equals(":pp")) { + if (name.substring(name.length() - 3).toLowerCase.equals(":pp") || + name.substring(name.length() - 13).toLowerCase().equals(":pretty_print") || + name.substring(name.length() - 12).toLowerCase().equals(":prettyprint")) { Object pp = evalSyn(i); return pp.toString(); } @@ -1239,9 +1242,6 @@ public int getIsTranslation() { if (this.parent == null || this.parent instanceof TopNode || this.isRoot() || this.isMain()) { return 0; } - // else if (this.self.hasForward()) { - // return 1 + this.parent.getIsTranslation(); - // } else if (this.getIsContractum()) { return 1 + this.parent.getIsTranslation(); } From e8258296de04c2c552856ed8aeb2098fe1cb3a93 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 12 Mar 2024 12:48:41 -0500 Subject: [PATCH 22/64] fix isRoot hack. No longer hacky --- runtime/java/src/common/DecoratedNode.java | 49 ++++++++++------------ 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 17c5d9cdc..88ec13aae 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -955,8 +955,7 @@ private DecoratedNode getRedexHelper(DecoratedNode dn) { // or just that dn.parent repeatedly will eventually find null // parent of DecoratedNode root is TopNode. Might need that and not null - if (dn == null || dn.parent == null || dn.parent instanceof TopNode || - dn.isRoot() || dn.isMain()) { + if (dn == null || dn.isRoot()) { return null; } @@ -975,8 +974,7 @@ public DecoratedNode getContractum() { private DecoratedNode getContractumHelper(DecoratedNode dn) { // For now assume abstract syntax tree root has null parent // or just that dn.parent repeatedly will eventually find null - if (dn == null || dn.parent == null || dn.parent instanceof TopNode || - dn.isRoot() || dn.isMain()) { + if (dn == null || dn.isRoot()) { return null; } @@ -1163,7 +1161,7 @@ public String getPrettyPrint() { // Search until find name that is "pp" String name = this.self.getNameOfSynAttr(i); // Want last three characters to be ":pp" - if (name.substring(name.length() - 3).toLowerCase.equals(":pp") || + if (name.substring(name.length() - 3).toLowerCase().equals(":pp") || name.substring(name.length() - 13).toLowerCase().equals(":pretty_print") || name.substring(name.length() - 12).toLowerCase().equals(":prettyprint")) { Object pp = evalSyn(i); @@ -1184,19 +1182,24 @@ public boolean getIsAttributeRoot() { } public boolean isRoot() { - return this.getNode().getName().contains("root"); - } - - public boolean isMain() { - return this.getNode().getName().contains("main"); - } + // return this.getNode().getName().contains("root"); + + // This is better solution + return + this.parent == null || + this.parent instanceof TopNode || + this.parent.parent == null || + this.parent.parent instanceof TopNode; + } + + // public boolean isMain() { + // // return this.getNode().getName().contains("main"); + // return this == null || this.parent == null || this.parent instanceof TopNode; + // } public void setIsAttributeRoot() { - // Had to hack this as well with this.parent.isMain() - if (! (this == null || this.parent instanceof TopNode || - this.isRoot() || this.isMain() || - this.parent == null || this.parent.isMain())) { + if (! (this == null || this.isRoot())) { // System.out.println("SET-IS-ATTR: " + this.toString()); Map map = Debug.allAttributesObjectMap(this.parent); @@ -1215,7 +1218,7 @@ public void setIsAttributeRoot() { public int getIsAttribute() { - if (this.parent == null || this.isRoot() || this.isMain()) { + if (this == null || this.isRoot()) { return 0; } else { @@ -1225,21 +1228,15 @@ public int getIsAttribute() { return this.parent.getIsAttribute(); } } - - // For now, assume there is a Silver annotation - // "is-attribute-root" of type String on - // higher-order attributes that is set to "TRUE" - // when true and not existant or FALSE when false - // https://melt.cs.umn.edu/silver/ref/decl/annotations/ - - public int getIsTranslation() { // See how many parents are contractums // System.out.println("GET-IS-TRANSLATION node:" + this.toString()); - // System.out.println("GET-IS-TRANSLATION has contractum:" + this.self.hasForward()); - if (this.parent == null || this.parent instanceof TopNode || this.isRoot() || this.isMain()) { + // System.out.println("GET-IS-TRANSLATION has contractum:" + this.getIsContractum()); + // Calling parent repeatedly will ignore forwarding nodes, so operate on + // getIsContractum only as the case to determine whether forwarding occurs or not + if (this == null || this.isRoot()) { return 0; } else if (this.getIsContractum()) { From 3075f441773245c2e77545c45fea3c0c8ad07702 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Wed, 13 Mar 2024 01:29:19 -0500 Subject: [PATCH 23/64] down is not allowed on redex --- runtime/java/src/common/Debug.java | 6 +++++- runtime/java/src/common/RTTIManager.java | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 85b754bb2..2d019ec2b 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -94,7 +94,11 @@ public void runingDebug(DecoratedNode tree) { case "down": case "d": int childNum = -1; - if (userInputList.length == 1) { + if(currentNode.getNode().hasForward()){ + System.out.println("can't go down on a forwarding node"); + break; + } + else if (userInputList.length == 1) { System.out.println("Which child?"); childNum = chooseFormList(inp, currentNode.undecorate().getProdleton().getChildTypes()); if(childNum == -1){ diff --git a/runtime/java/src/common/RTTIManager.java b/runtime/java/src/common/RTTIManager.java index 75c2faa41..dac5e1505 100644 --- a/runtime/java/src/common/RTTIManager.java +++ b/runtime/java/src/common/RTTIManager.java @@ -85,7 +85,9 @@ public abstract T constructDirect( final Object[] annos); // NO reify or other checking, used by native[De]Serialize public abstract String getName(); + //need to return an array literal //public abstract String[] getChildNames(); + //public static final String[] child_names = new String[${implode(",", namedSig.inputNames)}]; - but names of children public abstract Nonterminalton getNonterminalton(); public abstract String getTypeUnparse(); // Nominally opaque representation of the type From 48bd0bc369960ebebb0722a3a9d5dbbc7fbede95 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Wed, 13 Mar 2024 21:25:09 -0500 Subject: [PATCH 24/64] args ready, but file/html contextualization still not ready --- runtime/java/src/common/Debug.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 2d019ec2b..175db4803 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -49,9 +49,9 @@ public void runingDebug(DecoratedNode tree) { // creating a context stack when we run the debugger CMDContextVisualization cStack = new CMDContextVisualization("********************************"); // if we want a file visualization: - // FileContextVisualization cStack = new FileContextVisualization(); + // FileContextVisualization cStack = new FileContextVisualization("context.txt", "********************************"); // if we want an HTML visualization: - // HTMLContextVisualization cStack = new HTMLContextVisualization(); + // HTMLContextVisualization cStack = new HTMLContextVisualization("********************************"); cStack.push(currentNode); if(toggleCStackDisplay){ cStack.show(); From 84913619e183703263597fc5fa7f6755d5c96f74 Mon Sep 17 00:00:00 2001 From: Morgan Bozeman Date: Thu, 14 Mar 2024 14:54:19 -0500 Subject: [PATCH 25/64] added file context visualization --- .../src/common/CMDContextVisualization.java | 2 +- runtime/java/src/common/Debug.java | 6 +++--- .../src/common/FileContextVisualization.java | 20 +++++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/runtime/java/src/common/CMDContextVisualization.java b/runtime/java/src/common/CMDContextVisualization.java index 2ab9c90be..c9b30c6d2 100644 --- a/runtime/java/src/common/CMDContextVisualization.java +++ b/runtime/java/src/common/CMDContextVisualization.java @@ -4,7 +4,7 @@ public class CMDContextVisualization extends ContextVisualization { private final String printFormat = "%s\n%s\n%s\n"; - private String border; + protected String border; public CMDContextVisualization(String border) { super(); diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 175db4803..ea5456097 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -47,9 +47,9 @@ public void runingDebug(DecoratedNode tree) { } // creating a context stack when we run the debugger - CMDContextVisualization cStack = new CMDContextVisualization("********************************"); + // CMDContextVisualization cStack = new CMDContextVisualization("********************************"); // if we want a file visualization: - // FileContextVisualization cStack = new FileContextVisualization("context.txt", "********************************"); + FileContextVisualization cStack = new FileContextVisualization("context.txt", "********************************"); // if we want an HTML visualization: // HTMLContextVisualization cStack = new HTMLContextVisualization("********************************"); cStack.push(currentNode); @@ -784,4 +784,4 @@ public Object getObject() { return objectValue; } } -} \ No newline at end of file +} diff --git a/runtime/java/src/common/FileContextVisualization.java b/runtime/java/src/common/FileContextVisualization.java index 8970d254d..cbeffeef9 100644 --- a/runtime/java/src/common/FileContextVisualization.java +++ b/runtime/java/src/common/FileContextVisualization.java @@ -1,8 +1,11 @@ package common; import java.io.File; +import java.io.FileWriter; import java.io.FileNotFoundException; import java.io.PrintStream; +import java.util.Iterator; +import java.io.IOException; public class FileContextVisualization extends CMDContextVisualization { protected final String filename; @@ -15,15 +18,20 @@ public FileContextVisualization(String filename, String border) { @Override public void show() { + File file = new File(this.filename); - try(PrintStream replacementStream = new PrintStream(file)) { - System.setOut(replacementStream); - super.show(); - replacementStream.close(); - System.setOut(System.out); - } catch (FileNotFoundException e) { + try{ + FileWriter myWriter = new FileWriter(this.filename); + Iterator iterator = this.contextStack.iterator(); + while (iterator.hasNext()) { + NodeContextMessage nodeContextMessage = iterator.next(); + myWriter.write(this.border + "\n" + nodeContextMessage.toString() + "\n" + this.border); + } + myWriter.close(); + } + catch (IOException e) { e.printStackTrace(); } } From a9cd08da1517fd8493ab25fbfde4a118f3a8ebef Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Mon, 18 Mar 2024 13:23:26 -0500 Subject: [PATCH 26/64] started work on simplified context stack made from full stack (class ContextStack) --- runtime/java/src/common/ContextStack.java | 10 ++ runtime/java/src/common/Debug.java | 4 +- runtime/java/src/common/DecoratedNode.java | 22 ++- runtime/java/src/common/Feature.java | 53 +++++++ .../java/src/common/NodeContextMessage.java | 48 ++++++ runtime/java/src/common/Production.java | 23 +++ .../java/src/common/SimplifiedContextBox.java | 23 +++ .../src/common/SimplifiedContextStack.java | 150 ++++++++++++++++++ 8 files changed, 328 insertions(+), 5 deletions(-) create mode 100644 runtime/java/src/common/Feature.java create mode 100644 runtime/java/src/common/Production.java create mode 100644 runtime/java/src/common/SimplifiedContextBox.java create mode 100644 runtime/java/src/common/SimplifiedContextStack.java diff --git a/runtime/java/src/common/ContextStack.java b/runtime/java/src/common/ContextStack.java index 6922f6a72..c5b401d93 100644 --- a/runtime/java/src/common/ContextStack.java +++ b/runtime/java/src/common/ContextStack.java @@ -32,6 +32,16 @@ public Iterator iterator() { return this.stack.iterator(); } + public NodeContextMessage get(int index) { + // Index 0 is the bottom of the stack + int stackIndex = this.stack.size() - index - 1; + if (stackIndex >= 0 && stackIndex < this.stack.size()) { + return this.stack.get(stackIndex); + } else { + throw new IndexOutOfBoundsException("Index " + index + " is out of bounds."); + } + } + private Stack stack = new Stack(); private int height = 0; // Used for indices diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index ea5456097..235876d07 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -251,8 +251,8 @@ else if (userInputList.length == 1) { if(toggleNameDisplay){ printName(currentNode); } - // if we navigate backwards, push it on to the stack (?) - cStack.push(currentNode); + // if we navigate backwards, pop (?) + cStack.pop(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 88ec13aae..9cd6d29dd 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -881,7 +881,7 @@ public final Object evalInhSomehowButPublic(final int attribute) { // getEndCoordinates() DONE // getOrigin() DONE - // getIsNew() TODO + // getIsNew() MOSTLY-DONE (concrete syntax node hacks still) // getPrettyPrint() DONE @@ -1068,10 +1068,14 @@ public NOriginInfo getOrigin() { // return null; } + + // TODO: only check getIsNew on is-translation nodes (to avoid _c concrete syntax hack!) // If not a contractum or redex, // if getOrigin(this) == getRedex(this) // implies a node is "newly" created // like const(0) from neg(x) -> sub(0, x) + // Also require it to be Is-TRANSLATION + // (since only forwarding can do this anyway) public boolean getIsNew() { // Silver origin tracking does // not return Nodes or Decorated nodes @@ -1082,6 +1086,12 @@ public boolean getIsNew() { // check if the result is a PoriginOriginInfo // or PoriginAndRedexOriginInfo, if it is then // pull out the first child and do .getName() on that" + + this.compute_redex_contractum(); + if (this.getIsTranslation() < 1) { + // Cannot be a translation + return false; + } NOriginInfo oinfo = OriginsUtil.getOriginOrNull(this.self); // System.out.println("NOriginInfo: " + oinfo); @@ -1120,11 +1130,11 @@ public boolean getIsNew() { // P and @ if origin is another node of the same name. // Also, there will be a '_c@' if concrete syntax (so false if _c@ in) String ostr = origin.toString(); - // System.out.println("ORIGIN NAME: " + ostr); + System.out.println("ORIGIN NAME: " + ostr); // Origin in concrete syntax case - // FIXME: Don't count on this! + // // FIXME: Don't count on this! if (ostr.contains("_c@")) { // Never going to be new // System.out.println("CONCRETE SYNTAX ORIGIN"); @@ -1135,6 +1145,12 @@ else if (ostr.contains("P" + prod_name + "@")) { // Not new since same name return false; } + + // if (ostr.contains("P" + prod_name + "@")) { + // // System.out.println("ABSTRACT SYNTAX ORIGIN"); + // // Not new since same name + // return false; + // } else { // System.out.println("!!!!!!!!IS-NEW!!!!!!!!"); return true; diff --git a/runtime/java/src/common/Feature.java b/runtime/java/src/common/Feature.java new file mode 100644 index 000000000..62f97b55e --- /dev/null +++ b/runtime/java/src/common/Feature.java @@ -0,0 +1,53 @@ +package common; +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + +public class Feature { + public String base_prod; + public String label; + public String target; + public String sep; + + public Feature(String base_prod, String label) { + this.base_prod = base_prod; + this.label = label; + this.target = ""; + this.sep = ""; + } + + public Feature(String base_prod, String label, String target) { + this.base_prod = base_prod; + this.label = label; + this.target = target; + this.sep = ""; + } + + public void setSep() { + if (this.label.contains("redex")) { + this.sep = "to"; + } + else if (this.label.contains("contractum")) { + this.sep = "of"; + } + else if (this.label.contains("higher-order")) { + this.sep = ""; + } + else if (this.label.contains("new")) { + this.sep = ""; + } + else { + this.sep = "INVALID LABEL"; + } + } + + public String toString() { + if (! this.label.contains("new")) { + return this.base_prod + ": " + this.label + + " (" + this.sep + " " + this.target + ")"; + } + else { + return this.base_prod + ": " + this.label; + } + } +} diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index bf83ffe6c..25955402c 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -205,17 +205,41 @@ public String toString() { // private static int next_index = 0; // Section 1. Header will contain TRANSLATION and/or HIGHER-ORDER + public int getTranslationX() { + return this.translation_x; + } + public int getHigherOrderY() { + return this.higher_order_y; + } private int translation_x; private int higher_order_y; // Section 2. Actual text representation // (either copied from file or prity print (pp) represenation) + public String getTextRepr() { + return this.text_repr; + } private String text_repr; // Section 3. Production name and file lines + public String getProdName() { + return this.prod_name; + } private String prod_name; + + public String getFilenmae() { + return this.filename; + } private String filename; + + public FileCoordinate getFileCoordianteStart() { + return this.fc_start; + } private FileCoordinate fc_start; + + public FileCoordinate getFileCoordianteEnd() { + return this.fc_end; + } private FileCoordinate fc_end; // Section 4. Labels and associated info @@ -225,4 +249,28 @@ public String toString() { private boolean is_new; private boolean is_attribute_root; private int attribute_of; + + public boolean isRedex() { + return is_redex; + } + + public boolean isContractum() { + return is_contractum; + } + + public int getContractumOf() { + return contractum_of; + } + + public boolean isNew() { + return is_new; + } + + public boolean isAttributeRoot() { + return is_attribute_root; + } + + public int getAttributeOf() { + return attribute_of; + } } \ No newline at end of file diff --git a/runtime/java/src/common/Production.java b/runtime/java/src/common/Production.java new file mode 100644 index 000000000..e56b0d30a --- /dev/null +++ b/runtime/java/src/common/Production.java @@ -0,0 +1,23 @@ +package common; +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + +public class Production { + public String name; + public int index; + + public Production(String name, int index) { + this.name = name; + this.index = index; + } + + public String toString() { + if (this.index == 0) { + return this.name; + } + else { + return this.name + " (" + this.index + ")"; + } + } +} \ No newline at end of file diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java new file mode 100644 index 000000000..8a359a728 --- /dev/null +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -0,0 +1,23 @@ +package common; +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + +public class SimplifiedContextBox { + + // 4 sections + + // 1. Tree Order + public int translation_x; + public int higher_order_y; + + // 2. Text Syntax + public String text_syntax; + public String syntax_to_highlight; + + // 3. Productions Visited + public Production prods_visited[]; + + // 4. Interesting Features + public Feature features[]; +} \ No newline at end of file diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java new file mode 100644 index 000000000..8b82efc83 --- /dev/null +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -0,0 +1,150 @@ +package common; + +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + +// Basically a decorator over a ContextStack to +// generate a simplified (one node per tree order) +public class SimplifiedContextStack { + + public SimplifiedContextStack(ContextStack full_stack) { + this.full_stack = full_stack; + this.makeSimplifiedStack(); + } + + private void makeSimplifiedStack() { + this.fillInPartition(); + + // Now make one box per partition + int prev_partition_index = -1; + int start = 0; + int end = -1; + for (int i = 0; i < this.partition.length; i++) { + if (this.partition[i] > prev_partition_index) { + // Make box on existing start and end + SimplifiedContextBox sbox = this.makeSimplifiedBox(start, end); + this.simple_stack.push(sbox); + start = i; + end = start; + } + else { + end++; + } + } + // Last one + SimplifiedContextBox sbox = this.makeSimplifiedBox(start, end); + this.simple_stack.push(sbox); + } + + // Inclusive Partition Indices + private SimplifiedContextBox makeSimplifiedBox(int i, int j) { + // 4 sections to fill in + SimplifiedContextBox sbox = new SimplifiedContextBox(); + + NodeContextMessage first = this.full_stack.get(i); + NodeContextMessage last = this.full_stack.get(j); + // 1. Tree Order Trivial + sbox.translation_x = first.getTranslationX(); + sbox.higher_order_y = first.getHigherOrderY(); + + // 2. Text Syntax (highlight later when rendering) + sbox.text_syntax = first.getTextRepr(); + sbox.syntax_to_highlight = last.getTextRepr(); + + // 3. Need some counting logic to keep track of unique indices + Production all_prods[] = new Production[j - i + 1]; + for (int index = i; index <= j; index++) { + all_prods[index].name = this.full_stack.get(index).getProdName(); + all_prods[index].index = -1; + } + + + // Going to be fine with O(n^2) worst case time complexity here for now + + // Unique prod names get the 0 index (not to be displayed) + // Non-unique prod names are numbered from 1..n, so need extra + // scan afterwards to separate unique 1 -> 0 from actual 1 + for (int prod_index = 0; prod_index < all_prods.length; prod_index++) { + + int seq_num = 1; + String name = all_prods[prod_index].name; + + for (int visit_index = 0; visit_index < prod_index; visit_index++) { + String cur_name = all_prods[visit_index].name; + if (cur_name.compareTo(name) == 0) { + seq_num++; + } + } + all_prods[prod_index].index = seq_num; + } + + // All prod indices >= 1. Find if need to differentiate 1 into 0 now + // if truly unique and not start of 1..n sequence of indices + for (int prod_index = 0; prod_index < all_prods.length; prod_index++) { + + if (all_prods[prod_index].index == 1) { + boolean is_unique = true; + for (int k = 0; k < all_prods.length; k++) { + if (k != prod_index && + (all_prods[k].name.compareTo(all_prods[prod_index].name) == 0)) { + is_unique = false; + break; + } + } + if (is_unique) { + all_prods[prod_index].index = 0; + } + } + } + sbox.prods_visited = all_prods; + + // TODO 4. Make features list now + sbox.features = null; + + + return sbox; + + + } + + private void fillInPartition() { + int previous_x = 0; + int previous_y = 0; + int partition_index = 0; + for (int i = 0; i < this.full_stack.get_height(); i++) { + NodeContextMessage node = this.full_stack.get(0); + int cur_x = node.getTranslationX(); + int cur_y = node.getHigherOrderY(); + if (cur_x == previous_x && cur_y == previous_y) { + // Within same set of partition + this.partition[i] = partition_index; + } + else { + previous_x = cur_x; + previous_y = cur_y; + // Increment partition index + partition_index++; + this.partition[i] = partition_index; + } + } + } + + public Stack getSimplifiedStack() { + return this.simple_stack; + } + + + private ContextStack full_stack; + private Stack simple_stack = + new Stack(); + + // Put 0 for each respective element in the first + // stack partition, then 1, etc. Index 0 into stack is bottom + private int[] partition = new int[full_stack.get_height()]; + +} + + + + From c5abf389e259d34304bd3e45ed2d26de4a6128b3 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Mon, 18 Mar 2024 13:25:15 -0500 Subject: [PATCH 27/64] removed redundant dependencies --- runtime/java/src/common/Feature.java | 3 --- runtime/java/src/common/Production.java | 3 --- runtime/java/src/common/SimplifiedContextBox.java | 3 --- runtime/java/src/common/SimplifiedContextStack.java | 1 - 4 files changed, 10 deletions(-) diff --git a/runtime/java/src/common/Feature.java b/runtime/java/src/common/Feature.java index 62f97b55e..c9e874d73 100644 --- a/runtime/java/src/common/Feature.java +++ b/runtime/java/src/common/Feature.java @@ -1,7 +1,4 @@ package common; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; public class Feature { public String base_prod; diff --git a/runtime/java/src/common/Production.java b/runtime/java/src/common/Production.java index e56b0d30a..a7e2a1e0c 100644 --- a/runtime/java/src/common/Production.java +++ b/runtime/java/src/common/Production.java @@ -1,7 +1,4 @@ package common; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; public class Production { public String name; diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index 8a359a728..64f29f691 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -1,7 +1,4 @@ package common; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; public class SimplifiedContextBox { diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 8b82efc83..824139721 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -1,7 +1,6 @@ package common; import java.util.Iterator; -import java.util.List; import java.util.Stack; // Basically a decorator over a ContextStack to From 2bc898bce5a145d5215592b2f2287a89087dc96e Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Mon, 18 Mar 2024 18:57:54 -0500 Subject: [PATCH 28/64] fixed prod names. Must use entire prods array --- .../src/common/SimplifiedContextStack.java | 57 ++++++++++++++----- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 824139721..5dc361ce7 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -2,14 +2,19 @@ import java.util.Iterator; import java.util.Stack; +import java.util.Arrays; // Basically a decorator over a ContextStack to -// generate a simplified (one node per tree order) +// generate a simplified (one node per tree order) staco public class SimplifiedContextStack { public SimplifiedContextStack(ContextStack full_stack) { this.full_stack = full_stack; + } + + public Stack getSimplifiedStack() { this.makeSimplifiedStack(); + return this.simple_stack; } private void makeSimplifiedStack() { @@ -38,6 +43,12 @@ private void makeSimplifiedStack() { // Inclusive Partition Indices private SimplifiedContextBox makeSimplifiedBox(int i, int j) { + + if (j > i) { + System.out.println("Invalid Partition Indices: " + i + ", " + j); + return null; + } + // 4 sections to fill in SimplifiedContextBox sbox = new SimplifiedContextBox(); @@ -52,14 +63,36 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { sbox.syntax_to_highlight = last.getTextRepr(); // 3. Need some counting logic to keep track of unique indices - Production all_prods[] = new Production[j - i + 1]; - for (int index = i; index <= j; index++) { + sbox.prods_visited = Arrays.copyOfRange(this.productions, i, j + 1); + + // TODO 4. Make features list now + sbox.features = null; + + + return sbox; + + + } + + private void SetAllProds() { + + if (all_prods_static.length > 1) { + this.productions = all_prods_static; + return; + } + // Only do this once + // Not worried about multiple instances of SimplifiedContextStack; + // rather, don't want to do this for every SimplifiedContextBox created + + Production all_prods[] = new Production[this.full_stack.get_height()]; + for (int index = 0; index < this.full_stack.get_height(); index++) { all_prods[index].name = this.full_stack.get(index).getProdName(); all_prods[index].index = -1; } // Going to be fine with O(n^2) worst case time complexity here for now + // Simply a prototype implementation of simplified stack // Unique prod names get the 0 index (not to be displayed) // Non-unique prod names are numbered from 1..n, so need extra @@ -96,15 +129,10 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { } } } - sbox.prods_visited = all_prods; - - // TODO 4. Make features list now - sbox.features = null; - - return sbox; - - + this.productions = all_prods; + all_prods_static = all_prods; + return; } private void fillInPartition() { @@ -129,14 +157,15 @@ private void fillInPartition() { } } - public Stack getSimplifiedStack() { - return this.simple_stack; - } + private ContextStack full_stack; private Stack simple_stack = new Stack(); + + private Production productions[]; + private static Production all_prods_static[]; // Put 0 for each respective element in the first // stack partition, then 1, etc. Index 0 into stack is bottom From eefd149e0ed66cc6d46276adf108a48987ae9d39 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Mon, 18 Mar 2024 19:17:15 -0500 Subject: [PATCH 29/64] changed to dynamically be able to rebuild a simplified stack within the same SimplifiedContextStack --- runtime/java/src/common/SimplifiedContextStack.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 5dc361ce7..a461aa1fe 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -13,11 +13,15 @@ public SimplifiedContextStack(ContextStack full_stack) { } public Stack getSimplifiedStack() { + this.need_set_all_prods = true; this.makeSimplifiedStack(); return this.simple_stack; } private void makeSimplifiedStack() { + // Clear previous simplified stack to get a brand new one + this.simple_stack = new Stack(); + this.fillInPartition(); // Now make one box per partition @@ -63,6 +67,7 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { sbox.syntax_to_highlight = last.getTextRepr(); // 3. Need some counting logic to keep track of unique indices + this.SetAllProds(); sbox.prods_visited = Arrays.copyOfRange(this.productions, i, j + 1); // TODO 4. Make features list now @@ -76,8 +81,7 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { private void SetAllProds() { - if (all_prods_static.length > 1) { - this.productions = all_prods_static; + if (! this.need_set_all_prods) { return; } // Only do this once @@ -131,7 +135,7 @@ private void SetAllProds() { } this.productions = all_prods; - all_prods_static = all_prods; + this.need_set_all_prods = false; return; } @@ -164,8 +168,8 @@ private void fillInPartition() { private Stack simple_stack = new Stack(); + private boolean need_set_all_prods = true; private Production productions[]; - private static Production all_prods_static[]; // Put 0 for each respective element in the first // stack partition, then 1, etc. Index 0 into stack is bottom From 0188352fb300666578b8246803d0c2e9149c878d Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 19 Mar 2024 13:21:02 -0500 Subject: [PATCH 30/64] prototyped simplified context stack fully now --- runtime/java/src/common/DecoratedNode.java | 6 --- runtime/java/src/common/Feature.java | 11 ++-- .../java/src/common/NodeContextMessage.java | 5 -- .../java/src/common/SimplifiedContextBox.java | 5 +- .../src/common/SimplifiedContextStack.java | 51 +++++++++++++++++-- 5 files changed, 56 insertions(+), 22 deletions(-) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 9cd6d29dd..3f8cf17a1 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -1145,12 +1145,6 @@ else if (ostr.contains("P" + prod_name + "@")) { // Not new since same name return false; } - - // if (ostr.contains("P" + prod_name + "@")) { - // // System.out.println("ABSTRACT SYNTAX ORIGIN"); - // // Not new since same name - // return false; - // } else { // System.out.println("!!!!!!!!IS-NEW!!!!!!!!"); return true; diff --git a/runtime/java/src/common/Feature.java b/runtime/java/src/common/Feature.java index c9e874d73..567ee723a 100644 --- a/runtime/java/src/common/Feature.java +++ b/runtime/java/src/common/Feature.java @@ -20,15 +20,15 @@ public Feature(String base_prod, String label, String target) { this.sep = ""; } - public void setSep() { - if (this.label.contains("redex")) { + private void setSep() { + if (this.label.contains("redex") && ! this.target.equals("")) { this.sep = "to"; } else if (this.label.contains("contractum")) { this.sep = "of"; } - else if (this.label.contains("higher-order")) { - this.sep = ""; + else if (this.label.contains("attribute")) { + this.sep = "of"; } else if (this.label.contains("new")) { this.sep = ""; @@ -39,7 +39,8 @@ else if (this.label.contains("new")) { } public String toString() { - if (! this.label.contains("new")) { + this.setSep(); + if (! this.target.equals("")) { return this.base_prod + ": " + this.label + " (" + this.sep + " " + this.target + ")"; } diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index 25955402c..05c4f0990 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -96,11 +96,6 @@ public NodeContextMessage(DecoratedNode node, int num_index) { this.has_been_initialized = true; } - // private void set_index() { - // next_index++; - // this.num_index = next_index; - // } - // Set translation_x and translation_x bools here // Is there a way to know something is an attribute // just from its node values? diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index 64f29f691..6a4fa910a 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -1,5 +1,8 @@ package common; +import java.util.ArrayList; +import java.util.List; + public class SimplifiedContextBox { // 4 sections @@ -16,5 +19,5 @@ public class SimplifiedContextBox { public Production prods_visited[]; // 4. Interesting Features - public Feature features[]; + public List features; } \ No newline at end of file diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index a461aa1fe..b22a00441 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -3,9 +3,11 @@ import java.util.Iterator; import java.util.Stack; import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; // Basically a decorator over a ContextStack to -// generate a simplified (one node per tree order) staco +// generate a simplified (one node per tree order) stack public class SimplifiedContextStack { public SimplifiedContextStack(ContextStack full_stack) { @@ -70,13 +72,52 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { this.SetAllProds(); sbox.prods_visited = Arrays.copyOfRange(this.productions, i, j + 1); - // TODO 4. Make features list now - sbox.features = null; - + // Make features list now (list, not array, since unknown length) + sbox.features = new ArrayList(); + this.fillInFeaturesList(sbox, i, j); return sbox; + } + + private void fillInFeaturesList(SimplifiedContextBox sbox, int i, int j) { - + for (int k = i; k <= j; k++) { + NodeContextMessage node = this.full_stack.get(k); + + if (node.isRedex()) { + String nodeName = productions[k].toString(); + String targetName = ""; + if (k < j) { + targetName = productions[k + 1].toString(); + } + Feature f = new Feature(nodeName, "redex", targetName); + sbox.features.add(f); + } + if (node.isContractum()) { + String nodeName = productions[k].toString(); + String targetName = ""; + if (k > 0) { + targetName = productions[k - 1].toString(); + } + Feature f = new Feature(nodeName, "contractum", targetName); + sbox.features.add(f); + } + if (node.isNew()) { + String nodeName = productions[k].toString(); + // No origin tracking to find prod name of origin + Feature f = new Feature(nodeName, "new"); + sbox.features.add(f); + } + if (node.isAttributeRoot()) { + String nodeName = productions[k].toString(); + String targetName = ""; + if (k > 0) { + targetName = productions[k - 1].toString(); + } + Feature f = new Feature(nodeName, "attribute root", targetName); + sbox.features.add(f); + } + } } private void SetAllProds() { From c552b65c90b26f2773e1fb29b7b9033db9e2c8ca Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 19 Mar 2024 17:40:50 -0500 Subject: [PATCH 31/64] added commented lines that need to be debugged --- runtime/java/src/common/ContextVisualization.java | 4 ++++ runtime/java/src/common/Debug.java | 8 ++++++++ runtime/java/src/common/SimplifiedContextStack.java | 7 ++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/runtime/java/src/common/ContextVisualization.java b/runtime/java/src/common/ContextVisualization.java index 3bbc24f4b..f3efd0b06 100644 --- a/runtime/java/src/common/ContextVisualization.java +++ b/runtime/java/src/common/ContextVisualization.java @@ -16,4 +16,8 @@ public NodeContextMessage pop() { } public abstract void show(); + + public ContextStack getContextStack() { + return this.contextStack; + } } diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 235876d07..e9d265130 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -56,6 +56,14 @@ public void runingDebug(DecoratedNode tree) { if(toggleCStackDisplay){ cStack.show(); } + + // Fine to call this + ContextStack contextStack = (ContextStack)cStack.getContextStack(); + // System.out.println(cStack); + + // Need to debug why first line causes NullPointerException before SimplifiedContextStack constructor called + // SimplifiedContextStack sStack = new SimplifiedContextStack(cStack.getContextStack()); + // sStack.getSimplifiedStack(); //Control loop loop: do { diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index b22a00441..7f6e58bd0 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -21,6 +21,7 @@ public Stack getSimplifiedStack() { } private void makeSimplifiedStack() { + // Clear previous simplified stack to get a brand new one this.simple_stack = new Stack(); @@ -181,6 +182,9 @@ private void SetAllProds() { } private void fillInPartition() { + + this.partition = new int[full_stack.get_height()]; + int previous_x = 0; int previous_y = 0; int partition_index = 0; @@ -202,9 +206,6 @@ private void fillInPartition() { } } - - - private ContextStack full_stack; private Stack simple_stack = new Stack(); From 1a150f6d17b69aff926389400292bd8fdded7d3e Mon Sep 17 00:00:00 2001 From: Lucas Kramer Date: Mon, 25 Mar 2024 12:37:31 -0700 Subject: [PATCH 32/64] Get feature/agnosis building again --- .../translation/java/core/ProductionDcl.sv | 5 ----- runtime/java/src/common/Production.java | 20 ------------------- runtime/java/src/common/RTTIManager.java | 2 -- .../java/src/common/SimplifiedContextBox.java | 2 +- .../src/common/SimplifiedContextStack.java | 19 ++++++++++++++++++ 5 files changed, 20 insertions(+), 28 deletions(-) delete mode 100644 runtime/java/src/common/Production.java diff --git a/grammars/silver/compiler/translation/java/core/ProductionDcl.sv b/grammars/silver/compiler/translation/java/core/ProductionDcl.sv index 7e8dd81a8..2888d8488 100644 --- a/grammars/silver/compiler/translation/java/core/ProductionDcl.sv +++ b/grammars/silver/compiler/translation/java/core/ProductionDcl.sv @@ -260,11 +260,6 @@ ${if isData then "" else s""" return "${fName}"; } - @Override - public String[] getChildNames() { - return namedSig.inputNames; - } - ${otImpl} @Override diff --git a/runtime/java/src/common/Production.java b/runtime/java/src/common/Production.java deleted file mode 100644 index a7e2a1e0c..000000000 --- a/runtime/java/src/common/Production.java +++ /dev/null @@ -1,20 +0,0 @@ -package common; - -public class Production { - public String name; - public int index; - - public Production(String name, int index) { - this.name = name; - this.index = index; - } - - public String toString() { - if (this.index == 0) { - return this.name; - } - else { - return this.name + " (" + this.index + ")"; - } - } -} \ No newline at end of file diff --git a/runtime/java/src/common/RTTIManager.java b/runtime/java/src/common/RTTIManager.java index 36ab22add..fc72d060e 100644 --- a/runtime/java/src/common/RTTIManager.java +++ b/runtime/java/src/common/RTTIManager.java @@ -86,8 +86,6 @@ public abstract T constructDirect( public abstract String getName(); //need to return an array literal - //public abstract String[] getChildNames(); - //public static final String[] child_names = new String[${implode(",", namedSig.inputNames)}]; - but names of children public abstract Nonterminalton getNonterminalton(); public abstract String getTypeUnparse(); // Nominally opaque representation of the type diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index 6a4fa910a..337a9fce1 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -16,7 +16,7 @@ public class SimplifiedContextBox { public String syntax_to_highlight; // 3. Productions Visited - public Production prods_visited[]; + public SimplifiedContextStack.Production prods_visited[]; // 4. Interesting Features public List features; diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 7f6e58bd0..1ff76f636 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -206,6 +206,25 @@ private void fillInPartition() { } } + public static class Production { + public String name; + public int index; + + public Production(String name, int index) { + this.name = name; + this.index = index; + } + + public String toString() { + if (this.index == 0) { + return this.name; + } + else { + return this.name + " (" + this.index + ")"; + } + } + } + private ContextStack full_stack; private Stack simple_stack = new Stack(); From 2003f3f8f5537faf1b99e59eebdda29251a27259 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 2 Apr 2024 20:57:14 -0500 Subject: [PATCH 33/64] simplified stack works now --- runtime/java/src/common/ContextStack.java | 7 +- runtime/java/src/common/Debug.java | 11 +- runtime/java/src/common/DecoratedNode.java | 2 +- runtime/java/src/common/ProductionName.java | 26 ++++ .../java/src/common/SimplifiedContextBox.java | 2 +- .../src/common/SimplifiedContextStack.java | 111 ++++++++++++------ 6 files changed, 118 insertions(+), 41 deletions(-) create mode 100644 runtime/java/src/common/ProductionName.java diff --git a/runtime/java/src/common/ContextStack.java b/runtime/java/src/common/ContextStack.java index c5b401d93..9b529c71b 100644 --- a/runtime/java/src/common/ContextStack.java +++ b/runtime/java/src/common/ContextStack.java @@ -6,6 +6,8 @@ import java.util.Iterator; import java.util.Stack; +import javax.swing.plaf.basic.BasicInternalFrameTitlePane.SystemMenuBar; + public class ContextStack { public void push(DecoratedNode n) { @@ -32,13 +34,12 @@ public Iterator iterator() { return this.stack.iterator(); } - public NodeContextMessage get(int index) { + public NodeContextMessage get(int stackIndex) { // Index 0 is the bottom of the stack - int stackIndex = this.stack.size() - index - 1; if (stackIndex >= 0 && stackIndex < this.stack.size()) { return this.stack.get(stackIndex); } else { - throw new IndexOutOfBoundsException("Index " + index + " is out of bounds."); + throw new IndexOutOfBoundsException("Index " + stackIndex + " is out of bounds."); } } diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index e9d265130..15e35cc82 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -59,11 +59,11 @@ public void runingDebug(DecoratedNode tree) { // Fine to call this ContextStack contextStack = (ContextStack)cStack.getContextStack(); - // System.out.println(cStack); + // System.out.println(cStack.getContextStack()); // Need to debug why first line causes NullPointerException before SimplifiedContextStack constructor called - // SimplifiedContextStack sStack = new SimplifiedContextStack(cStack.getContextStack()); - // sStack.getSimplifiedStack(); + SimplifiedContextStack sStack = new SimplifiedContextStack(contextStack); + sStack.getSimplifiedStack(); //Control loop loop: do { @@ -92,6 +92,7 @@ public void runingDebug(DecoratedNode tree) { } // if we navigate up to a parent, push it on to the stack (?) cStack.pop(); + sStack.getSimplifiedStack(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); @@ -138,6 +139,7 @@ else if (userInputList.length == 1) { } // if we navigate down to a child, push it on to the stack cStack.push(currentNode); + sStack.getSimplifiedStack(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); @@ -161,6 +163,7 @@ else if (userInputList.length == 1) { } // remove from the stack cStack.pop(); + sStack.getSimplifiedStack(); if(toggleCStackDisplay){ cStack.show(); } @@ -186,6 +189,7 @@ else if (userInputList.length == 1) { } // if we navigate to a forward, push it on to the stack cStack.push(currentNode); + sStack.getSimplifiedStack(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); @@ -261,6 +265,7 @@ else if (userInputList.length == 1) { } // if we navigate backwards, pop (?) cStack.pop(); + sStack.getSimplifiedStack(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 2bab47ee5..3ae168d96 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -1173,7 +1173,7 @@ public boolean getIsNew() { // P and @ if origin is another node of the same name. // Also, there will be a '_c@' if concrete syntax (so false if _c@ in) String ostr = origin.toString(); - System.out.println("ORIGIN NAME: " + ostr); + // System.out.println("ORIGIN NAME: " + ostr); // Origin in concrete syntax case diff --git a/runtime/java/src/common/ProductionName.java b/runtime/java/src/common/ProductionName.java new file mode 100644 index 000000000..ba7d4b68b --- /dev/null +++ b/runtime/java/src/common/ProductionName.java @@ -0,0 +1,26 @@ +package common; + +public class ProductionName { + public String name; + public int index; + + public ProductionName(String name, int index) { + this.name = name; + this.index = index; + } + + // Default constructor + public ProductionName() { + this.name = ""; + this.index = -1; + } + + public String toString() { + if (this.index == 0) { + return this.name; + } + else { + return this.name + " (" + this.index + ")"; + } + } +} \ No newline at end of file diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index 337a9fce1..335188107 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -16,7 +16,7 @@ public class SimplifiedContextBox { public String syntax_to_highlight; // 3. Productions Visited - public SimplifiedContextStack.Production prods_visited[]; + public ProductionName prods_visited[]; // 4. Interesting Features public List features; diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 1ff76f636..72ddbdf2a 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -12,11 +12,15 @@ public class SimplifiedContextStack { public SimplifiedContextStack(ContextStack full_stack) { this.full_stack = full_stack; + this.partition = new int[full_stack.get_height()]; } public Stack getSimplifiedStack() { this.need_set_all_prods = true; this.makeSimplifiedStack(); + + // UNCOMMENT-ME. FOR-DEMO + System.out.println("NEW SIMPLIFIED STACK SIZE: " + this.simple_stack.size()); return this.simple_stack; } @@ -26,18 +30,22 @@ private void makeSimplifiedStack() { this.simple_stack = new Stack(); this.fillInPartition(); - + // Now make one box per partition - int prev_partition_index = -1; + int prev_partition_index = 0; int start = 0; int end = -1; + + // System.out.println(this.partition[0]); for (int i = 0; i < this.partition.length; i++) { + if (this.partition[i] > prev_partition_index) { // Make box on existing start and end SimplifiedContextBox sbox = this.makeSimplifiedBox(start, end); this.simple_stack.push(sbox); start = i; end = start; + prev_partition_index++; } else { end++; @@ -51,7 +59,11 @@ private void makeSimplifiedStack() { // Inclusive Partition Indices private SimplifiedContextBox makeSimplifiedBox(int i, int j) { - if (j > i) { + // UNCOMMENT-ME. FOR-DEMO + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // System.out.println("MAKING SIMPLIFIED BOX: " + i + ", " + j); + + if (i > j) { System.out.println("Invalid Partition Indices: " + i + ", " + j); return null; } @@ -61,22 +73,38 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { NodeContextMessage first = this.full_stack.get(i); NodeContextMessage last = this.full_stack.get(j); + // System.out.println(first.getProdName()); + // 1. Tree Order Trivial sbox.translation_x = first.getTranslationX(); sbox.higher_order_y = first.getHigherOrderY(); - // 2. Text Syntax (highlight later when rendering) + // // 2. Text Syntax (highlight later when rendering) sbox.text_syntax = first.getTextRepr(); sbox.syntax_to_highlight = last.getTextRepr(); - // 3. Need some counting logic to keep track of unique indices + // // 3. Need some counting logic to keep track of unique indices this.SetAllProds(); sbox.prods_visited = Arrays.copyOfRange(this.productions, i, j + 1); - // Make features list now (list, not array, since unknown length) + // // Make features list now (list, not array, since unknown length) sbox.features = new ArrayList(); this.fillInFeaturesList(sbox, i, j); + + // for (i = 0; i < sbox.prods_visited.length; i++) { + // System.out.println(sbox.prods_visited[i]); + // } + // System.out.println("text: " + sbox.text_syntax); + // System.out.println("to highlight: " + sbox.syntax_to_highlight); + + // UNCOMMENT-ME. FOR-DEMO + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // System.out.println("first prod: " + sbox.prods_visited[0]); + // if (sbox.features.size() > 0) { + // System.out.println("first feature: " + sbox.features.get(0)); + // } + return sbox; } @@ -122,7 +150,8 @@ private void fillInFeaturesList(SimplifiedContextBox sbox, int i, int j) { } private void SetAllProds() { - + + // System.out.println(this.need_set_all_prods); if (! this.need_set_all_prods) { return; } @@ -130,10 +159,11 @@ private void SetAllProds() { // Not worried about multiple instances of SimplifiedContextStack; // rather, don't want to do this for every SimplifiedContextBox created - Production all_prods[] = new Production[this.full_stack.get_height()]; + ProductionName all_prods[] = new ProductionName[this.full_stack.get_height()]; for (int index = 0; index < this.full_stack.get_height(); index++) { - all_prods[index].name = this.full_stack.get(index).getProdName(); - all_prods[index].index = -1; + // System.out.println(all_prods.length); + ProductionName pn = new ProductionName(this.full_stack.get(index).getProdName(), -1); + all_prods[index] = pn; } @@ -178,6 +208,14 @@ private void SetAllProds() { this.productions = all_prods; this.need_set_all_prods = false; + // System.out.println(this.productions[0]); + // String res = "Prods visted: [\n"; + // for (int i = 0; i < this.productions.length; i++) { + // res += "\t" + this.productions[i].name + ", \n"; + // } + // res += "]"; + // System.out.println(res); + return; } @@ -189,7 +227,7 @@ private void fillInPartition() { int previous_y = 0; int partition_index = 0; for (int i = 0; i < this.full_stack.get_height(); i++) { - NodeContextMessage node = this.full_stack.get(0); + NodeContextMessage node = this.full_stack.get(i); int cur_x = node.getTranslationX(); int cur_y = node.getHigherOrderY(); if (cur_x == previous_x && cur_y == previous_y) { @@ -204,37 +242,44 @@ private void fillInPartition() { this.partition[i] = partition_index; } } - } - - public static class Production { - public String name; - public int index; - - public Production(String name, int index) { - this.name = name; - this.index = index; - } - public String toString() { - if (this.index == 0) { - return this.name; - } - else { - return this.name + " (" + this.index + ")"; - } - } + // String res = "PARTITION: [\n"; + // for (int i = 0; i < this.partition.length; i++) { + // res += "\t" + this.partition[i] + ", \n"; + // } + // res += "]"; + // System.out.println(res); } + // public static class Production { + // public String name; + // public int index; + + // public Production(String name, int index) { + // this.name = name; + // this.index = index; + // } + + // public String toString() { + // if (this.index == 0) { + // return this.name; + // } + // else { + // return this.name + " (" + this.index + ")"; + // } + // } + // } + private ContextStack full_stack; private Stack simple_stack = new Stack(); private boolean need_set_all_prods = true; - private Production productions[]; + private ProductionName productions[]; - // Put 0 for each respective element in the first - // stack partition, then 1, etc. Index 0 into stack is bottom - private int[] partition = new int[full_stack.get_height()]; + // // Put 0 for each respective element in the first + // // stack partition, then 1, etc. Index 0 into stack is bottom + private int[] partition; } From 9d7c62933b14d1e61958a0f70d06d62766a5e360 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Thu, 4 Apr 2024 17:07:09 -0500 Subject: [PATCH 34/64] to String stuff done --- .../.settings/org.eclipse.jdt.core.prefs | 2 +- .../java/src/common/SimplifiedContextBox.java | 44 +++++++++++++++++++ .../src/common/SimplifiedContextStack.java | 10 ++--- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/language-server/launcher/.settings/org.eclipse.jdt.core.prefs b/language-server/launcher/.settings/org.eclipse.jdt.core.prefs index 6bf842e11..43781029c 100644 --- a/language-server/launcher/.settings/org.eclipse.jdt.core.prefs +++ b/language-server/launcher/.settings/org.eclipse.jdt.core.prefs @@ -110,7 +110,7 @@ org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=wa org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index 335188107..66b79a443 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -20,4 +20,48 @@ public class SimplifiedContextBox { // 4. Interesting Features public List features; + + public getSection1Str() { + + String top = "Tree Order: "; + if (this.translation_x == 0 && this.higher_order_y == 0) { + return top + "0\n"; + } + top += "\n"; + String trans = ""; + if (this.translation_x > 0) { + trans = "TRANSLATION-" + this.translation_x + "\n"; + } + String higher = ""; + if (this.higher_order_y > 0) { + higher = "HIGHER-ORDER-" + this.higher_order_y + "\n"; + } + return top + trans + higher; + } + + public getSection2Str() { + String header1 = "^^^^^^^^^^^^^^^^^^^^ALL SYNTAX^^^^^^^^^^^^^^^^^^^^\n"; + String header2 = "^^^^^^^^^^^^^^^^^^^^TO HIGHLIGHT^^^^^^^^^^^^^^^^^^^^\n"; + String sep = "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"; + return header1 + this.text_syntax + header2 + this.syntax_to_highlight + sep; + } + + public getSection3Str() { + String res = "Productions Visited: "; + for (int i = 0; i < this.prods_visited.length; i++) { + res += "\t" + this.prods_visited[i].toString + "\n"; + } + return res; + } + + public getSection4Str() { + if (this.features.size() == 0) { + return ""; + } + String res = "Features: "; + for (Feature feature: this.features) { + res += "\t" + feature.toString() + "\n"; + } + return res; + } } \ No newline at end of file diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 72ddbdf2a..199b48b60 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -61,7 +61,7 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { // UNCOMMENT-ME. FOR-DEMO // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // System.out.println("MAKING SIMPLIFIED BOX: " + i + ", " + j); + System.out.println("MAKING SIMPLIFIED BOX: " + i + ", " + j); if (i > j) { System.out.println("Invalid Partition Indices: " + i + ", " + j); @@ -100,10 +100,10 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { // UNCOMMENT-ME. FOR-DEMO // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // System.out.println("first prod: " + sbox.prods_visited[0]); - // if (sbox.features.size() > 0) { - // System.out.println("first feature: " + sbox.features.get(0)); - // } + System.out.println("first prod: " + sbox.prods_visited[0]); + if (sbox.features.size() > 0) { + System.out.println("first feature: " + sbox.features.get(0)); + } return sbox; } From c0cfde29a63810720c64240505ec61d5af53b63a Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Thu, 4 Apr 2024 17:20:59 -0500 Subject: [PATCH 35/64] ready for file visualization --- runtime/java/src/common/CMDContextVisualization.java | 1 - runtime/java/src/common/Debug.java | 12 ++++++------ runtime/java/src/common/SimplifiedContextBox.java | 8 ++++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/runtime/java/src/common/CMDContextVisualization.java b/runtime/java/src/common/CMDContextVisualization.java index c9b30c6d2..8b748bc75 100644 --- a/runtime/java/src/common/CMDContextVisualization.java +++ b/runtime/java/src/common/CMDContextVisualization.java @@ -25,4 +25,3 @@ public void show() { } } } - diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 15e35cc82..8a15fd6e6 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -63,7 +63,7 @@ public void runingDebug(DecoratedNode tree) { // Need to debug why first line causes NullPointerException before SimplifiedContextStack constructor called SimplifiedContextStack sStack = new SimplifiedContextStack(contextStack); - sStack.getSimplifiedStack(); + sStack.show(); //Control loop loop: do { @@ -92,7 +92,7 @@ public void runingDebug(DecoratedNode tree) { } // if we navigate up to a parent, push it on to the stack (?) cStack.pop(); - sStack.getSimplifiedStack(); + sStack.show(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); @@ -139,7 +139,7 @@ else if (userInputList.length == 1) { } // if we navigate down to a child, push it on to the stack cStack.push(currentNode); - sStack.getSimplifiedStack(); + sStack.show(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); @@ -163,7 +163,7 @@ else if (userInputList.length == 1) { } // remove from the stack cStack.pop(); - sStack.getSimplifiedStack(); + sStack.show(); if(toggleCStackDisplay){ cStack.show(); } @@ -189,7 +189,7 @@ else if (userInputList.length == 1) { } // if we navigate to a forward, push it on to the stack cStack.push(currentNode); - sStack.getSimplifiedStack(); + sStack.show(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); @@ -265,7 +265,7 @@ else if (userInputList.length == 1) { } // if we navigate backwards, pop (?) cStack.pop(); - sStack.getSimplifiedStack(); + sStack.show(); // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index 66b79a443..b399bb469 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -64,4 +64,12 @@ public getSection4Str() { } return res; } + + public String toString() { + return + getSection1Str() + + getSection2Str() + + getSection3Str() + + getSection4Str(); + } } \ No newline at end of file From 51631b5df5d24ec20abb255496a0dc0d5ad651f2 Mon Sep 17 00:00:00 2001 From: Morgan Bozeman Date: Thu, 4 Apr 2024 17:21:25 -0500 Subject: [PATCH 36/64] added show to simple stack --- .../src/common/SimplifiedContextStack.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 199b48b60..c6b7b63eb 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -13,6 +13,13 @@ public class SimplifiedContextStack { public SimplifiedContextStack(ContextStack full_stack) { this.full_stack = full_stack; this.partition = new int[full_stack.get_height()]; + this.filename = "debugcontext.txt"; + } + + public SimplifiedContextStack(ContextStack full_stack, String fn) { + this.full_stack = full_stack; + this.partition = new int[full_stack.get_height()]; + this.filename = fn; } public Stack getSimplifiedStack() { @@ -24,6 +31,25 @@ public Stack getSimplifiedStack() { return this.simple_stack; } + public void show(){ + this.getSimplifiedStack(); + File file = new File(this.filename); + String border = "*******************"; + + try{ + FileWriter myWriter = new FileWriter(this.filename); + Iterator iterator = this.simple_stack.iterator(); + while (iterator.hasNext()) { + SimplifiedContextBox sbox = iterator.next(); + myWriter.write(border + "\n" + sbox.toString() + "\n" + border); + } + myWriter.close(); + } + catch (IOException e) { + e.printStackTrace(); + } + } + private void makeSimplifiedStack() { // Clear previous simplified stack to get a brand new one @@ -271,6 +297,7 @@ private void fillInPartition() { // } private ContextStack full_stack; + private String filename; private Stack simple_stack = new Stack(); From bf404c57d113297477000091dfc5d99e316d6579 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Sun, 7 Apr 2024 13:55:03 -0500 Subject: [PATCH 37/64] fixed to string on simple stack --- .../java/src/common/SimplifiedContextBox.java | 26 +++++++++++-------- .../src/common/SimplifiedContextStack.java | 19 ++++++++++---- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index b399bb469..cc435e480 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -21,7 +21,9 @@ public class SimplifiedContextBox { // 4. Interesting Features public List features; - public getSection1Str() { + private String sectionSep = "--------------------\n"; + + public String getSection1Str() { String top = "Tree Order: "; if (this.translation_x == 0 && this.higher_order_y == 0) { @@ -39,26 +41,25 @@ public getSection1Str() { return top + trans + higher; } - public getSection2Str() { - String header1 = "^^^^^^^^^^^^^^^^^^^^ALL SYNTAX^^^^^^^^^^^^^^^^^^^^\n"; - String header2 = "^^^^^^^^^^^^^^^^^^^^TO HIGHLIGHT^^^^^^^^^^^^^^^^^^^^\n"; - String sep = "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"; - return header1 + this.text_syntax + header2 + this.syntax_to_highlight + sep; + public String getSection2Str() { + String header1 = "^^^^^ALL SYNTAX^^^^^\n"; + String header2 = "\n^^^^^TO HIGHLIGHT^^^^^\n"; + return header1 + this.text_syntax + header2 + this.syntax_to_highlight + "\n"; } - public getSection3Str() { - String res = "Productions Visited: "; + public String getSection3Str() { + String res = "Productions Visited: \n"; for (int i = 0; i < this.prods_visited.length; i++) { - res += "\t" + this.prods_visited[i].toString + "\n"; + res += "\t" + this.prods_visited[i].toString() + "\n"; } return res; } - public getSection4Str() { + public String getSection4Str() { if (this.features.size() == 0) { return ""; } - String res = "Features: "; + String res = "Features: \n"; for (Feature feature: this.features) { res += "\t" + feature.toString() + "\n"; } @@ -68,8 +69,11 @@ public getSection4Str() { public String toString() { return getSection1Str() + + this.sectionSep + getSection2Str() + + this.sectionSep + getSection3Str() + + this.sectionSep + getSection4Str(); } } \ No newline at end of file diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index c6b7b63eb..891f35813 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -6,6 +6,13 @@ import java.util.ArrayList; import java.util.List; +import java.io.File; +import java.io.FileWriter; +import java.io.FileNotFoundException; +import java.io.PrintStream; +import java.util.Iterator; +import java.io.IOException; + // Basically a decorator over a ContextStack to // generate a simplified (one node per tree order) stack public class SimplifiedContextStack { @@ -13,7 +20,7 @@ public class SimplifiedContextStack { public SimplifiedContextStack(ContextStack full_stack) { this.full_stack = full_stack; this.partition = new int[full_stack.get_height()]; - this.filename = "debugcontext.txt"; + this.filename = "simpleDebugContext.txt"; } public SimplifiedContextStack(ContextStack full_stack, String fn) { @@ -25,14 +32,16 @@ public SimplifiedContextStack(ContextStack full_stack, String fn) { public Stack getSimplifiedStack() { this.need_set_all_prods = true; this.makeSimplifiedStack(); - - // UNCOMMENT-ME. FOR-DEMO - System.out.println("NEW SIMPLIFIED STACK SIZE: " + this.simple_stack.size()); return this.simple_stack; } + public void updateSimplifiedStack() { + this.need_set_all_prods = true; + this.makeSimplifiedStack(); + } + public void show(){ - this.getSimplifiedStack(); + this.updateSimplifiedStack(); File file = new File(this.filename); String border = "*******************"; From fc15757067077e580e69a29340af0c243ef06355 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 9 Apr 2024 12:07:56 -0500 Subject: [PATCH 38/64] removed unncessary prints --- .../src/common/SimplifiedContextStack.java | 54 ------------------- 1 file changed, 54 deletions(-) diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 891f35813..ed6b8bb00 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -94,10 +94,6 @@ private void makeSimplifiedStack() { // Inclusive Partition Indices private SimplifiedContextBox makeSimplifiedBox(int i, int j) { - // UNCOMMENT-ME. FOR-DEMO - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - System.out.println("MAKING SIMPLIFIED BOX: " + i + ", " + j); - if (i > j) { System.out.println("Invalid Partition Indices: " + i + ", " + j); return null; @@ -108,7 +104,6 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { NodeContextMessage first = this.full_stack.get(i); NodeContextMessage last = this.full_stack.get(j); - // System.out.println(first.getProdName()); // 1. Tree Order Trivial sbox.translation_x = first.getTranslationX(); @@ -126,20 +121,6 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { sbox.features = new ArrayList(); this.fillInFeaturesList(sbox, i, j); - // for (i = 0; i < sbox.prods_visited.length; i++) { - // System.out.println(sbox.prods_visited[i]); - // } - // System.out.println("text: " + sbox.text_syntax); - // System.out.println("to highlight: " + sbox.syntax_to_highlight); - - - // UNCOMMENT-ME. FOR-DEMO - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - System.out.println("first prod: " + sbox.prods_visited[0]); - if (sbox.features.size() > 0) { - System.out.println("first feature: " + sbox.features.get(0)); - } - return sbox; } @@ -186,7 +167,6 @@ private void fillInFeaturesList(SimplifiedContextBox sbox, int i, int j) { private void SetAllProds() { - // System.out.println(this.need_set_all_prods); if (! this.need_set_all_prods) { return; } @@ -196,7 +176,6 @@ private void SetAllProds() { ProductionName all_prods[] = new ProductionName[this.full_stack.get_height()]; for (int index = 0; index < this.full_stack.get_height(); index++) { - // System.out.println(all_prods.length); ProductionName pn = new ProductionName(this.full_stack.get(index).getProdName(), -1); all_prods[index] = pn; } @@ -243,13 +222,6 @@ private void SetAllProds() { this.productions = all_prods; this.need_set_all_prods = false; - // System.out.println(this.productions[0]); - // String res = "Prods visted: [\n"; - // for (int i = 0; i < this.productions.length; i++) { - // res += "\t" + this.productions[i].name + ", \n"; - // } - // res += "]"; - // System.out.println(res); return; } @@ -277,34 +249,8 @@ private void fillInPartition() { this.partition[i] = partition_index; } } - - // String res = "PARTITION: [\n"; - // for (int i = 0; i < this.partition.length; i++) { - // res += "\t" + this.partition[i] + ", \n"; - // } - // res += "]"; - // System.out.println(res); } - // public static class Production { - // public String name; - // public int index; - - // public Production(String name, int index) { - // this.name = name; - // this.index = index; - // } - - // public String toString() { - // if (this.index == 0) { - // return this.name; - // } - // else { - // return this.name + " (" + this.index + ")"; - // } - // } - // } - private ContextStack full_stack; private String filename; private Stack simple_stack = From 2ca734bf2f1787e443607a1a5a218d13acb4209d Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 11 Apr 2024 10:50:36 -0500 Subject: [PATCH 39/64] html of productions and attributes --- .../compiler/translation/java/core/Expr.sv | 2 +- runtime/java/src/common/Debug.java | 253 +++++++++++++++++- runtime/java/src/common/DecoratedNode.java | 5 + runtime/java/src/common/Util.java | 18 ++ 4 files changed, 265 insertions(+), 13 deletions(-) diff --git a/grammars/silver/compiler/translation/java/core/Expr.sv b/grammars/silver/compiler/translation/java/core/Expr.sv index 3f3fe5208..6f728e6ab 100644 --- a/grammars/silver/compiler/translation/java/core/Expr.sv +++ b/grammars/silver/compiler/translation/java/core/Expr.sv @@ -677,6 +677,6 @@ String ::= e::Decorated Expr | r :: _ -> r.grammarSource | [] -> "" end ++ loc.filename; - local sourceLocationTrans::String = s"new silver.core.Ploc(\"${fileName}\", ${toString(loc.line)}, ${toString(loc.column)}, ${toString(loc.endLine)}, ${toString(loc.endColumn)}, ${toString(loc.index)}, ${toString(loc.endIndex)})"; + local sourceLocationTrans::String = s"new silver.core.Ploc(new common.StringCatter(\"${fileName}\"), ${toString(loc.line)}, ${toString(loc.column)}, ${toString(loc.endLine)}, ${toString(loc.endColumn)}, ${toString(loc.index)}, ${toString(loc.endIndex)})"; return s"new common.Lazy() { public final Object eval(final common.DecoratedNode context) { ${swizzleOrigins} return ${e.translation}; } public final silver.core.NLocation getSourceLocation() { return ${sourceLocationTrans}; } }"; } diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index e9d265130..7f2a19943 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -12,6 +12,15 @@ import java.util.List; import java.util.Arrays; +import silver.core.NLocation; +import silver.core.NMaybe; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Collections; import common.Util.*; @@ -108,7 +117,10 @@ public void runingDebug(DecoratedNode tree) { } else if (userInputList.length == 1) { System.out.println("Which child?"); - childNum = chooseFormList(inp, currentNode.undecorate().getProdleton().getChildTypes()); + String currentProduction = currentNode.undecorate().getProdleton().getTypeUnparse(); + String[] listCurrentProduction = currentProduction.split("\\s+"); + String[] childNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length); + childNum = chooseFormList(inp, childNames); if(childNum == -1){ break; } @@ -319,12 +331,52 @@ else if (userInputList.length == 1) { //Somehow this needs to create a new function for RTTI manager but current attempt does not work //We want - user defined names (ex: left right), attribute equations (ex: left = parent + 1) and nearby code (filename and linenumber?) case "eq": - if (userInputList.length != 1 && userInputList.length != 2) { - System.out.println("invalid, correct usage: eq"); + //A bit reptative right now but when I get a idea on how to list only the higer order nodes It will be better + String attributeNameView = ""; + Integer attributeNumView = 0; + List attributeListView = allAttributesList(currentNode); + if (userInputList.length == 1) { + System.out.println("Which attribute?"); + String[] attriburteArrayView = attributeListView.toArray(new String[attributeListView.size()]); + attributeNumView = chooseFormList(inp, attriburteArrayView); + if(attributeNumView == -1){ + break; + }else if(attributeNumView >= attributeListView.size()){ + System.out.println("Invaild attribute number"); + break; + }else{ + attributeNameView = attributeListView.get(attributeNumView); + } + }else if(userInputList.length == 2){ + try{ + attributeNumView = Integer.parseInt(userInputList[1]); + attributeNameView = attributeListView.get(attributeNumView); + }catch (NumberFormatException e) { + System.out.println("invalid, correct usage: view "); + break; + }catch (IndexOutOfBoundsException e){ + System.out.println("Index out of bounds"); + break; + } }else{ - System.out.println("do the eq stuff"); - + System.out.println("invalid, correct usage: into "); + break; } + printEquation(currentNode, attributeNameView); + // if(childNode == null){ + // System.out.println("invalid input"); + // } + // else{ + // System.out.println("going into"); + // currentNode = childNode; + // // if(toggleNameDisplay){ + // // printName(currentNode); + // // } + // // // if we navigate to a forward, push it on to the stack + // // cStack.push(currentNode); + // // // when we push, update and show the context + // // cStack.show(); + // } break; //List synthesized attributes @@ -395,7 +447,8 @@ else if (userInputList.length == 1) { System.out.println("invalid, correct usage: view "); break; } - printAttrFromName(currentNode, attributeName); + //printAttrFromName(currentNode, attributeName); + printAllAttributeData(currentNode, attributeName); break; @@ -566,12 +619,12 @@ public DecoratedNode backtrack(DecoratedNode node) public void printProduction(DecoratedNode node) { String partent_production = node.undecorate().getProdleton().getTypeUnparse(); - String child_productions[] = node.undecorate().getProdleton().getChildTypes(); - System.out.print(partent_production + " "); - for (int i = 0; i < child_productions.length; i++){ - System.out.print(child_productions[i] + " "); - } - System.out.print("\n"); + // String child_productions[] = node.undecorate().getProdleton().getChildTypes(); + System.out.print(partent_production + "\n"); + // for (int i = 0; i < child_productions.length; i++){ + // System.out.print(child_productions[i] + " "); + // } + // System.out.print("\n"); } public void printName(DecoratedNode node) @@ -591,9 +644,93 @@ public void printName(DecoratedNode node) // System.out.print("\n"); // } + //TODO: file for the production you are on + //Also a file with list of attribute values + //Optional: Replace variables with values )_) + //ask lucas for endline + // Prints out the equation of the specified attr. // If attr is not specified, prints out the equations for all the attributes on the current node. // via eric we can just add equations as an attribute within our AG + public void printEquation(DecoratedNode node, String attriburteName) + { + Map lazyMap = allAttributesLazyMap(node); + if (lazyMap.containsKey(attriburteName)) { + // System.out.println("In print Equation function"); + Lazy attributeLazy = lazyMap.get(attriburteName); + NLocation loc = attributeLazy.getSourceLocation(); + String notes = ""; + String qualifier = Integer.toHexString(System.identityHashCode(this)); + if(loc != null) { + // Object filenameObj = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location); + // Class synthesizedClass = filenameObj.getClass(); + // System.out.println("Type of synthesized object: " + synthesizedClass.getName()); + + String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); + + int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); + int col = (Integer)loc.synthesized(silver.core.Init.silver_core_column__ON__silver_core_Location); + // System.out.println("our line, col: " + line + "," + col); + // System.out.println("our filename: " + file); + printContent(file, line, col); + //qualifier += ", " + file + ":" + Integer.toString(line) + ":" + Integer.toString(col); + } + if(!notes.isEmpty()) { + qualifier += ", " + notes; + } + //Lazy attributeObject = attributeMap.get(attriburteName); + } + //System.out.println("made it here at least"); + } + + public static void printContent(String filename, int lineNumber, int col) { + //System.out.println("in print content"); + try (BufferedReader br1 = new BufferedReader(new FileReader(filename)); + BufferedWriter writer = new BufferedWriter(new FileWriter("current_production.html"))) { + writer.write("\n"); + writer.write("\n"); + writer.write("\n"); + // System.out.println("in try"); + String line; + int currentLineNumber = 1; + int productionLineNum = 0; + while ((line = br1.readLine()) != null) { + if (line.contains("::=")) { + productionLineNum = currentLineNumber; // Stop printing when encountering the line containing "}" + } + if (currentLineNumber >= lineNumber ) { + break; + } + currentLineNumber++; + } + currentLineNumber = 1; + br1.close(); + BufferedReader br2 = new BufferedReader(new FileReader(filename)); + writer.write("
\n");
+            while ((line = br2.readLine()) != null) {
+                if (currentLineNumber >= productionLineNum && currentLineNumber != lineNumber) {
+                    writer.write(line);
+                    writer.newLine();
+                }else if(currentLineNumber == lineNumber){
+                    writer.write("");
+                    writer.write(line);
+                    writer.write("");
+                    writer.newLine();
+                }
+                if (currentLineNumber >= productionLineNum && line.trim().equals("}")) {
+                    break; // Stop printing when encountering the line exactly containing "}"
+                }
+                currentLineNumber++;
+            }
+            writer.write("
\n"); + writer.write("\n"); + writer.write("\n"); + }catch (IOException e) { + System.out.println("in catch"); + e.printStackTrace(); + } + } + public void eqSynth(int attribute) { @@ -664,10 +801,45 @@ public List removeHeaders(List stringList){ } public void printAttrFromName(DecoratedNode node, String printAttribute){ + //Map attributeMap = allAttributesThunkMap(node); Map attributeMap = allAttributesObjectMap(node); + // @SuppressWarnings("unchecked") + //TODO: fix known bug can't access the same thunk twice + // Thunk finalTunk = (Thunk) attributeMap.get(printAttribute); + // System.out.println(Util.genericShow(finalTunk.eval())); + System.out.println(Util.genericShow(attributeMap.get(printAttribute))); } + public void printAllAttributeData(DecoratedNode node, String printAttribute){ + //Map attributeMap = allAttributesThunkMap(node); + Map attributeMap = allAttributesObjectMap(node); + try (BufferedWriter writer = new BufferedWriter(new FileWriter("attribute_values.html"))) { + writer.write("\n"); + writer.write("\n"); + writer.write("\n"); + writer.write("
\n");
+            for (Map.Entry entry : attributeMap.entrySet()) {
+                String key = entry.getKey();
+                Object value = entry.getValue();
+                if (key.equals(printAttribute)){
+                    writer.write("");
+                }
+                writer.write(key + ": " + Util.genericShow(value));
+                if (key.equals(printAttribute)){
+                    writer.write("");
+                }
+                writer.newLine();
+            }
+            writer.write("
\n"); + writer.write("\n"); + writer.write("\n"); + + }catch (IOException e) { + System.err.println("Error writing to file: " + e.getMessage()); + } + } + //List of all and only local attributes public static List getLocalAttrs(DecoratedNode node) { @@ -743,6 +915,63 @@ public static Map allAttributesObjectMap(DecoratedNode node) return attributeMap; } + //TODO: replace all uses of allAttributesObjectMap with this once it works (see known bug on printAttrFromName) + public static Map allAttributesThunkMap(DecoratedNode node) + { + List attributeList = allAttributesList(node); + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + Map attributeMap = new HashMap<>(); + + for(String attribute : attributeList) + { + if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ + Integer index = nonterminalton.getSynOccursIndex(attribute); + Object o = node.contextSynthesizedLazy(index); + attributeMap.put(attribute, o); + }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + Integer index = nonterminalton.getInhOccursIndex(attribute); + Object o = node.contextInheritedLazy(index); + attributeMap.put(attribute, o); + }else{ //Should be local + List listLocals = getLocalAttrs(node); + Integer index = listLocals.indexOf(attribute); + Object o = node.localLazy(index); + attributeMap.put(attribute, o); + } + } + return attributeMap; + } + + + public static Map allAttributesLazyMap(DecoratedNode node) + { + List attributeList = allAttributesList(node); + RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); + RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); + Map attributeMap = new HashMap<>(); + + for(String attribute : attributeList) + { + if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ + Integer index = nonterminalton.getSynOccursIndex(attribute); + Lazy synthAttribute = node.getNode().getSynthesized(index); //breaks for forwarded nodes + attributeMap.put(attribute, synthAttribute); + }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + Integer index = nonterminalton.getInhOccursIndex(attribute); + Lazy inheritedAttribute = node.getInheritedAttribute(index); + attributeMap.put(attribute, inheritedAttribute); + }else{ //Should be local + List listLocals = getLocalAttrs(node); + Integer index = listLocals.indexOf(attribute); + Lazy localAttribute = node.getNode().getLocal(index); + attributeMap.put(attribute, localAttribute); + } + } + return attributeMap; + } + + public static Integer chooseFormList(Scanner inp, String[] list){ for (int i = 0; i < list.length; i++){ System.out.println(Integer.toString(i) + ": " + list[i]); diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 2bab47ee5..f266a5700 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -238,6 +238,11 @@ public DecoratedNode getForwardParent() return forwardParent; } + //Getter added by Micahel + public Lazy getInheritedAttribute(int index) { + return inheritedAttributes[index]; + } + /** * Decorate this (unique decorated) node with additional inherited attributes. * This has no effect if the node already has a forward parent. diff --git a/runtime/java/src/common/Util.java b/runtime/java/src/common/Util.java index ebec4c5b0..d2c5a324d 100644 --- a/runtime/java/src/common/Util.java +++ b/runtime/java/src/common/Util.java @@ -192,6 +192,24 @@ public static int genInt() { public static void printStackCauses(Throwable e) { freeThisToPrintErrors = null; + // // Get all environment variables + // Map envVariables = System.getenv(); + + // // // Print all environment variables + // // for (Map.Entry entry : envVariables.entrySet()) { + // // String variableName = entry.getKey(); + // // String variableValue = entry.getValue(); + // // System.out.println(variableName + " = " + variableValue); + // // } + // String stackTraceString = envVariables.get("SILVERTRACE"); + // System.out.println("Value of SILVERTRACE: " + stackTraceString); + + // System.setProperty("SILVERTRACE", "1"); + + // stackTraceString = envVariables.get("SILVERTRACE"); + // System.out.println("Value of SILVERTRACE: " + stackTraceString); + + System.err.println("\nAn error occurred. Silver stack trace follows. (To see full traces including java elements, SILVERTRACE=1)\n"); if(! "1".equals(System.getenv("SILVERTRACE"))) { From 55a0b351c629c9199c1fe1b349307b76b9e28e89 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 11 Apr 2024 12:11:05 -0500 Subject: [PATCH 40/64] cleaned some comments, endline and jason added --- runtime/java/src/common/Debug.java | 185 ++++++++++++----------------- 1 file changed, 79 insertions(+), 106 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 3ed0d72e6..b37632fe7 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -1,4 +1,4 @@ -//Thing to remeber: ./silver-compile --force-origins --clean +//needed to run: ./silver-compile --force-origins --clean package common; @@ -44,7 +44,7 @@ public void runingDebug(DecoratedNode tree) { boolean toggleNameDisplay = false; boolean toggleCStackDisplay = true; boolean toggleHeadlessAttributes = false; - String[] toggleChoices = {"prodDisplay", "cStackDisplay", "fullAttributeNames"}; + String[] toggleChoices = {"nameDisplay", "cStackDisplay", "fullAttributeNames"}; DecoratedNode childNode; this.root = tree; this.currentNode = tree; @@ -293,7 +293,7 @@ else if (userInputList.length == 1) { }else if (userInputList.length == 2){ toggelChoice = userInputList[1]; } - if(toggelChoice.equals("prodDisplay")){ + if(toggelChoice.equals("nameDisplay")){ if(toggleNameDisplay){ System.out.println("Production Display off"); toggleNameDisplay = false; @@ -318,7 +318,7 @@ else if (userInputList.length == 1) { toggleCStackDisplay = true; } }else{ - System.out.println("legal toggles: prodDisplay, fullAttributeNames, cStackDisplay"); + System.out.println("legal toggles: nameDisplay, fullAttributeNames, cStackDisplay"); } break; @@ -331,12 +331,17 @@ else if (userInputList.length == 1) { printProduction(currentNode); } break; - - //TODO:Implement this - use genericShow?, see ProductionDcl in grammer/silver/compiler/translation/java/core - //Somehow this needs to create a new function for RTTI manager but current attempt does not work - //We want - user defined names (ex: left right), attribute equations (ex: left = parent + 1) and nearby code (filename and linenumber?) + + case "name": + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: prod<>"); + }else{ + printName(currentNode); + } + break; + + //Makes html of the production with the specific production highlighted case "eq": - //A bit reptative right now but when I get a idea on how to list only the higer order nodes It will be better String attributeNameView = ""; Integer attributeNumView = 0; List attributeListView = allAttributesList(currentNode); @@ -411,9 +416,6 @@ else if (userInputList.length == 1) { if (userInputList.length != 1 && userInputList.length != 2) { System.out.println("invalid, correct usage: list"); }else{ - // if(listSynth(currentNode) + listInher(currentNode) == 0){ - // System.out.println("no attributes"); - // } printAttributes(currentNode, toggleHeadlessAttributes); } break; @@ -576,9 +578,9 @@ public DecoratedNode up() public DecoratedNode down(int child) { - String child_productions[] = currentNode.undecorate().getProdleton().getChildTypes(); + String childProductions[] = currentNode.undecorate().getProdleton().getChildTypes(); try{ - if(child_productions[child].equals("null")){ + if(childProductions[child].equals("null")){ return null; } DecoratedNode childNode = currentNode.childDecorated(child); @@ -590,20 +592,6 @@ public DecoratedNode down(int child) System.out.println("Index out of bound"); return null; } - //if (currentNode.getNode().getNumberOfChildren() > child && child >= 0){ - //Might be a bandaid fix not sure I understand why the problem exists - // DecoratedNode childNode = currentNode.childDecorated(child); - // return childNode; - // //} - // return null; - } - - public void printChildren(DecoratedNode node) - { - String child_productions[] = node.undecorate().getProdleton().getChildTypes(); - for (int i = 0; i < child_productions.length; i++){ - System.out.println(Integer.toString(i) + ": " + child_productions[i] + " "); - } } public DecoratedNode forwards(DecoratedNode node) @@ -614,6 +602,7 @@ public DecoratedNode forwards(DecoratedNode node) } return null; } + public DecoratedNode backtrack(DecoratedNode node) { currentNode = node.getForwardParent(); @@ -621,87 +610,74 @@ public DecoratedNode backtrack(DecoratedNode node) } - public void printProduction(DecoratedNode node) + //Most user frindly print + public void printName(DecoratedNode node) { - String partent_production = node.undecorate().getProdleton().getTypeUnparse(); - // String child_productions[] = node.undecorate().getProdleton().getChildTypes(); - System.out.print(partent_production + "\n"); - // for (int i = 0; i < child_productions.length; i++){ - // System.out.print(child_productions[i] + " "); - // } - // System.out.print("\n"); + String partentProduction = node.undecorate().getProdleton().getTypeUnparse(); + System.out.println(partentProduction); } - public void printName(DecoratedNode node) + //Gives production + public void printProduction(DecoratedNode node) { String name = node.undecorate().getProdleton().getName(); - System.out.println(name); + String childProductions[] = node.undecorate().getProdleton().getChildTypes(); + System.out.print(name + " "); + for (int i = 0; i < childProductions.length; i++){ + System.out.print(childProductions[i] + " "); + } + System.out.print("\n"); } - // public void printNames(DecoratedNode node) - // { - // String partent_production = node.undecorate().getProdleton().getName(); - // String child_productions[] = node.undecorate().getProdleton().getChildNames(); - // System.out.print(partent_production + " "); - // for (int i = 0; i < child_productions.length; i++){ - // System.out.print(child_productions[i] + " "); - // } - // System.out.print("\n"); - // } - - //TODO: file for the production you are on - //Also a file with list of attribute values - //Optional: Replace variables with values )_) - //ask lucas for endline - - // Prints out the equation of the specified attr. - // If attr is not specified, prints out the equations for all the attributes on the current node. - // via eric we can just add equations as an attribute within our AG + // makes html of the production containing the inputed attribute name + // the specific attribute is highlighted public void printEquation(DecoratedNode node, String attriburteName) { Map lazyMap = allAttributesLazyMap(node); if (lazyMap.containsKey(attriburteName)) { - // System.out.println("In print Equation function"); Lazy attributeLazy = lazyMap.get(attriburteName); NLocation loc = attributeLazy.getSourceLocation(); - String notes = ""; String qualifier = Integer.toHexString(System.identityHashCode(this)); if(loc != null) { - // Object filenameObj = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location); - // Class synthesizedClass = filenameObj.getClass(); - // System.out.println("Type of synthesized object: " + synthesizedClass.getName()); - String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); - int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); - int col = (Integer)loc.synthesized(silver.core.Init.silver_core_column__ON__silver_core_Location); - // System.out.println("our line, col: " + line + "," + col); - // System.out.println("our filename: " + file); - printContent(file, line, col); - //qualifier += ", " + file + ":" + Integer.toString(line) + ":" + Integer.toString(col); - } - if(!notes.isEmpty()) { - qualifier += ", " + notes; + int endline = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); + + equationHTML(file, line, endline); + writToJason(file, line, endline); } - //Lazy attributeObject = attributeMap.get(attriburteName); } - //System.out.println("made it here at least"); } - public static void printContent(String filename, int lineNumber, int col) { + // makes html of the production containing the inputed attribute name + // the specific attribute is highlighted + public void writToJason(String filename, int lineNumber, int endline) + { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(".debugger_communicator.jason"))) { + writer.write("{\"file_path\": \"" + filename + "\", \"line_begin\": " + lineNumber + "\"line_end\":" + endline+ "}"); + }catch (IOException e) { + System.out.println("in catch"); + e.printStackTrace(); + } + } + + + + //Helper for printEquation + public static void equationHTML(String filename, int lineNumber, int endline) { //System.out.println("in print content"); try (BufferedReader br1 = new BufferedReader(new FileReader(filename)); BufferedWriter writer = new BufferedWriter(new FileWriter("current_production.html"))) { writer.write("\n"); writer.write("\n"); writer.write("\n"); - // System.out.println("in try"); String line; int currentLineNumber = 1; int productionLineNum = 0; while ((line = br1.readLine()) != null) { + //HACK:Relies on the the fact that "::=" is only and always used in production declarations if (line.contains("::=")) { - productionLineNum = currentLineNumber; // Stop printing when encountering the line containing "}" + productionLineNum = currentLineNumber; } if (currentLineNumber >= lineNumber ) { break; @@ -713,17 +689,20 @@ public static void printContent(String filename, int lineNumber, int col) { BufferedReader br2 = new BufferedReader(new FileReader(filename)); writer.write("
\n");
             while ((line = br2.readLine()) != null) {
-                if (currentLineNumber >= productionLineNum && currentLineNumber != lineNumber) {
-                    writer.write(line);
-                    writer.newLine();
-                }else if(currentLineNumber == lineNumber){
+                if(currentLineNumber == lineNumber){
                     writer.write("");
+                }
+                if (currentLineNumber >= productionLineNum) {
                     writer.write(line);
-                    writer.write("");
+                    if(currentLineNumber == endline){
+                        writer.write("");
+                        writer.newLine();
+                    }
                     writer.newLine();
                 }
+                //HACK:Relies on the the fact that the line "}" is only and always used in production ends
                 if (currentLineNumber >= productionLineNum && line.trim().equals("}")) {
-                    break; // Stop printing when encountering the line exactly containing "}"
+                    break; 
                 }
                 currentLineNumber++;
             }
@@ -736,47 +715,39 @@ public static void printContent(String filename, int lineNumber, int col) {
         }
     }
 
-    public void eqSynth(int attribute)
-    {
-
-    }
-
-    public void eqInher(int attribute)
-    {
-
-    }
-
-    // no optional params in java, could use overloading or just pass in null
+    //Old function not sure if we still want it
     public int listSynth(DecoratedNode node)
     {
         RTTIManager.Prodleton prodleton = node.getNode().getProdleton();
         RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton();
         Set synAttrSet = nonterminalton.getAllSynth();
-        int num_attr = 0;
+        int numAttr = 0;
 
         for (String synAttr : synAttrSet)
         {
             System.out.println("Attribute = " + synAttr);
-            num_attr++;
+            numAttr++;
         }
-        return num_attr;
+        return numAttr;
     }
 
+    //Old function not sure if we still want it
     public int listInher(DecoratedNode node)
     {
         RTTIManager.Prodleton prodleton = node.getNode().getProdleton();
         RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton();
         Set inhAttrSet = nonterminalton.getAllInh();
-        int num_attr = 0;
+        int numAttr = 0;
 
         for (String inhAttr : inhAttrSet)
         {
             System.out.println("Attribute = " + inhAttr);
-            num_attr++;
+            numAttr++;
         }
-        return num_attr;
+        return numAttr;
     }   
 
+    //Prints all attributes using allAttributesList
     public void printAttributes(DecoratedNode node, boolean toggleHeadlessAttributes){
         List attributeList = allAttributesList(node);
         if(toggleHeadlessAttributes){
@@ -816,6 +787,7 @@ public void printAttrFromName(DecoratedNode node, String printAttribute){
         System.out.println(Util.genericShow(attributeMap.get(printAttribute)));
     }
 
+    //TODO: update by using the thunk map inplace of the object map
     public void printAllAttributeData(DecoratedNode node, String printAttribute){
         //Map attributeMap = allAttributesThunkMap(node);
         Map attributeMap = allAttributesObjectMap(node);
@@ -861,7 +833,7 @@ public static List getLocalAttrs(DecoratedNode node)
     }
 
     //TODO: Add access to higher order attriburte
-    // Translation attribute or Decorated, locals only locals should all be decorated
+    //Translation attribute or Decorated, locals only locals should all be decorated
     public DecoratedNode into(DecoratedNode node, String attriburteName){
         Map attributeMap = allAttributesObjectMap(node);
         if (attributeMap.containsKey(attriburteName)) {
@@ -873,7 +845,7 @@ public DecoratedNode into(DecoratedNode node, String attriburteName){
     }
     
 
-    //Helper for printAttrFromName 
+    //Helper for printing Attributes
     public static List allAttributesList(DecoratedNode node)
     {
         RTTIManager.Prodleton prodleton = node.getNode().getProdleton();
@@ -887,7 +859,7 @@ public static List allAttributesList(DecoratedNode node)
         return attributeList;
     }
 
-    // Another Helper 
+    //TODO: We want change this to use the thunk version below.
     public static Map allAttributesObjectMap(DecoratedNode node)
     {
         List attributeList = allAttributesList(node);
@@ -920,7 +892,8 @@ public static Map allAttributesObjectMap(DecoratedNode node)
         return attributeMap;
     }
 
-    //TODO: replace all uses of allAttributesObjectMap with this once it works (see known bug on printAttrFromName)
+    //TODO: replace all uses of allAttributesObjectMap with this once it works 
+    //known bug: only can use thunks once then breaks
     public static Map allAttributesThunkMap(DecoratedNode node)
     {
         List attributeList = allAttributesList(node);
@@ -948,7 +921,7 @@ public static Map allAttributesThunkMap(DecoratedNode node)
         return attributeMap;
     }
 
-    
+    //Another helper
     public static Map allAttributesLazyMap(DecoratedNode node)
     {
         List attributeList = allAttributesList(node);
@@ -976,7 +949,7 @@ public static Map allAttributesLazyMap(DecoratedNode node)
         return attributeMap;
     }
 
-
+    //Should be in util?
     public static Integer chooseFormList(Scanner inp, String[] list){
         for (int i = 0; i < list.length; i++){
             System.out.println(Integer.toString(i) + ": " + list[i]);

From 37b081d422995262d53e3ee4099103457e48374e Mon Sep 17 00:00:00 2001
From: Cauth006 
Date: Thu, 11 Apr 2024 14:36:59 -0500
Subject: [PATCH 41/64] fixed json, stared alroithmic debugging

---
 runtime/java/src/common/Debug.java | 125 ++++++++++++++++++++++++-----
 1 file changed, 106 insertions(+), 19 deletions(-)

diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java
index b37632fe7..d4789a98c 100644
--- a/runtime/java/src/common/Debug.java
+++ b/runtime/java/src/common/Debug.java
@@ -120,7 +120,7 @@ else if (userInputList.length == 1) {
                         System.out.println("Which child?");
                         String currentProduction = currentNode.undecorate().getProdleton().getTypeUnparse();
                         String[] listCurrentProduction = currentProduction.split("\\s+");
-                        String[] childNames =  Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
+                        String[] childNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
                         childNum = chooseFormList(inp, childNames);
                         if(childNum == -1){
                             break;
@@ -372,7 +372,9 @@ else if (userInputList.length == 1) {
                         System.out.println("invalid, correct usage: into ");
                         break;
                     }
-                    printEquation(currentNode, attributeNameView);
+
+                    printEquation(currentNode, attributeNameView) ;
+                    attributeDataHTML(currentNode, "");
                     // if(childNode == null){
                     //     System.out.println("invalid input");
                     // }
@@ -455,7 +457,42 @@ else if (userInputList.length == 1) {
                         break;
                     }
                     //printAttrFromName(currentNode, attributeName);
-                    printAllAttributeData(currentNode, attributeName);
+                    attributeDataHTML(currentNode, attributeName);
+                    break;
+
+                case "algoDebugg": case "a": 
+                    attributeName = ""; 
+                    attributeNum = 0;
+                    attributeList = allAttributesList(currentNode);
+                    if (userInputList.length == 1) {
+                        System.out.println("Which attribute?");
+                        String[] attriburteArray =  attributeList.toArray(new String[attributeList.size()]);
+                        attributeNum = chooseFormList(inp, attriburteArray);
+                        if(attributeNum == -1){
+                            break;
+                        }else if(attributeNum >= attributeList.size()){
+                            System.out.println("Invaild attribute number");
+                            break;
+                        }else{
+                            attributeName = attributeList.get(attributeNum);
+                        }
+                    }else if(userInputList.length == 2){
+                        try{
+                            attributeNum = Integer.parseInt(userInputList[1]);
+                            attributeName = attributeList.get(attributeNum);
+                        }catch (NumberFormatException e) {
+                            System.out.println("invalid, correct usage: view ");
+                            break;
+                        }catch (IndexOutOfBoundsException e){
+                            System.out.println("Index out of bounds");
+                            break;
+                        }
+                    }else{
+                        System.out.println("invalid, correct usage: view ");
+                        break;
+                    }
+                    //printAttrFromName(currentNode, attributeName);
+                    algorithmicDebugg(currentNode, attributeName);
                     break;
 
 
@@ -642,21 +679,24 @@ public void printEquation(DecoratedNode node, String attriburteName)
                 String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
                 int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
                 int endline = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
-
+                
                 equationHTML(file, line, endline);
-                writToJason(file, line, endline);
+                writeToJason(file, line, endline);
             }
         }
     }
 
     // makes html of the production containing the inputed attribute name
     // the specific attribute is highlighted
-    public void writToJason(String filename, int lineNumber, int endline)
+    public void writeToJason(String filename, int lineNumber, int endline)
     {
         try (BufferedWriter writer = new BufferedWriter(new FileWriter(".debugger_communicator.jason"))) {
-                writer.write("{\"file_path\": \"" + filename + "\", \"line_begin\": " + lineNumber + "\"line_end\":" + endline+ "}");
+            String currentDirectory = System.getProperty("user.dir");
+            System.out.println(currentDirectory);
+            int lastIndex = filename.lastIndexOf("/");
+            String fileEnd = filename.substring(lastIndex + 1);
+            writer.write("{\"file_path\": \"" + currentDirectory + fileEnd + "\", \"line_begin\": " + lineNumber + ", \"line_end\": " + endline+ "}");
         }catch (IOException e) {
-            System.out.println("in catch");
             e.printStackTrace();
         }
     }
@@ -710,7 +750,6 @@ public static void equationHTML(String filename, int lineNumber, int endline) {
             writer.write("\n");
             writer.write("\n");
         }catch (IOException e) {
-            System.out.println("in catch");
             e.printStackTrace();
         }
     }
@@ -777,18 +816,18 @@ public List removeHeaders(List stringList){
     }
 
     public void printAttrFromName(DecoratedNode node, String printAttribute){
-        //Map attributeMap = allAttributesThunkMap(node);
-        Map attributeMap = allAttributesObjectMap(node);
-        // @SuppressWarnings("unchecked")
+        Map attributeMap = allAttributesThunkMap(node);
+        @SuppressWarnings("unchecked")
         //TODO: fix known bug can't access the same thunk twice
-        // Thunk finalTunk = (Thunk) attributeMap.get(printAttribute);
-        // System.out.println(Util.genericShow(finalTunk.eval()));
-
-        System.out.println(Util.genericShow(attributeMap.get(printAttribute)));
+        Thunk finalTunk = (Thunk) attributeMap.get(printAttribute);
+        System.out.println(Util.genericShow(finalTunk.eval()));
+        
+        //Map attributeMap = allAttributesObjectMap(node);
+        //System.out.println(Util.genericShow(attributeMap.get(printAttribute)));
     }
 
     //TODO: update by using the thunk map inplace of the object map
-    public void printAllAttributeData(DecoratedNode node, String printAttribute){
+    public void attributeDataHTML(DecoratedNode node, String printAttribute){
         //Map attributeMap = allAttributesThunkMap(node);
         Map attributeMap = allAttributesObjectMap(node);
         try (BufferedWriter writer = new BufferedWriter(new FileWriter("attribute_values.html"))) {
@@ -817,6 +856,54 @@ public void printAllAttributeData(DecoratedNode node, String printAttribute){
         }
     }
 
+    //List of all and only local attributes
+    public void algorithmicDebugg(DecoratedNode node, String attriburteName)
+    {
+        Map lazyMap = allAttributesLazyMap(node);
+        if (lazyMap.containsKey(attriburteName)) {
+            Lazy attributeLazy = lazyMap.get(attriburteName);
+            NLocation loc = attributeLazy.getSourceLocation();
+            String qualifier = Integer.toHexString(System.identityHashCode(this));
+            if(loc != null) {
+                String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
+                int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
+                int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
+
+                try {
+                    printLines(filePath, startLine, endLine);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        //TODO: fix when thunks work
+        Map attributeMap = allAttributesObjectMap(node);
+        System.out.println(attriburteName + ": " + Util.genericShow(attributeMap.get(attriburteName)));
+
+    }
+
+    //helper foralgorithmicDebugg
+    public static void printLines(String filePath, int startLine, int endLine) throws IOException {
+        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
+            String line;
+            int currentLine = 1;
+
+            // Read lines until reaching the start line
+            while ((line = reader.readLine()) != null && currentLine < startLine) {
+                currentLine++;
+            }
+
+            // Print lines from startLine to endLine
+            while (line != null && currentLine <= endLine) {
+                System.out.println(line);
+                line = reader.readLine();
+                currentLine++;
+            }
+        }catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
     //List of all and only local attributes
     public static List getLocalAttrs(DecoratedNode node)
     {
@@ -966,10 +1053,10 @@ public static Integer chooseFormList(Scanner inp, String[] list){
                 continueLoop = false;
             }else{
                 stopper = inp.nextLine();
-                if (stopper.equals("e")){
+                if (stopper.equals("q")){
                     continueLoop = false;
                 }else{
-                    System.out.println("Please choose an integer or e to exit");
+                    System.out.println("Please choose an integer or q to exit");
                 }
             }
         }

From a9cbed09f930817e2849fdec0de17ae246cbd776 Mon Sep 17 00:00:00 2001
From: Cauth006 
Date: Thu, 11 Apr 2024 15:05:43 -0500
Subject: [PATCH 42/64] fixed json again also alorithmic debugging is ded

---
 runtime/java/src/common/Debug.java | 67 ++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 23 deletions(-)

diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java
index d4789a98c..3d935f5fd 100644
--- a/runtime/java/src/common/Debug.java
+++ b/runtime/java/src/common/Debug.java
@@ -681,16 +681,16 @@ public void printEquation(DecoratedNode node, String attriburteName)
                 int endline = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
                 
                 equationHTML(file, line, endline);
-                writeToJason(file, line, endline);
+                writeTojson(file, line, endline);
             }
         }
     }
 
     // makes html of the production containing the inputed attribute name
     // the specific attribute is highlighted
-    public void writeToJason(String filename, int lineNumber, int endline)
+    public void writeTojson(String filename, int lineNumber, int endline)
     {
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(".debugger_communicator.jason"))) {
+        try (BufferedWriter writer = new BufferedWriter(new FileWriter(".debugger_communicator.json"))) {
             String currentDirectory = System.getProperty("user.dir");
             System.out.println(currentDirectory);
             int lastIndex = filename.lastIndexOf("/");
@@ -859,26 +859,47 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){
     //List of all and only local attributes
     public void algorithmicDebugg(DecoratedNode node, String attriburteName)
     {
-        Map lazyMap = allAttributesLazyMap(node);
-        if (lazyMap.containsKey(attriburteName)) {
-            Lazy attributeLazy = lazyMap.get(attriburteName);
-            NLocation loc = attributeLazy.getSourceLocation();
-            String qualifier = Integer.toHexString(System.identityHashCode(this));
-            if(loc != null) {
-                String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
-                int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
-                int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
-
-                try {
-                    printLines(filePath, startLine, endLine);
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        //TODO: fix when thunks work
-        Map attributeMap = allAttributesObjectMap(node);
-        System.out.println(attriburteName + ": " + Util.genericShow(attributeMap.get(attriburteName)));
+        // Map lazyMap = allAttributesLazyMap(node);
+        // if (lazyMap.containsKey(attriburteName)) {
+        //     Lazy attributeLazy = lazyMap.get(attriburteName);
+        //     NLocation loc = attributeLazy.getSourceLocation();
+        //     String qualifier = Integer.toHexString(System.identityHashCode(this));
+        //     if(loc != null) {
+        //         String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
+        //         int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
+        //         int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
+
+        //         try {
+        //             System.out.println("Equation: \n");
+        //             printLines(filePath, startLine, endLine);
+        //         } catch (IOException e) {
+        //             e.printStackTrace();
+        //         }
+        //     }
+        // }
+
+        // System.out.println("Data: \n");
+        // //TODO: fix when thunks work
+        // Map attributeMap = allAttributesObjectMap(node);
+
+        // //HACK: this entire prossess is based on string meddling
+        // String partentProduction = node.undecorate().getProdleton().getTypeUnparse();
+        // int index1 = partentProduction.indexOf("::");
+        // int index2 = attriburteName.indexOf(":");
+        // String parentNameInEquation = partentProduction.substring(0, index1) + "." + attriburteName.substring(index2+1);
+        // System.out.println(parentNameInEquation + ": " + Util.genericShow(attributeMap.get(attriburteName)));
+
+        // String[] listCurrentProduction = currentProduction.split("\\s+");
+        // String[] childFullNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
+        // String[] childFrontNames = new String[childFullNames.length()];
+        // for (int i = 0; i < childFullNames.length();  i++) {
+        //     int index = childFullNames[i].indexOf("::");
+        //     childFrontNames = childFullNames[i].substring(0, index);
+        //     System.out.println(childFrontNames[i]);
+        // }
+
+
+        //int nextChild = chooseFormList(inp, childNames);
 
     }
 

From 2cf0a4025afe4eeb090d150f0a55a3c24a69fbe1 Mon Sep 17 00:00:00 2001
From: Cauth006 
Date: Thu, 11 Apr 2024 15:15:04 -0500
Subject: [PATCH 43/64] fixed json agin (this time for sure), algorithic
 debugging is less ded

---
 runtime/java/src/common/Debug.java | 85 +++++++++++++++---------------
 1 file changed, 43 insertions(+), 42 deletions(-)

diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java
index 3d935f5fd..bf9e9a8f0 100644
--- a/runtime/java/src/common/Debug.java
+++ b/runtime/java/src/common/Debug.java
@@ -695,7 +695,7 @@ public void writeTojson(String filename, int lineNumber, int endline)
             System.out.println(currentDirectory);
             int lastIndex = filename.lastIndexOf("/");
             String fileEnd = filename.substring(lastIndex + 1);
-            writer.write("{\"file_path\": \"" + currentDirectory + fileEnd + "\", \"line_begin\": " + lineNumber + ", \"line_end\": " + endline+ "}");
+            writer.write("{\"file_path\": \"" + currentDirectory + "/" + fileEnd + "\", \"line_begin\": " + lineNumber + ", \"line_end\": " + endline+ "}");
         }catch (IOException e) {
             e.printStackTrace();
         }
@@ -859,47 +859,48 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){
     //List of all and only local attributes
     public void algorithmicDebugg(DecoratedNode node, String attriburteName)
     {
-        // Map lazyMap = allAttributesLazyMap(node);
-        // if (lazyMap.containsKey(attriburteName)) {
-        //     Lazy attributeLazy = lazyMap.get(attriburteName);
-        //     NLocation loc = attributeLazy.getSourceLocation();
-        //     String qualifier = Integer.toHexString(System.identityHashCode(this));
-        //     if(loc != null) {
-        //         String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
-        //         int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
-        //         int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
-
-        //         try {
-        //             System.out.println("Equation: \n");
-        //             printLines(filePath, startLine, endLine);
-        //         } catch (IOException e) {
-        //             e.printStackTrace();
-        //         }
-        //     }
-        // }
-
-        // System.out.println("Data: \n");
-        // //TODO: fix when thunks work
-        // Map attributeMap = allAttributesObjectMap(node);
-
-        // //HACK: this entire prossess is based on string meddling
-        // String partentProduction = node.undecorate().getProdleton().getTypeUnparse();
-        // int index1 = partentProduction.indexOf("::");
-        // int index2 = attriburteName.indexOf(":");
-        // String parentNameInEquation = partentProduction.substring(0, index1) + "." + attriburteName.substring(index2+1);
-        // System.out.println(parentNameInEquation + ": " + Util.genericShow(attributeMap.get(attriburteName)));
-
-        // String[] listCurrentProduction = currentProduction.split("\\s+");
-        // String[] childFullNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
-        // String[] childFrontNames = new String[childFullNames.length()];
-        // for (int i = 0; i < childFullNames.length();  i++) {
-        //     int index = childFullNames[i].indexOf("::");
-        //     childFrontNames = childFullNames[i].substring(0, index);
-        //     System.out.println(childFrontNames[i]);
-        // }
-
-
-        //int nextChild = chooseFormList(inp, childNames);
+        Map lazyMap = allAttributesLazyMap(node);
+        if (lazyMap.containsKey(attriburteName)) {
+            Lazy attributeLazy = lazyMap.get(attriburteName);
+            NLocation loc = attributeLazy.getSourceLocation();
+            String qualifier = Integer.toHexString(System.identityHashCode(this));
+            if(loc != null) {
+                String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
+                int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
+                int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
+
+                try {
+                    System.out.println("Equation: \n");
+                    printLines(filePath, startLine, endLine);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        System.out.println("Data: \n");
+        //TODO: fix when thunks work
+        Map attributeMap = allAttributesObjectMap(node);
+
+        //HACK: this entire prossess is based on string meddling
+        String partentProduction = node.undecorate().getProdleton().getTypeUnparse();
+        int index1 = partentProduction.indexOf("::");
+        int index2 = attriburteName.indexOf(":");
+        String parentNameInEquation = partentProduction.substring(0, index1) + "." + attriburteName.substring(index2+1);
+        System.out.println(parentNameInEquation + ": " + Util.genericShow(attributeMap.get(attriburteName)));
+
+        String currentProduction = currentNode.undecorate().getProdleton().getTypeUnparse();
+        String[] listCurrentProduction = currentProduction.split("\\s+");
+        String[] childFullNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
+        String[] childFrontNames = new String[childFullNames.length];
+        for (int i = 0; i < childFullNames.length; i++) {
+            int index = childFullNames[i].indexOf("::");
+            childFrontNames[i] = childFullNames[i].substring(0, index) + ".";
+            System.out.println(childFrontNames[i]);
+        }
+
+
+        // int nextChild = chooseFormList(inp, childNames);
 
     }
 

From 9a8976cf298bc37f71d0ed02345008312dbe503a Mon Sep 17 00:00:00 2001
From: meng0181 
Date: Tue, 16 Apr 2024 11:40:16 -0500
Subject: [PATCH 44/64] update a client function to send message to vscode
 extention

---
 runtime/java/src/common/Debug.java | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java
index bf9e9a8f0..7d4dfc39d 100644
--- a/runtime/java/src/common/Debug.java
+++ b/runtime/java/src/common/Debug.java
@@ -1,7 +1,10 @@
 //needed to run: ./silver-compile --force-origins --clean
-
 package common;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.Socket;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Scanner;
@@ -666,6 +669,23 @@ public void printProduction(DecoratedNode node)
         System.out.print("\n");
     }
 
+
+    private void sendMessageToExtension(String message) {
+        String host = "127.0.0.1"; // Host of the VS Code extension server
+        int port = 19387; 
+    
+        try (Socket socket = new Socket(host, port);
+             PrintWriter out = new PrintWriter(socket.getOutputStream(), true)) {
+    
+            out.println(message);
+            System.out.println("Message sent to extension: " + message);
+    
+        } catch (IOException e) {
+            System.err.println("Couldn't connect to the extension server at " + host + ":" + port);
+            System.err.println(e.getMessage());
+        }
+    }
+    
     // makes html of the production containing the inputed attribute name
     // the specific attribute is highlighted
     public void printEquation(DecoratedNode node, String attriburteName)
@@ -682,6 +702,8 @@ public void printEquation(DecoratedNode node, String attriburteName)
                 
                 equationHTML(file, line, endline);
                 writeTojson(file, line, endline);
+                // add a client server here, when it called send 1
+                sendMessageToExtension("1");
             }
         }
     }

From 88519ad9d2f1cff90e5d97dd6e1c5e5b30baacf2 Mon Sep 17 00:00:00 2001
From: Cauth006 
Date: Tue, 16 Apr 2024 12:18:58 -0500
Subject: [PATCH 45/64] Thunk map finally implemented, this solved many bugs,
 also you can call backwards now (backtrack still exist for the easter egg)

---
 runtime/java/src/common/Debug.java | 175 ++++++++++++++++++-----------
 1 file changed, 107 insertions(+), 68 deletions(-)

diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java
index bf9e9a8f0..56df58b8d 100644
--- a/runtime/java/src/common/Debug.java
+++ b/runtime/java/src/common/Debug.java
@@ -183,9 +183,7 @@ else if (userInputList.length == 1) {
                     }
                     break;
 
-                //TODO: Works but known bug view is weird a forward nodes 
-                //bug update: looks like the problem is with getSyhthized called in allAttributesObjectMap not sure how to fix
-                case "forwards": 
+                case "forwards": case "f":
                     if (userInputList.length != 1) {
                         System.out.println("invalid, correct usage: forwards<>");
                     }else{
@@ -261,7 +259,7 @@ else if (userInputList.length == 1) {
                     }
                     break;
 
-                case "backtrack": 
+                case "backtrack": case "backwrads": case "b":
                     if (userInputList.length != 1) {
                         System.out.println("invalid, correct usage: backtrack<>");
                     }else{
@@ -456,7 +454,7 @@ else if (userInputList.length == 1) {
                         System.out.println("invalid, correct usage: view ");
                         break;
                     }
-                    //printAttrFromName(currentNode, attributeName);
+                    printAttrFromName(currentNode, attributeName);
                     attributeDataHTML(currentNode, attributeName);
                     break;
 
@@ -492,7 +490,7 @@ else if (userInputList.length == 1) {
                         break;
                     }
                     //printAttrFromName(currentNode, attributeName);
-                    algorithmicDebugg(currentNode, attributeName);
+                    algorithmicDebugg(currentNode, attributeName, inp);
                     break;
 
 
@@ -818,18 +816,14 @@ public List removeHeaders(List stringList){
     public void printAttrFromName(DecoratedNode node, String printAttribute){
         Map attributeMap = allAttributesThunkMap(node);
         @SuppressWarnings("unchecked")
-        //TODO: fix known bug can't access the same thunk twice
-        Thunk finalTunk = (Thunk) attributeMap.get(printAttribute);
-        System.out.println(Util.genericShow(finalTunk.eval()));
-        
-        //Map attributeMap = allAttributesObjectMap(node);
-        //System.out.println(Util.genericShow(attributeMap.get(printAttribute)));
+        Object finalThunk = attributeMap.get(printAttribute);
+        System.out.println(Util.genericShow(Util.demand(finalThunk)));
     }
 
-    //TODO: update by using the thunk map inplace of the object map
+    //Higlights the 
     public void attributeDataHTML(DecoratedNode node, String printAttribute){
-        //Map attributeMap = allAttributesThunkMap(node);
-        Map attributeMap = allAttributesObjectMap(node);
+        Map attributeMap = allAttributesThunkMap(node);
+        //Map attributeMap = allAttributesObjectMap(node);
         try (BufferedWriter writer = new BufferedWriter(new FileWriter("attribute_values.html"))) {
             writer.write("\n");
             writer.write("\n");
@@ -839,11 +833,15 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){
                 String key = entry.getKey();
                 Object value = entry.getValue();
                 if (key.equals(printAttribute)){
-                    writer.write("");
-                }
-                writer.write(key + ": " + Util.genericShow(value));
-                if (key.equals(printAttribute)){
-                    writer.write("");
+                    writer.write("");
+                    writer.write(key + ": " + Util.genericShow(Util.demand(value)));
+                    writer.write("");
+                }else{
+                    if(value instanceof Thunk){
+                        writer.write(key + ": THUNKING...");
+                    }else{
+                        writer.write(key + ": " + Util.genericShow(value));
+                    }
                 }
                 writer.newLine();
             }
@@ -857,55 +855,95 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){
     }
 
     //List of all and only local attributes
-    public void algorithmicDebugg(DecoratedNode node, String attriburteName)
+    public void algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner inp)
     {
-        Map lazyMap = allAttributesLazyMap(node);
-        if (lazyMap.containsKey(attriburteName)) {
-            Lazy attributeLazy = lazyMap.get(attriburteName);
-            NLocation loc = attributeLazy.getSourceLocation();
-            String qualifier = Integer.toHexString(System.identityHashCode(this));
-            if(loc != null) {
-                String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
-                int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
-                int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
-
-                try {
-                    System.out.println("Equation: \n");
-                    printLines(filePath, startLine, endLine);
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-
-        System.out.println("Data: \n");
-        //TODO: fix when thunks work
-        Map attributeMap = allAttributesObjectMap(node);
-
-        //HACK: this entire prossess is based on string meddling
-        String partentProduction = node.undecorate().getProdleton().getTypeUnparse();
-        int index1 = partentProduction.indexOf("::");
-        int index2 = attriburteName.indexOf(":");
-        String parentNameInEquation = partentProduction.substring(0, index1) + "." + attriburteName.substring(index2+1);
-        System.out.println(parentNameInEquation + ": " + Util.genericShow(attributeMap.get(attriburteName)));
-
-        String currentProduction = currentNode.undecorate().getProdleton().getTypeUnparse();
-        String[] listCurrentProduction = currentProduction.split("\\s+");
-        String[] childFullNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
-        String[] childFrontNames = new String[childFullNames.length];
-        for (int i = 0; i < childFullNames.length; i++) {
-            int index = childFullNames[i].indexOf("::");
-            childFrontNames[i] = childFullNames[i].substring(0, index) + ".";
-            System.out.println(childFrontNames[i]);
-        }
-
-
-        // int nextChild = chooseFormList(inp, childNames);
+        // String equationString = "";
+        // Map lazyMap = allAttributesLazyMap(node);
+        // if (lazyMap.containsKey(attriburteName)) {
+        //     Lazy attributeLazy = lazyMap.get(attriburteName);
+        //     NLocation loc = attributeLazy.getSourceLocation();
+        //     String qualifier = Integer.toHexString(System.identityHashCode(this));
+        //     if(loc != null) {
+        //         String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
+        //         int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
+        //         int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
+
+        //         System.out.println("Equation: \n");
+        //          try {
+        //             equationString = getLines(filePath, startLine, endLine);
+        //         } catch (IOException e) {
+        //             e.printStackTrace();
+        //         }
+        //     }
+        // }
+
+        // System.out.println("Data: \n");
+        // //TODO: fix when thunks work
+        // Map attributeMap = allAttributesObjectMap(node);
+
+        // //HACK: this entire prossess is based on string meddling
+        // String partentProduction = node.undecorate().getProdleton().getTypeUnparse();
+        // int index1 = partentProduction.indexOf("::");
+        // int index2 = attriburteName.indexOf(":");
+        // String parentNameInEquation = partentProduction.substring(0, index1) + "." + attriburteName.substring(index2+1);
+        // System.out.println(parentNameInEquation + ": " + Util.genericShow(attributeMap.get(attriburteName)));
+
+        // String currentProduction = currentNode.undecorate().getProdleton().getTypeUnparse();
+        // String[] listCurrentProduction = currentProduction.split("\\s+");
+        // String[] childFullNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
+        // String[] childFrontNames = new String[childFullNames.length];
+        // for (int i = 0; i < childFullNames.length; i++) {
+        //     int index = childFullNames[i].indexOf("::");
+        //     childFrontNames[i] = childFullNames[i].substring(0, index) + ".";
+        //     //System.out.println(childFrontNames[i]);
+        // }
+
+        // List dependentAttributes = new ArrayList<>();
+
+        // String[] equationComponents = equationString.split("\\s+");
+        // for (String component : equationComponents) {
+        //     // Check if the word starts with any element from the array
+        //     for (String childFront : childFrontNames) {
+        //         if (component.startsWith(childFront)) {
+        //             dependentAttributes.add(component);
+        //             break;
+        //         }
+        //     }
+        // }
+        // for (String attribute : dependentAttributes) {
+        //     System.out.println(attribute);
+        // }
+
+        // String[] dependentAttributesArray = dependentAttributes.toArray(new String[0]);
+        // int inputInt = chooseFormList(inp, dependentAttributesArray);
+        // String chosenAttribute = dependentAttributesArray[inputInt];
+        // String[] chosenAttributeComponents = input.split("\\.");
+        // String nextChild;
+        // for (String fullName : childFullNames){
+        //     if (fullName.startsWith(chosenAttributeComponents[0] + "::")) {
+        //         nextChild = fullName;
+        //     }
+        // }
+
+        // //list should be list of 
+        // for (String element : list) {
+        //     // Split the element by ':' and get the suffix
+        //     String[] parts = element.split(":");
+        //     if (parts.length == 2 && parts[1].equals(desiredSuffix)) {
+        //         nextAttributeName = element;
+        //     }
+        // }
+
+        // //TODO: find childNode and nextAttributeName
+        // if(nextChild != -1){
+        //     algorithmicDebugg(childNode, nextAttributeName, Scanner inp)
+        // }
 
     }
 
     //helper foralgorithmicDebugg
-    public static void printLines(String filePath, int startLine, int endLine) throws IOException {
+    public static String getLines(String filePath, int startLine, int endLine) throws IOException {
+        String returnString = "";
         try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
             String line;
             int currentLine = 1;
@@ -918,12 +956,14 @@ public static void printLines(String filePath, int startLine, int endLine) throw
             // Print lines from startLine to endLine
             while (line != null && currentLine <= endLine) {
                 System.out.println(line);
+                returnString += line;
                 line = reader.readLine();
                 currentLine++;
             }
         }catch (IOException e) {
             e.printStackTrace();
         }
+        return returnString;
     }
 
     //List of all and only local attributes
@@ -968,7 +1008,7 @@ public static List allAttributesList(DecoratedNode node)
         return attributeList;
     }
 
-    //TODO: We want change this to use the thunk version below.
+    //Deprecated: please use allAttributesThunkMap
     public static Map allAttributesObjectMap(DecoratedNode node)
     {
         List attributeList = allAttributesList(node);
@@ -1001,8 +1041,7 @@ public static Map allAttributesObjectMap(DecoratedNode node)
         return attributeMap;
     }
 
-    //TODO: replace all uses of allAttributesObjectMap with this once it works 
-    //known bug: only can use thunks once then breaks
+    //Creates a map of attribute names to there thunks that can be demanded to get the values of the attributes
     public static Map allAttributesThunkMap(DecoratedNode node)
     {
         List attributeList = allAttributesList(node);
@@ -1030,7 +1069,7 @@ public static Map allAttributesThunkMap(DecoratedNode node)
         return attributeMap;
     }
 
-    //Another helper
+    //maps attributes names to there lazy
     public static Map allAttributesLazyMap(DecoratedNode node)
     {
         List attributeList = allAttributesList(node);

From 64886c8c0bf80fb2cd78487e847436f7fe78d181 Mon Sep 17 00:00:00 2001
From: Cauth006 
Date: Wed, 17 Apr 2024 00:05:53 -0500
Subject: [PATCH 46/64] algorithimc debugger prototype

---
 runtime/java/src/common/Debug.java | 185 +++++++++++++++++------------
 1 file changed, 107 insertions(+), 78 deletions(-)

diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java
index 1ecbda056..8499443e7 100644
--- a/runtime/java/src/common/Debug.java
+++ b/runtime/java/src/common/Debug.java
@@ -876,91 +876,120 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){
         }
     }
 
-    //List of all and only local attributes
-    public void algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner inp)
+    //HACK: this entire prossess is based on string meddling
+    public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner inp)
     {
-        // String equationString = "";
-        // Map lazyMap = allAttributesLazyMap(node);
-        // if (lazyMap.containsKey(attriburteName)) {
-        //     Lazy attributeLazy = lazyMap.get(attriburteName);
-        //     NLocation loc = attributeLazy.getSourceLocation();
-        //     String qualifier = Integer.toHexString(System.identityHashCode(this));
-        //     if(loc != null) {
-        //         String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
-        //         int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
-        //         int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
-
-        //         System.out.println("Equation: \n");
-        //          try {
-        //             equationString = getLines(filePath, startLine, endLine);
-        //         } catch (IOException e) {
-        //             e.printStackTrace();
-        //         }
-        //     }
-        // }
+        //Gets the equation we are on
+        String equationString = "";
+        Map lazyMap = allAttributesLazyMap(node);
+        if (lazyMap.containsKey(attriburteName)) {
+            Lazy attributeLazy = lazyMap.get(attriburteName);
+            NLocation loc = attributeLazy.getSourceLocation();
+            String qualifier = Integer.toHexString(System.identityHashCode(this));
+            if(loc != null) {
+                String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString();
+                int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location);
+                int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location);
+
+                System.out.println("Equation:");
+                 try {
+                    equationString = getLines(filePath, startLine, endLine);
+                    System.out.println();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
 
-        // System.out.println("Data: \n");
-        // //TODO: fix when thunks work
-        // Map attributeMap = allAttributesObjectMap(node);
-
-        // //HACK: this entire prossess is based on string meddling
-        // String partentProduction = node.undecorate().getProdleton().getTypeUnparse();
-        // int index1 = partentProduction.indexOf("::");
-        // int index2 = attriburteName.indexOf(":");
-        // String parentNameInEquation = partentProduction.substring(0, index1) + "." + attriburteName.substring(index2+1);
-        // System.out.println(parentNameInEquation + ": " + Util.genericShow(attributeMap.get(attriburteName)));
-
-        // String currentProduction = currentNode.undecorate().getProdleton().getTypeUnparse();
-        // String[] listCurrentProduction = currentProduction.split("\\s+");
-        // String[] childFullNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
-        // String[] childFrontNames = new String[childFullNames.length];
-        // for (int i = 0; i < childFullNames.length; i++) {
-        //     int index = childFullNames[i].indexOf("::");
-        //     childFrontNames[i] = childFullNames[i].substring(0, index) + ".";
-        //     //System.out.println(childFrontNames[i]);
-        // }
+        //Next we want to get the LHS of the equation
+        System.out.println("Data:");
+        Map attributeMap = allAttributesThunkMap(node);
 
-        // List dependentAttributes = new ArrayList<>();
-
-        // String[] equationComponents = equationString.split("\\s+");
-        // for (String component : equationComponents) {
-        //     // Check if the word starts with any element from the array
-        //     for (String childFront : childFrontNames) {
-        //         if (component.startsWith(childFront)) {
-        //             dependentAttributes.add(component);
-        //             break;
-        //         }
-        //     }
-        // }
+        String partentProduction = node.undecorate().getProdleton().getTypeUnparse();
+        int index1 = partentProduction.indexOf("::");
+        int index2 = attriburteName.indexOf(":");
+        String parentNameInEquation = partentProduction.substring(0, index1) + "." + attriburteName.substring(index2+1);
+        System.out.println(parentNameInEquation + ": " + Util.genericShow(Util.demand(attributeMap.get(attriburteName))));
+
+        //This generates a list of all children of the production and splits them 
+        //into the attribute front name (ex. ds) and bakc name (ex. DeclList)
+        String currentProduction = node.undecorate().getProdleton().getTypeUnparse();
+        String[] listCurrentProduction = currentProduction.split("\\s+");
+        String[] childFullNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length);
+        String[] childFrontNames = new String[childFullNames.length];
+        String[] childBackNames = new String[childFullNames.length];
+        for (int i = 0; i < childFullNames.length; i++) {
+            // System.out.println("childFullNames[i]: " + childFullNames[i]);
+            index1 = childFullNames[i].indexOf("::");
+            // System.out.println(childFullNames[i].substring(0, index1)+ ".");
+            childFrontNames[i] = childFullNames[i].substring(0, index1) + ".";
+            index2 = childFullNames[i].indexOf(":");
+            // System.out.println(childFullNames[i].substring(index2+2));
+            childBackNames[i] = childFullNames[i].substring(index2+2);
+        }
+
+        //Here we are getting the RHS of the equation (all attributes / variables)
+        //These should fallow the form .attribute (ex. ds.pp)
+        List dependentAttributes = new ArrayList<>();
+        String[] equationComponents = equationString.split("\\s+");
+        for (String component : equationComponents) {
+            // Check if the word starts with any element from the array
+            for (String childFront : childFrontNames) {
+                if (component.startsWith(childFront)) {
+                    dependentAttributes.add(component);
+                    break;
+                }
+            }
+        }
         // for (String attribute : dependentAttributes) {
         //     System.out.println(attribute);
         // }
 
-        // String[] dependentAttributesArray = dependentAttributes.toArray(new String[0]);
-        // int inputInt = chooseFormList(inp, dependentAttributesArray);
-        // String chosenAttribute = dependentAttributesArray[inputInt];
-        // String[] chosenAttributeComponents = input.split("\\.");
-        // String nextChild;
-        // for (String fullName : childFullNames){
-        //     if (fullName.startsWith(chosenAttributeComponents[0] + "::")) {
-        //         nextChild = fullName;
-        //     }
-        // }
-
-        // //list should be list of 
-        // for (String element : list) {
-        //     // Split the element by ':' and get the suffix
-        //     String[] parts = element.split(":");
-        //     if (parts.length == 2 && parts[1].equals(desiredSuffix)) {
-        //         nextAttributeName = element;
-        //     }
-        // }
-
-        // //TODO: find childNode and nextAttributeName
-        // if(nextChild != -1){
-        //     algorithmicDebugg(childNode, nextAttributeName, Scanner inp)
-        // }
+        //Next the user will pick which of these variables they want to further investigate 
+        //We split this into 2 parts index 0 is the Front name (ex. ds) 
+        //the second is the attribute  (ex. pp)
+        System.out.println();
+        System.out.println("Pick the next node to investigate");
+        String[] dependentAttributesArray = dependentAttributes.toArray(new String[0]);
+        int inputInt = chooseFormList(inp, dependentAttributesArray);
+        if(inputInt == -1)
+            return -1;
+        String chosenAttribute = dependentAttributesArray[inputInt];
+        String[] chosenAttributeComponents = chosenAttribute.split("\\.");
+
+        //Baed on what the user chose we can solve for the child they want to travle to
+        //Becaues it will have the same Front name as the variable (ex. ds.pp -> ds::DeclList)
+        String nextChildName = "";
+        for (String fullName : childFullNames){
+            if (fullName.startsWith(chosenAttributeComponents[0] + "::")) {
+                nextChildName = fullName;
+            }
+        }
+        System.out.println(nextChildName);
+
+        //Now that we know the child we can travle their
+        Integer nextChildNum = Arrays.binarySearch(childFullNames, nextChildName);
+        DecoratedNode nextNode = down(nextChildNum);
+        currentNode = nextNode;
+
+        //We also know what attribute they want to investigate
+        //it should have the same end as the chosen attribute
+        List attributeList = allAttributesList(nextNode);
+        String nextAttributeName = "";
+        //list should be list of attributes
+        for (String element : attributeList) {
+            String[] parts = element.split(":");
+            if (parts.length == 2 && parts[1].equals(chosenAttributeComponents[1])) {
+                nextAttributeName = element;
+            }
+        }
+        System.out.println(nextAttributeName);
 
+        //TODO: find childNode and nextAttributeName
+        if(nextChildName != ""){
+            algorithmicDebugg(nextNode, nextAttributeName, inp);
+        }
+        return -1;
     }
 
     //helper foralgorithmicDebugg
@@ -977,7 +1006,7 @@ public static String getLines(String filePath, int startLine, int endLine) throw
 
             // Print lines from startLine to endLine
             while (line != null && currentLine <= endLine) {
-                System.out.println(line);
+                System.out.println(line); //Comment this out
                 returnString += line;
                 line = reader.readLine();
                 currentLine++;

From 3e7ff13134533347010112aced3f1d54f2d22af7 Mon Sep 17 00:00:00 2001
From: Matthew Feraru 
Date: Wed, 17 Apr 2024 12:52:35 -0500
Subject: [PATCH 47/64] now generate rudimentary HTML for contextualizations

---
 runtime/java/src/common/Debug.java            | 12 ++--
 .../java/src/common/SimplifiedContextBox.java | 69 +++++++++++++++++++
 .../src/common/SimplifiedContextStack.java    | 44 ++++++++++--
 3 files changed, 115 insertions(+), 10 deletions(-)

diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java
index 8499443e7..73c239f66 100644
--- a/runtime/java/src/common/Debug.java
+++ b/runtime/java/src/common/Debug.java
@@ -75,7 +75,7 @@ public void runingDebug(DecoratedNode tree) {
 
         // Need to debug why first line causes NullPointerException before SimplifiedContextStack constructor called
         SimplifiedContextStack sStack = new SimplifiedContextStack(contextStack);
-        sStack.show();
+        sStack.generateHTMLFile();
 
         //Control loop
         loop: do { 
@@ -104,7 +104,7 @@ public void runingDebug(DecoratedNode tree) {
                             }
                             // if we navigate up to a parent, push it on to the stack (?)
                             cStack.pop();
-                            sStack.show();
+                            sStack.generateHTMLFile();
                             // when we push, update and show the context
                             if(toggleCStackDisplay){
                                 cStack.show();
@@ -154,7 +154,7 @@ else if (userInputList.length == 1) {
                         }
                         // if we navigate down to a child, push it on to the stack
                         cStack.push(currentNode);
-                        sStack.show();
+                        sStack.generateHTMLFile();
                         // when we push, update and show the context
                         if(toggleCStackDisplay){
                             cStack.show();
@@ -178,7 +178,7 @@ else if (userInputList.length == 1) {
                             }
                             // remove from the stack
                             cStack.pop();
-                            sStack.show();
+                            sStack.generateHTMLFile();
                             if(toggleCStackDisplay){
                                 cStack.show();
                             }
@@ -202,7 +202,7 @@ else if (userInputList.length == 1) {
                             }
                             // if we navigate to a forward, push it on to the stack
                             cStack.push(currentNode);
-                            sStack.show();
+                            sStack.generateHTMLFile();
                             // when we push, update and show the context
                             if(toggleCStackDisplay){
                                 cStack.show();
@@ -278,7 +278,7 @@ else if (userInputList.length == 1) {
                             }
                             // if we navigate backwards, pop (?)
                             cStack.pop();
-                            sStack.show();
+                            sStack.generateHTMLFile();
                             // when we push, update and show the context
                             if(toggleCStackDisplay){
                                 cStack.show();
diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java
index cc435e480..398ca9090 100644
--- a/runtime/java/src/common/SimplifiedContextBox.java
+++ b/runtime/java/src/common/SimplifiedContextBox.java
@@ -23,6 +23,75 @@ public class SimplifiedContextBox {
 
     private String sectionSep = "--------------------\n";
 
+    // For HTML: no labels added
+    public String getTreeOrderHTML() {
+        if (this.translation_x == 0 && this.higher_order_y == 0) {
+            return "0";
+        }
+        String res = "";
+        if (this.translation_x > 0) {
+            res += "TRANSLATION-" + this.translation_x;
+        }
+        if (this.higher_order_y > 0) {
+            res = ", HIGHER-ORDER-" + this.higher_order_y;
+        }
+        return res;
+    }
+
+    public String getAllSyntaxHTML() {
+        return this.text_syntax;
+    }
+
+    public String getSyntaxToHighlightHTML() {
+        return this.syntax_to_highlight;
+    }
+
+    public String getProductionsVisitedHTML() {
+        String res = "";
+        for (int i = 0; i < this.prods_visited.length; i++) {
+            res += this.prods_visited[i].toString() + "; ";
+        }
+        return res;
+    }
+
+    public String getFeaturesHTML() {
+        if (this.features.size() == 0) {
+            return "";
+        }
+        String res = "";
+        for (Feature feature: this.features) {
+            res += feature.toString() + "; ";
+        }
+        return res;
+    }
+
+
+    public String getHTMLBox() {
+        
+        // Section 1: Tree Order
+        String res = "";
+        res += "

Tree Order:

"; + res += "

" + this.getTreeOrderHTML() + "

"; + + // Section 2: Syntax + // FIXME: ACTUALLY HIGHLIGHT WITHIN ALL SYNTAX + res += "

ALL SYNTAX

"; + res += "

" + this.getAllSyntaxHTML() + "

"; + + res += "

TO HIGHLIGHT

"; + res += "

" + this.getSyntaxToHighlightHTML() + "

"; + + // Section 3: Productions Visited + res += "

Productions Visited:

"; + res += "

" + this.getProductionsVisitedHTML() + "

"; + + // Section 4: Features + res += "

Features:

"; + res += "

" + this.getFeaturesHTML() + "

"; + + return res; + } + public String getSection1Str() { String top = "Tree Order: "; diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index ed6b8bb00..2aa8adb3f 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -12,6 +12,7 @@ import java.io.PrintStream; import java.util.Iterator; import java.io.IOException; +import java.io.BufferedWriter; // Basically a decorator over a ContextStack to // generate a simplified (one node per tree order) stack @@ -21,14 +22,25 @@ public SimplifiedContextStack(ContextStack full_stack) { this.full_stack = full_stack; this.partition = new int[full_stack.get_height()]; this.filename = "simpleDebugContext.txt"; + this.filename_html = "simpleDebugContext.html"; } public SimplifiedContextStack(ContextStack full_stack, String fn) { this.full_stack = full_stack; this.partition = new int[full_stack.get_height()]; this.filename = fn; + this.filename_html = "simpleDebugContext.html"; } + public SimplifiedContextStack(ContextStack full_stack, String fn, String fn_html) { + this.full_stack = full_stack; + this.partition = new int[full_stack.get_height()]; + this.filename = fn; + this.filename_html = fn_html; + } + + + public Stack getSimplifiedStack() { this.need_set_all_prods = true; this.makeSimplifiedStack(); @@ -42,14 +54,14 @@ public void updateSimplifiedStack() { public void show(){ this.updateSimplifiedStack(); - File file = new File(this.filename); String border = "*******************"; try{ FileWriter myWriter = new FileWriter(this.filename); - Iterator iterator = this.simple_stack.iterator(); - while (iterator.hasNext()) { - SimplifiedContextBox sbox = iterator.next(); + // Want to go backwards through stack. Render it from top down in the file + // java stack iterator doesn't support going backwards + for (int i = this.simple_stack.size() - 1; i >= 0; i--) { + SimplifiedContextBox sbox = this.simple_stack.get(i); myWriter.write(border + "\n" + sbox.toString() + "\n" + border); } myWriter.close(); @@ -59,6 +71,28 @@ public void show(){ } } + public void generateHTMLFile() { + this.updateSimplifiedStack(); + + try (FileWriter myWriter = new FileWriter(this.filename_html)) { + myWriter.write("Simplified Context Stack\n"); + + // Iterate through the stack in reverse order + for (int i = this.simple_stack.size() - 1; i >= 0; i--) { + SimplifiedContextBox sbox = this.simple_stack.get(i); + + myWriter.write(sbox.getHTMLBox()); + + // Add a border between SimplifiedContextBoxes + myWriter.write("
"); + } + + myWriter.write(""); + } catch (IOException e) { + e.printStackTrace(); + } + } + private void makeSimplifiedStack() { // Clear previous simplified stack to get a brand new one @@ -253,6 +287,8 @@ private void fillInPartition() { private ContextStack full_stack; private String filename; + private String filename_html; + private Stack simple_stack = new Stack(); From 3ecbab728f632d6aab3fa3d495c611aa390b0e37 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 18 Apr 2024 14:47:46 -0500 Subject: [PATCH 48/64] minor bug fix in algorithmicDebugg mostly just wanted to commit to pull matthews changes --- runtime/java/src/common/Debug.java | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 8499443e7..0bf5f9b7c 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -842,7 +842,7 @@ public void printAttrFromName(DecoratedNode node, String printAttribute){ System.out.println(Util.genericShow(Util.demand(finalThunk))); } - //Higlights the + //Higlights the data of the specified attribute public void attributeDataHTML(DecoratedNode node, String printAttribute){ Map attributeMap = allAttributesThunkMap(node); //Map attributeMap = allAttributesObjectMap(node); @@ -855,12 +855,13 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){ String key = entry.getKey(); Object value = entry.getValue(); if (key.equals(printAttribute)){ - writer.write(""); + writer.write(""); writer.write(key + ": " + Util.genericShow(Util.demand(value))); - writer.write(""); + writer.write(""); }else{ if(value instanceof Thunk){ writer.write(key + ": THUNKING..."); + //writer.write("" + key + ": THUNKING..." + ""); }else{ writer.write(key + ": " + Util.genericShow(value)); } @@ -868,6 +869,7 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){ writer.newLine(); } writer.write("\n"); + //writer.write("\n"); writer.write("\n"); writer.write("\n"); @@ -877,6 +879,8 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){ } //HACK: this entire prossess is based on string meddling + //A better way to do this would be to have each attribute know what other attributes generate it + //This way we would not need to rely on specific string formatting public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner inp) { //Gets the equation we are on @@ -948,10 +952,15 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner //Next the user will pick which of these variables they want to further investigate //We split this into 2 parts index 0 is the Front name (ex. ds) //the second is the attribute (ex. pp) - System.out.println(); - System.out.println("Pick the next node to investigate"); String[] dependentAttributesArray = dependentAttributes.toArray(new String[0]); - int inputInt = chooseFormList(inp, dependentAttributesArray); + int inputInt = -1; + if(dependentAttributesArray.length > 0){ + System.out.println(); + System.out.println("Pick the next node to investigate"); + inputInt = chooseFormList(inp, dependentAttributesArray); + }else{ + return 0; + } if(inputInt == -1) return -1; String chosenAttribute = dependentAttributesArray[inputInt]; @@ -985,7 +994,7 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner } System.out.println(nextAttributeName); - //TODO: find childNode and nextAttributeName + //recursive time if(nextChildName != ""){ algorithmicDebugg(nextNode, nextAttributeName, inp); } From 4aa209d9f7bc7d6e5f58bc991e12fadc8fcb8031 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Thu, 18 Apr 2024 22:13:07 -0500 Subject: [PATCH 49/64] code styling started --- runtime/java/src/common/DecoratedNode.java | 213 +++--------------- runtime/java/src/common/Feature.java | 3 - .../java/src/common/NodeContextMessage.java | 13 +- .../src/common/SimplifiedContextStack.java | 6 - 4 files changed, 34 insertions(+), 201 deletions(-) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 30fb6c9c5..954ccc9a8 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -914,12 +914,8 @@ public final Object evalInhSomehowButPublic(final int attribute) { } - // ************************************************************** + // ************************************************************** // Functions and attributes added for context message support - - // To add: - // setDebuggingIndex() DONE - // getDebuggingIndex() DONE // getRedex() DONE // getIsRedex() DONE // getContractum() DONE @@ -927,70 +923,49 @@ public final Object evalInhSomehowButPublic(final int attribute) { // getFilename() DONE // getStartCoordinates()DONE // getEndCoordinates() DONE - - // getOrigin() DONE - // getIsNew() MOSTLY-DONE (concrete syntax node hacks still) - // getPrettyPrint() DONE - // getIsAttribute() DONE - // getIsTranslation() DONE - private int debugging_index; - private boolean is_redex; - private boolean is_contractum; - private boolean is_attribute_root; - private boolean need_set_is_attribute_root = true; + private boolean isRedex; + private boolean isContractum; + private boolean isAttributeRoot; + private boolean needSetIsAttributeRoot = true; - private boolean need_compute_redex_contractum = true; - - public void setDebuggingIndex(int i) { - this.debugging_index = i; - } - public int getDebuggingIndex() { - return this.debugging_index; - } + private boolean needComputeRedexContractum = true; public boolean getIsRedex() { - if (this.need_compute_redex_contractum) { - this.compute_redex_contractum(); + if (this.needComputeRedexContractum) { + this.computeRedexContractum(); } - return this.is_redex; + return this.isRedex; } public boolean getIsContractum() { - if (this.need_compute_redex_contractum) { - this.compute_redex_contractum(); + if (this.needComputeRedexContractum) { + this.computeRedexContractum(); } - return this.is_contractum; + return this.isContractum; } - private void compute_redex_contractum() { - if (!this.need_compute_redex_contractum) { + private void computeRedexContractum() { + if (!this.needComputeRedexContractum) { return; - } - - // Consider as not mutually exclusive categories for now - // Something could forward to something that forwards again - // e.g. case -> ifthen -> ifthenelse - - // This is a very basic implementation that only looks - // at forwards as the only way to have reduction semantics + } if (this.self.hasForward()) { - this.is_redex = true; + this.isRedex = true; } else { - this.is_redex = false; + this.isRedex = false; } if (this.forwardParent != null) { - this.is_contractum = true; + this.isContractum = true; } else { - this.is_contractum = false; + this.isContractum = false; } - this.need_compute_redex_contractum = false; + this.needComputeRedexContractum = false; } public DecoratedNode getRedex() { @@ -999,15 +974,11 @@ public DecoratedNode getRedex() { } private DecoratedNode getRedexHelper(DecoratedNode dn) { - // For now assume abstract syntax tree root has null parent - // or just that dn.parent repeatedly will eventually find null - - // parent of DecoratedNode root is TopNode. Might need that and not null if (dn == null || dn.isRoot()) { return null; } - if (dn.is_redex) { + if (dn.isRedex) { return dn; } else { @@ -1020,13 +991,11 @@ public DecoratedNode getContractum() { return this.getContractumHelper(this); } private DecoratedNode getContractumHelper(DecoratedNode dn) { - // For now assume abstract syntax tree root has null parent - // or just that dn.parent repeatedly will eventually find null if (dn == null || dn.isRoot()) { return null; } - if (dn.is_contractum) { + if (dn.isContractum) { return dn; } else { @@ -1037,9 +1006,7 @@ private DecoratedNode getContractumHelper(DecoratedNode dn) { public String getFilename() { boolean res = this.self instanceof silver.core.Alocation; - // System.out.println("IS ALOCATION? " + res); res = this.self instanceof Tracked; - // System.out.println("IS TRACKED? " + res); if(self == null) { return ""; @@ -1059,7 +1026,6 @@ public String getFilename() { } return ""; - } public FileCoordinate getStartCoordinates() { @@ -1108,120 +1074,19 @@ public FileCoordinate getEndCoordinates() { return new FileCoordinate(-1, -1); } - // Wrapper around OriginsUtil.getOriginOrNull() - // for the sake of my naming convention - // Not yet used but probably need for reference attributes - public NOriginInfo getOrigin() { - return OriginsUtil.getOriginOrNull(this); - // return null; - } - - - // TODO: only check getIsNew on is-translation nodes (to avoid _c concrete syntax hack!) - // If not a contractum or redex, - // if getOrigin(this) == getRedex(this) - // implies a node is "newly" created - // like const(0) from neg(x) -> sub(0, x) - // Also require it to be Is-TRANSLATION - // (since only forwarding can do this anyway) - public boolean getIsNew() { - // Silver origin tracking does - // not return Nodes or Decorated nodes - // to do == comparison - - // From Lucas on Slack - // "You just want to get the NOriginInfo, - // check if the result is a PoriginOriginInfo - // or PoriginAndRedexOriginInfo, if it is then - // pull out the first child and do .getName() on that" - - this.compute_redex_contractum(); - if (this.getIsTranslation() < 1) { - // Cannot be a translation - return false; - } - - NOriginInfo oinfo = OriginsUtil.getOriginOrNull(this.self); - // System.out.println("NOriginInfo: " + oinfo); - if (oinfo == null) { - return false; - } - if (oinfo instanceof PoriginAndRedexOriginInfo || - oinfo instanceof PoriginOriginInfo) { - - // System.out.println("IS PoriginAndRedexOriginInfo or PoriginOriginInfo"); - // Might need check types here - // Should get only Nodes from here - Object origin = oinfo.getChild(0); - - if (origin instanceof Node) { - // Use this name - // System.out.println("NAME: " + (((Node)origin).getName())); - } - - // For regular (non-root) nonterminals, there appear to be 2 origins, - // the second of which is just true, so only use the first - - // DecoratedNode dn = (DecoratedNode)origin; - // System.out.println("Origin: " + oinfo.getNumberOfChildren()); - // for (int i = 0; i < oinfo.getNumberOfChildren(); i++) { - // System.out.println("Origin name: " + oinfo.getChild(i).toString()); - // } - - String full_prod_name = this.self.getName(); - int lastIndex = full_prod_name.lastIndexOf(':'); - String prod_name = full_prod_name.substring(lastIndex + 1); - // System.out.println("PROD NAME: " + prod_name); - - // Will do a hacky version with origin.toString() for now - // since last part of production name will be in there between - // P and @ if origin is another node of the same name. - // Also, there will be a '_c@' if concrete syntax (so false if _c@ in) - String ostr = origin.toString(); - // System.out.println("ORIGIN NAME: " + ostr); - // Origin in concrete syntax case - - - // // FIXME: Don't count on this! - if (ostr.contains("_c@")) { - // Never going to be new - // System.out.println("CONCRETE SYNTAX ORIGIN"); - return false; - } - else if (ostr.contains("P" + prod_name + "@")) { - // System.out.println("ABSTRACT SYNTAX ORIGIN"); - // Not new since same name - return false; - } - else { - // System.out.println("!!!!!!!!IS-NEW!!!!!!!!"); - return true; - } - - } - else { - System.out.println("NO ORIGIN FOUND!!!"); - } - return false; - } // access pretty print attribute // through this function (a synthesized attribute) - // "pp" seems to be standard pretty print name + // "pp" is the standard pretty print name public String getPrettyPrint() { - // use genericShow(): it accesses pp if it exists - // return Util.genericShow(this).toString(); - int num_attrs = this.self.getNumberOfSynAttrs(); for (int i = 0; i < num_attrs; i++) { // Search until find name that is "pp" String name = this.self.getNameOfSynAttr(i); // Want last three characters to be ":pp" - if (name.substring(name.length() - 3).toLowerCase().equals(":pp") || - name.substring(name.length() - 13).toLowerCase().equals(":pretty_print") || - name.substring(name.length() - 12).toLowerCase().equals(":prettyprint")) { + if (name.substring(name.length() - 3).toLowerCase().equals(":pp")) { Object pp = evalSyn(i); return pp.toString(); } @@ -1230,51 +1095,39 @@ public String getPrettyPrint() { return Util.genericShow(this).toString(); } - // only set is_attribute_root once + // only set isAttributeRoot once public boolean getIsAttributeRoot() { - if (this.need_set_is_attribute_root) { + if (this.needSetIsAttributeRoot) { this.setIsAttributeRoot(); - this.need_set_is_attribute_root = false; + this.needSetIsAttributeRoot = false; } - return this.is_attribute_root; + return this.isAttributeRoot; } public boolean isRoot() { - // return this.getNode().getName().contains("root"); - - // This is better solution return this.parent == null || this.parent instanceof TopNode || this.parent.parent == null || this.parent.parent instanceof TopNode; } - - // public boolean isMain() { - // // return this.getNode().getName().contains("main"); - // return this == null || this.parent == null || this.parent instanceof TopNode; - // } public void setIsAttributeRoot() { if (! (this == null || this.isRoot())) { - - // System.out.println("SET-IS-ATTR: " + this.toString()); - Map map = Debug.allAttributesObjectMap(this.parent); + Map map = Debug.allAttributesThunkMap(this.parent); Collection values = map.values(); for (Object obj: values) { - if (obj == this) { - this.is_attribute_root = true; + if (Util.demand(obj) == this) { + this.isAttributeRoot = true; return; } } } - - this.is_attribute_root = false; + this.isAttributeRoot = false; } - public int getIsAttribute() { if (this == null || this.isRoot()) { return 0; @@ -1290,8 +1143,6 @@ public int getIsAttribute() { public int getIsTranslation() { // See how many parents are contractums - // System.out.println("GET-IS-TRANSLATION node:" + this.toString()); - // System.out.println("GET-IS-TRANSLATION has contractum:" + this.getIsContractum()); // Calling parent repeatedly will ignore forwarding nodes, so operate on // getIsContractum only as the case to determine whether forwarding occurs or not if (this == null || this.isRoot()) { diff --git a/runtime/java/src/common/Feature.java b/runtime/java/src/common/Feature.java index 567ee723a..1f465b6d1 100644 --- a/runtime/java/src/common/Feature.java +++ b/runtime/java/src/common/Feature.java @@ -30,9 +30,6 @@ else if (this.label.contains("contractum")) { else if (this.label.contains("attribute")) { this.sep = "of"; } - else if (this.label.contains("new")) { - this.sep = ""; - } else { this.sep = "INVALID LABEL"; } diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index 05c4f0990..abfa548a3 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -7,7 +7,7 @@ // Context implementation. // Headers are either TRANSLATION (for contractum) or HIGHER-ORDER -// Uses current label rules of is-contractum, is-redex, is-new, and is-attribute +// Uses current label rules of is-contractum, is-redex, and is-attribute public class NodeContextMessage { @@ -52,9 +52,6 @@ public String GetSection4() { if (this.is_contractum) { res += "*is-contractum of " + this.contractum_of + "\n"; } - if (this.is_new) { - res += "*is-new\n"; - } if (this.is_attribute_root) { res += "*is-attribute_root\n"; } @@ -86,7 +83,7 @@ public NodeContextMessage(DecoratedNode node, int num_index) { // Section 3. Determine file lines last // because they depend on computing boolean attributes if ((this.translation_x > 0) || (this.higher_order_y > 0) || - this.is_attribute_root || this.is_contractum || this.is_new) { + this.is_attribute_root || this.is_contractum) { this.pretty_print(node); } else { @@ -121,7 +118,6 @@ private void set_labels(DecoratedNode node) { this.is_contractum = node.getIsContractum(); // Will always work for forwarding. Only use this value if is_contractum this.contractum_of = this.num_index - 1; - this.is_new = node.getIsNew(); this.is_attribute_root = node.getIsAttributeRoot(); this.attribute_of = this.num_index - 1; } @@ -241,7 +237,6 @@ public FileCoordinate getFileCoordianteEnd() { private boolean is_redex; private boolean is_contractum; private int contractum_of; - private boolean is_new; private boolean is_attribute_root; private int attribute_of; @@ -257,10 +252,6 @@ public int getContractumOf() { return contractum_of; } - public boolean isNew() { - return is_new; - } - public boolean isAttributeRoot() { return is_attribute_root; } diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 2aa8adb3f..0a476ebe7 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -181,12 +181,6 @@ private void fillInFeaturesList(SimplifiedContextBox sbox, int i, int j) { Feature f = new Feature(nodeName, "contractum", targetName); sbox.features.add(f); } - if (node.isNew()) { - String nodeName = productions[k].toString(); - // No origin tracking to find prod name of origin - Feature f = new Feature(nodeName, "new"); - sbox.features.add(f); - } if (node.isAttributeRoot()) { String nodeName = productions[k].toString(); String targetName = ""; From 791c3727c5d2b2f33d6f3bee2239fc59850fd2f6 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Fri, 19 Apr 2024 12:52:27 -0500 Subject: [PATCH 50/64] commented my code --- runtime/java/src/common/ContextStack.java | 10 +++ runtime/java/src/common/Debug.java | 11 +-- runtime/java/src/common/DecoratedNode.java | 62 ++++++++++---- runtime/java/src/common/Feature.java | 32 ++++++-- .../java/src/common/NodeContextMessage.java | 80 +++++++++++-------- runtime/java/src/common/ProductionName.java | 9 ++- .../java/src/common/SimplifiedContextBox.java | 45 ++++++++++- .../src/common/SimplifiedContextStack.java | 65 +++++++++++---- 8 files changed, 235 insertions(+), 79 deletions(-) diff --git a/runtime/java/src/common/ContextStack.java b/runtime/java/src/common/ContextStack.java index 9b529c71b..dce956ad2 100644 --- a/runtime/java/src/common/ContextStack.java +++ b/runtime/java/src/common/ContextStack.java @@ -1,5 +1,15 @@ package common; +// Key intermediate structure of debugging contextualization. +// We push/pop nodes while navigating in Debug.java into this stack. +// A ContextStack is then a member of a SimplifiedContextStack, which +// produces the actual contextualization. + +// ContextStack is fundementally a stack of NodeContextMessage objects. +// Each of these objects represents a record of contextualization +// information we store about a single visited node (only maintain +// those on the path from root to the current node, like a DFS traversal). + // Wrapped around built-in Java Stack class // No error handling in current version diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 5acda6eee..2b6682083 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -59,8 +59,7 @@ public void runingDebug(DecoratedNode tree) { } // creating a context stack when we run the debugger - // CMDContextVisualization cStack = new CMDContextVisualization("********************************"); - // if we want a file visualization: + // Creates a "full" or verbose context stack. FileContextVisualization cStack = new FileContextVisualization("context.txt", "********************************"); // if we want an HTML visualization: // HTMLContextVisualization cStack = new HTMLContextVisualization("********************************"); @@ -69,11 +68,13 @@ public void runingDebug(DecoratedNode tree) { cStack.show(); } - // Fine to call this + // We need the actual context stack to be used to make the SimplifiedContextStack sStack ContextStack contextStack = (ContextStack)cStack.getContextStack(); - // System.out.println(cStack.getContextStack()); - // Need to debug why first line causes NullPointerException before SimplifiedContextStack constructor called + // This is the actual contextualization. + // Nodes are added to or removed from cStack (pushed/popped). This updates the contextStack + // sStack maintains. Then, one just has to call sStack.generateHTMLFile() to render the contextualization + // AFTER pushing/popping to/from cStack. SimplifiedContextStack sStack = new SimplifiedContextStack(contextStack); sStack.generateHTMLFile(); diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 954ccc9a8..1e1b6fe6e 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -915,23 +915,40 @@ public final Object evalInhSomehowButPublic(final int attribute) { // ************************************************************** - // Functions and attributes added for context message support - // getRedex() DONE - // getIsRedex() DONE - // getContractum() DONE - // getIsContractum() DONE - // getFilename() DONE - // getStartCoordinates()DONE - // getEndCoordinates() DONE - // getPrettyPrint() DONE - // getIsAttribute() DONE - // getIsTranslation() DONE + // Below here are all functions and attributes added to Decorated Node + // for debugging contextualization. + + // TODO. Make into Utils file. Will have worse time complexity though. + + // Functions + + // For labels in NodeContextMessageBox + // getRedex() + // getIsRedex() + // getContractum() + // getIsContractum() + + // For headers for NodeContextMessageBox + // getIsAttribute() + // getIsTranslation() + + + // Getting concrete syntax from parsed file + // getFilename() + // getStartCoordinates() + // getEndCoordinates() + // Concrete syntax alternative if node + // was created by rewrite rule or higher-order attribute + // getPrettyPrint() + + private boolean isRedex; private boolean isContractum; private boolean isAttributeRoot; private boolean needSetIsAttributeRoot = true; + // Compute only once redex/contractum property private boolean needComputeRedexContractum = true; public boolean getIsRedex() { @@ -947,6 +964,8 @@ public boolean getIsContractum() { return this.isContractum; } + // Locally determing if redex and/or contractum + // through forwarding as the rewrite rule method private void computeRedexContractum() { if (!this.needComputeRedexContractum) { return; @@ -968,11 +987,12 @@ private void computeRedexContractum() { this.needComputeRedexContractum = false; } + // Wrapper for recursive helper + // Returns the first redex parent encountered or null if none public DecoratedNode getRedex() { - // Wrapper for recursive helper return this.getRedexHelper(this); } - + private DecoratedNode getRedexHelper(DecoratedNode dn) { if (dn == null || dn.isRoot()) { return null; @@ -986,6 +1006,8 @@ private DecoratedNode getRedexHelper(DecoratedNode dn) { } } + // Wrapper for recursive helper + // Returns the first contractum parent encountered or null if none public DecoratedNode getContractum() { // Wrapper for recursive helper return this.getContractumHelper(this); @@ -1003,6 +1025,8 @@ private DecoratedNode getContractumHelper(DecoratedNode dn) { } } + // Get filename the associated with the concrete syntax location + // origin tacking follows back from this node public String getFilename() { boolean res = this.self instanceof silver.core.Alocation; @@ -1028,6 +1052,8 @@ public String getFilename() { return ""; } + // Get start coordinates for the file location associated with + // the concrete syntax location origin tacking follows back from this node public FileCoordinate getStartCoordinates() { if(self == null) { @@ -1051,6 +1077,8 @@ public FileCoordinate getStartCoordinates() { return new FileCoordinate(-1, -1); } + // Get end coordinates for the file location associated with + // the concrete syntax location origin tacking follows back from this node public FileCoordinate getEndCoordinates() { if(self == null) { @@ -1075,7 +1103,7 @@ public FileCoordinate getEndCoordinates() { } - // access pretty print attribute + // Access pretty print attribute // through this function (a synthesized attribute) // "pp" is the standard pretty print name public String getPrettyPrint() { @@ -1104,6 +1132,7 @@ public boolean getIsAttributeRoot() { return this.isAttributeRoot; } + // Catch program "root" public boolean isRoot() { return this.parent == null || @@ -1112,6 +1141,8 @@ public boolean isRoot() { this.parent.parent instanceof TopNode; } + // Higher-order attribute roots are attributes of their parent nodes. + // Only do once. public void setIsAttributeRoot() { if (! (this == null || this.isRoot())) { @@ -1127,7 +1158,7 @@ public void setIsAttributeRoot() { this.isAttributeRoot = false; } - + // Determine higher-order attribute nesting of this node. public int getIsAttribute() { if (this == null || this.isRoot()) { return 0; @@ -1141,6 +1172,7 @@ public int getIsAttribute() { } + // Determine how many forwarding edges were followed to get to this node. public int getIsTranslation() { // See how many parents are contractums // Calling parent repeatedly will ignore forwarding nodes, so operate on diff --git a/runtime/java/src/common/Feature.java b/runtime/java/src/common/Feature.java index 1f465b6d1..f75f44465 100644 --- a/runtime/java/src/common/Feature.java +++ b/runtime/java/src/common/Feature.java @@ -1,20 +1,38 @@ package common; +// The Feature class is a helper class for debugging +// contextualization. + +// It stores an individual label +// to be used in a SimplifiedContextBox. These possible +// labels are indended to be redex, contractum, and higher-order +// attribute-root. It stores one in a label. + +// The baseProd is the production name of the node +// this label is associated with. + +// The target is "other" the node that may be associated +// with a label (e.g., the redex of a contractum)/ + +// toString is the main functionality Feature offers when +// writing labels to a file as part of a SimplifiedContextStack. + + public class Feature { - public String base_prod; + public String baseProd; public String label; public String target; public String sep; - public Feature(String base_prod, String label) { - this.base_prod = base_prod; + public Feature(String baseProd, String label) { + this.baseProd = baseProd; this.label = label; this.target = ""; this.sep = ""; } - public Feature(String base_prod, String label, String target) { - this.base_prod = base_prod; + public Feature(String baseProd, String label, String target) { + this.baseProd = baseProd; this.label = label; this.target = target; this.sep = ""; @@ -38,11 +56,11 @@ else if (this.label.contains("attribute")) { public String toString() { this.setSep(); if (! this.target.equals("")) { - return this.base_prod + ": " + this.label + + return this.baseProd + ": " + this.label + " (" + this.sep + " " + this.target + ")"; } else { - return this.base_prod + ": " + this.label; + return this.baseProd + ": " + this.label; } } } diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index abfa548a3..79b21bcc4 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -4,13 +4,41 @@ import java.io.FileReader; import java.io.IOException; -// Context implementation. +// Core of the debugging contextualization implementation. +// A NodeContextMessage records all debugging contextualization +// information we wish to keep about a navigated-to node. -// Headers are either TRANSLATION (for contractum) or HIGHER-ORDER -// Uses current label rules of is-contractum, is-redex, and is-attribute +// A stack of these makes up a "full" or verbose ContextStack. +// The ContextStack is then compressed to yield a better +// SimplifiedContextStack. + +// Section 1. (HEADERS). Headers are either TRANSLATION-X (for rewrite rules) or HIGHER-ORDER +// (for higher-order attributes). They represent the cumulative nesting of these constructs +// a current node has relative to the program root. Headers are dependent on a node's labels and +// its ancestors' labels. + +// Section 2. (CONCRETE SYNTAX). Concrete syntax representation of the current node. +// Should hold parsed concrete syntax from the source file if headers are empty +// (no rewrite rules or higher-order attributes traversed yet), or the node's +// pretty print attribute otherwise. + +// Section 3. (PRODUCTION). Store the production name (we currently keep +// file lines as well. But they are not needed for the current version of +// the SimplifiedContextStack). + +// TODO. Perhaps show file lines in the SimplifiedContextStack as well, at least +// for "Tree Order" 0 nodes. + +// SECTION 4. (labels). Labels represents whether the current node is involved with +// horizontal edges. Current possible labels are is-contractuma and is-redex +// (for forwarding relationship) and is-attribute-root (for higher-order attribute subtree roots). +// Labels are currently extracted from DecoratedNode itself. + +// TODO. Add a new contextualization label/header framework for REFERENCE ATTRIBUTES. public class NodeContextMessage { + // String representations for each section. public String GetSection0() { return Integer.toString(this.num_index); } @@ -65,10 +93,7 @@ public NodeContextMessage(DecoratedNode node, int num_index) { // to make decrementing on pop() easy this.num_index = num_index; - // Section 0 - // this.set_index(); - - // Try to do all this within java given a node n + // Necessary order. // Section 2 this.prod_name = node.getNode().getName(); @@ -84,41 +109,38 @@ public NodeContextMessage(DecoratedNode node, int num_index) { // because they depend on computing boolean attributes if ((this.translation_x > 0) || (this.higher_order_y > 0) || this.is_attribute_root || this.is_contractum) { + // If headers are represent (non-"order" 0 node), its pretty print is used. this.pretty_print(node); } else { + // Otherwise file times are used for the text/concrete syntax representation. this.pull_filelines(); } - - this.has_been_initialized = true; } // Set translation_x and translation_x bools here - // Is there a way to know something is an attribute - // just from its node values? private void initialize_headers(DecoratedNode node) { this.translation_x = node.getIsTranslation(); this.higher_order_y = node.getIsAttribute(); } - // Use file location method I wrote in DecoratedNode + // Use file location method written in DecoratedNode private void fill_in_rows_and_cols(DecoratedNode node){ this.fc_start = node.getStartCoordinates(); this.fc_end = node.getEndCoordinates(); this.filename = node.getFilename(); } - // Big reduction semantics logic goes here - // Simplified now by only allowing forwards - // to be only reduction semantic + // Labels currently only regard forwarding and higher-order attributes. private void set_labels(DecoratedNode node) { this.is_redex = node.getIsRedex(); this.is_contractum = node.getIsContractum(); - // Will always work for forwarding. Only use this value if is_contractum - this.contractum_of = this.num_index - 1; this.is_attribute_root = node.getIsAttributeRoot(); + + // Only relevant if these attributes are true + this.contractum_of = this.num_index - 1; this.attribute_of = this.num_index - 1; } @@ -128,9 +150,8 @@ private void pretty_print(DecoratedNode node) { this.text_repr = node.getPrettyPrint(); } - // probably need some file I/O, but might find it - // in java runtime code. Basically extract file lines - // from row x col y to row x' to y'. + // Basically extract file lines from row x col y to + // row x' to y' for the two FileCoordinates this class stores. private void pull_filelines() { // Currently not the most efficient but should get the job done for now @@ -140,7 +161,7 @@ private void pull_filelines() { int col = 1; String res = ""; for (; row < this.fc_start.getRow(); row++) { - // System.out.println("skipping row: " + row); + // Skip these rows. String line = br.readLine(); } // Advance to starting char @@ -149,8 +170,7 @@ private void pull_filelines() { // System.out.println("skipping col: " + col); int c = br.read(); } - // reset col to 0 for last read - // col = 1; + // Now in correct row to start actually noting down file contents // Get whole lines here @@ -179,17 +199,13 @@ private void pull_filelines() { @Override public String toString() { - return this.GetSection0() + "\n" + this.GetSection1() + "\n" + this.GetSection2() + "\n" + this.GetSection3() + "\n" + this.GetSection4(); + return this.GetSection0() + "\n" + + this.GetSection1() + "\n" + + this.GetSection2() + "\n" + + this.GetSection3() + "\n" + + this.GetSection4(); } - // @Override - // protected void finalize() throws Throwable { - // next_index--; - // super.finalize(); - // } - - // Only perform attribute setting once - private boolean has_been_initialized = false; // Section 0. Every context box will have a numeric index label private int num_index; diff --git a/runtime/java/src/common/ProductionName.java b/runtime/java/src/common/ProductionName.java index ba7d4b68b..fc0729697 100644 --- a/runtime/java/src/common/ProductionName.java +++ b/runtime/java/src/common/ProductionName.java @@ -1,5 +1,12 @@ package common; +// The Production name class is a helper class for debugging +// contextualization. + +// It simply associated an index with a production name, which i +// is to be used when there are multiple productions with the same +// name encountered in a SimplifiedContextStack. + public class ProductionName { public String name; public int index; @@ -12,7 +19,7 @@ public ProductionName(String name, int index) { // Default constructor public ProductionName() { this.name = ""; - this.index = -1; + this.index = 0; } public String toString() { diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index 398ca9090..1c905c60f 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -3,6 +3,47 @@ import java.util.ArrayList; import java.util.List; +// The SimplifiedContextBox maintains all information needed for +// an individual element as part of simplified debugging contextualization. + +// They are the elements of a SimplifiedContextStack. + +// It fully represents a path that has no horizontal edges. + // (forwarding/translation + // or higher-order attribute entry links) + +// The SimplifiedContextStack creates one of these boxes each time +// it encounters a horizontal edge (plus the original started at +// the program root). + +// Tree Order represents how many horizontal edges +// have been navigated across. + +// Text Syntax represents the current path through concrete syntax. +// text_syntax should store parsed concrete syntax when (x, y) from tree order +// are both 0. Otherwise, it will be the pretty print representation. This is for +// the first production associated with a SimplifiedContextBox (widest-spanning) + +// syntax_to_highlight should be highlighted within text_syntax. It represents +// the deepest (least-spanning) navigated-to node within the path of productions +// such a box represents. + +// TODO: some extra information while doing tree traversal +// will be needed to make highlighting unique +// if there are mulitple instances of syntax_to_highlight within text_syntax. + +// Productions Visited. Just a list of production names this box's abstract +// syntax tree path represents. They should be added with increasing tree depth. + +// Interesting Features. Records which nodes are associated with horizontal edges +// themselves. This info comes from NodeContextMessage objects stored in the +// basic ContextStack from which a SimplifiedContextStack is built from. + +// There are currently HTML and toString representations of an individual box. +// When adding/generating HTML, the headers are added within SimplifiedContextStack. + + + public class SimplifiedContextBox { // 4 sections @@ -42,7 +83,7 @@ public String getAllSyntaxHTML() { return this.text_syntax; } - public String getSyntaxToHighlightHTML() { + public String getsyntax_to_highlightHTML() { return this.syntax_to_highlight; } @@ -79,7 +120,7 @@ public String getHTMLBox() { res += "

" + this.getAllSyntaxHTML() + "

"; res += "

TO HIGHLIGHT

"; - res += "

" + this.getSyntaxToHighlightHTML() + "

"; + res += "

" + this.getsyntax_to_highlightHTML() + "

"; // Section 3: Productions Visited res += "

Productions Visited:

"; diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index 0a476ebe7..a39b572fb 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -14,8 +14,24 @@ import java.io.IOException; import java.io.BufferedWriter; -// Basically a decorator over a ContextStack to -// generate a simplified (one node per tree order) stack +// Core of contextualization for debugging: +// The SimplifiedContextStack is basically a heavyweight decorator +// over a ContextStack to generate a simplified (one node per tree order/ +// horizontal-edge encountered) stack. + +// Its ContextStack member full_stack is dynamically updated while debugging occurs. +// Then, extracting a contextualization from a SimplifiedContextStack requires +// calling updateSimplifiedStack() to create an updated SimplifiedContextStack +// (of SimplifiedConextBox objects) based on the current state of the ContextStack full_stack. + +// TODO. Move full_stack updating directly into here, +// i.e., push/pop nodes into the simplifiedStack directly. + +// TODO. Find better than O(n^2) time complexity for production name assignment. + +// It currently can print some primitive text representations to a text file, or generate +// a better HTML file. (Filenames can be specified upin SimplifiedContextStack construction). + public class SimplifiedContextStack { public SimplifiedContextStack(ContextStack full_stack) { @@ -39,19 +55,14 @@ public SimplifiedContextStack(ContextStack full_stack, String fn, String fn_html this.filename_html = fn_html; } - - - public Stack getSimplifiedStack() { - this.need_set_all_prods = true; - this.makeSimplifiedStack(); - return this.simple_stack; - } - - public void updateSimplifiedStack() { + // KEY function called immediately when generateHTMLFile() or show() are called. + // Updates this.simple_stack based on any changes to this.full_stack + private void updateSimplifiedStack() { this.need_set_all_prods = true; this.makeSimplifiedStack(); } + // Create a basic text representation public void show(){ this.updateSimplifiedStack(); String border = "*******************"; @@ -71,6 +82,8 @@ public void show(){ } } + // Main function with extract a contextualization out. Must push to/pop to the separate ContextStack + // that was used to create public void generateHTMLFile() { this.updateSimplifiedStack(); @@ -93,6 +106,7 @@ public void generateHTMLFile() { } } + // Recreate the internal simplified stack based on an updated full ContextStack private void makeSimplifiedStack() { // Clear previous simplified stack to get a brand new one @@ -125,7 +139,10 @@ private void makeSimplifiedStack() { this.simple_stack.push(sbox); } - // Inclusive Partition Indices + + // Make a single box after partitioning has been done. + // Compress full stack nodes at (inclusive) indices i..j + // into a single SimplifiedContextBox. private SimplifiedContextBox makeSimplifiedBox(int i, int j) { if (i > j) { @@ -143,21 +160,23 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { sbox.translation_x = first.getTranslationX(); sbox.higher_order_y = first.getHigherOrderY(); - // // 2. Text Syntax (highlight later when rendering) + // 2. Text Syntax (highlight later when rendering) sbox.text_syntax = first.getTextRepr(); sbox.syntax_to_highlight = last.getTextRepr(); - // // 3. Need some counting logic to keep track of unique indices + // 3. Need some counting logic to keep track of unique indices this.SetAllProds(); sbox.prods_visited = Arrays.copyOfRange(this.productions, i, j + 1); - // // Make features list now (list, not array, since unknown length) + // Make features list now (list, not array, since unknown length) sbox.features = new ArrayList(); this.fillInFeaturesList(sbox, i, j); return sbox; } + // Helper to iterate through a sequence of NodeContextMessages within this.full_stack, + // extract their labels, and create a Feature list. private void fillInFeaturesList(SimplifiedContextBox sbox, int i, int j) { for (int k = i; k <= j; k++) { @@ -193,6 +212,8 @@ private void fillInFeaturesList(SimplifiedContextBox sbox, int i, int j) { } } + // Determine all production names before partitioning to give repeated names + // new indices. private void SetAllProds() { if (! this.need_set_all_prods) { @@ -203,6 +224,7 @@ private void SetAllProds() { // rather, don't want to do this for every SimplifiedContextBox created ProductionName all_prods[] = new ProductionName[this.full_stack.get_height()]; + for (int index = 0; index < this.full_stack.get_height(); index++) { ProductionName pn = new ProductionName(this.full_stack.get(index).getProdName(), -1); all_prods[index] = pn; @@ -254,6 +276,9 @@ private void SetAllProds() { return; } + // Determine partition of this.full_stack based on different headers. + // All nodes of the same header go into one partition element. + // Denote the partition by different sequential indices in the this.partition array. private void fillInPartition() { this.partition = new int[full_stack.get_height()]; @@ -279,18 +304,24 @@ private void fillInPartition() { } } + // The "full"/verbose stack holding the complete path of navigated-to nodes + // from root to the current node in a stack (basically maintain DFS traversal). + // Currently, nodes must be pushed/popped separately to full_stack first. + // TODO. Merge full_stack navigation into this stack. private ContextStack full_stack; + private String filename; private String filename_html; + // Actual contextualization comes from file rendering of the simple_stack. private Stack simple_stack = new Stack(); private boolean need_set_all_prods = true; private ProductionName productions[]; - // // Put 0 for each respective element in the first - // // stack partition, then 1, etc. Index 0 into stack is bottom + // Put 0 for each respective element in the first + // stack partition, then 1, etc. Index 0 into stack is bottom private int[] partition; } From b9e598b8dd3c2a6ba502f87cc715d29d31581bf1 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Mon, 22 Apr 2024 13:18:44 -0500 Subject: [PATCH 51/64] small formatting --- runtime/java/src/common/DecoratedNode.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 1e1b6fe6e..5e2f6b30b 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -927,6 +927,7 @@ public final Object evalInhSomehowButPublic(final int attribute) { // getIsRedex() // getContractum() // getIsContractum() + // getIsAttributeRoot() // For headers for NodeContextMessageBox // getIsAttribute() @@ -1108,8 +1109,8 @@ public FileCoordinate getEndCoordinates() { // "pp" is the standard pretty print name public String getPrettyPrint() { - int num_attrs = this.self.getNumberOfSynAttrs(); - for (int i = 0; i < num_attrs; i++) { + int numAttrs = this.self.getNumberOfSynAttrs(); + for (int i = 0; i < numAttrs; i++) { // Search until find name that is "pp" String name = this.self.getNameOfSynAttr(i); From 70807c9c3e9566cd730eca66aa2e1954d1934c52 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Mon, 22 Apr 2024 14:43:37 -0500 Subject: [PATCH 52/64] start of debugg cleanup --- runtime/java/src/common/Debug.java | 35 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 5acda6eee..20fe28d40 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -1,3 +1,5 @@ +// Auto uptade view and eq as we move + //needed to run: ./silver-compile --force-origins --clean package common; @@ -61,7 +63,7 @@ public void runingDebug(DecoratedNode tree) { // creating a context stack when we run the debugger // CMDContextVisualization cStack = new CMDContextVisualization("********************************"); // if we want a file visualization: - FileContextVisualization cStack = new FileContextVisualization("context.txt", "********************************"); + this.cStack = new FileContextVisualization("context.txt", "********************************"); // if we want an HTML visualization: // HTMLContextVisualization cStack = new HTMLContextVisualization("********************************"); cStack.push(currentNode); @@ -70,11 +72,11 @@ public void runingDebug(DecoratedNode tree) { } // Fine to call this - ContextStack contextStack = (ContextStack)cStack.getContextStack(); + this.contextStack = (ContextStack)cStack.getContextStack(); // System.out.println(cStack.getContextStack()); // Need to debug why first line causes NullPointerException before SimplifiedContextStack constructor called - SimplifiedContextStack sStack = new SimplifiedContextStack(contextStack); + this.sStack = new SimplifiedContextStack(contextStack); sStack.generateHTMLFile(); //Control loop @@ -91,14 +93,14 @@ public void runingDebug(DecoratedNode tree) { if (userInputList.length != 1) { System.out.println("invalid, correct usage: up<>"); }else{ + //TODO: lots of this logic already happens in up() we can get rid of it here if (currentNode.getParent().getParent() instanceof TopNode || currentNode.getParent() == null){ System.out.println("Root Node has no parent"); }else if (currentNode.getParent() == null){ System.out.println("Null parent"); }else{ nodeStack.push(currentNode); - currentNode = currentNode.getParent(); - //System.out.println("going to parent"); + currentNode = up(); if(toggleNameDisplay){ printName(currentNode); } @@ -113,6 +115,7 @@ public void runingDebug(DecoratedNode tree) { } break; + //Would be cool to call down on strings in addition to ints case "down": case "d": int childNum = -1; if(currentNode.getNode().hasForward()){ @@ -147,6 +150,7 @@ else if (userInputList.length == 1) { break; } else{ + //TODO: This logic should move to the down function nodeStack.push(currentNode); currentNode = childNode; if(toggleNameDisplay){ @@ -213,6 +217,9 @@ else if (userInputList.length == 1) { //TODO: known bug, don't know how to represent higher order nodes as decoratedNodes + //Known caues: its becaues the CStack suff is not being updated when we go down, + //this logic needs to move to the down function! + //probaly a general update of organizing what goes in fucntions is in order case "into": //A bit reptative right now but when I get a idea on how to list only the higer order nodes It will be better String attributeNameinto = ""; @@ -590,6 +597,9 @@ else if (userInputList.length == 1) { private DecoratedNode root; private DecoratedNode currentNode; private Stack nodeStack; + private FileContextVisualization cStack; + private ContextStack contextStack; + private SimplifiedContextStack sStack; HashMap currentNodeSynthAttrs; HashMap currentNodeInhAttrs; HashMap currentNodeLocalAttrs; @@ -608,6 +618,11 @@ public DecoratedNode up() { if (currentNode.getParent() != null) { + // printProduction(currentNode); + // System.out.println("No Null parent!"); + // System.out.println(currentNode); + // System.out.println(currentNode.getParent()); + printProduction(currentNode.getParent()); currentNode = (DecoratedNode) currentNode.getParent(); return currentNode; } @@ -881,6 +896,7 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){ //HACK: this entire prossess is based on string meddling //A better way to do this would be to have each attribute know what other attributes generate it //This way we would not need to rely on specific string formatting + //Should probaly not be pushed to public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner inp) { //Gets the equation we are on @@ -978,9 +994,16 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner //Now that we know the child we can travle their Integer nextChildNum = Arrays.binarySearch(childFullNames, nextChildName); + //Wierd bug, we can't go up after goinf down in alogdebugg DecoratedNode nextNode = down(nextChildNum); + //TODO: This logic should move to the down function currentNode = nextNode; + // System.out.println(); + // System.out.println("currentNode:"); + // printProduction(currentNode); + // System.out.println(); + //We also know what attribute they want to investigate //it should have the same end as the chosen attribute List attributeList = allAttributesList(nextNode); @@ -988,7 +1011,7 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner //list should be list of attributes for (String element : attributeList) { String[] parts = element.split(":"); - if (parts.length == 2 && parts[1].equals(chosenAttributeComponents[1])) { + if (parts.length == 2 && chosenAttributeComponents[1].startsWith(parts[1])) { nextAttributeName = element; } } From fc24180df5b809a24958419d33f4109cb8c3d5c1 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Mon, 22 Apr 2024 20:35:51 -0500 Subject: [PATCH 53/64] up and down now update the display also down is called by child names and some comments have been added to each --- runtime/java/src/common/Debug.java | 311 +++++++++++++++++++---------- 1 file changed, 205 insertions(+), 106 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 20fe28d40..1bea8edb1 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -37,133 +37,124 @@ public class Debug { public static DecoratedNode runDebug(DecoratedNode tree) { Debug debug = new Debug(); + //When Debugg is run runingDebug is called and does most the work debug.runingDebug(tree); return tree; } public void runingDebug(DecoratedNode tree) { + //IO variables Scanner inp = new Scanner(System.in); - System.out.println("Enter characters, and 'q' to quit."); String userInput; String[] userInputList; + + //Variables for termainal displays boolean toggleNameDisplay = false; boolean toggleCStackDisplay = true; boolean toggleHeadlessAttributes = false; String[] toggleChoices = {"nameDisplay", "cStackDisplay", "fullAttributeNames"}; + + //A few Place holder variable DecoratedNode childNode; this.root = tree; this.currentNode = tree; + //This stack is used for the undo command this.nodeStack = new Stack(); - if(toggleNameDisplay){ - //printNames(currentNode); - printName(currentNode); - } - - // creating a context stack when we run the debugger - // CMDContextVisualization cStack = new CMDContextVisualization("********************************"); - // if we want a file visualization: + // These stacks are important for the file visualization this.cStack = new FileContextVisualization("context.txt", "********************************"); - // if we want an HTML visualization: - // HTMLContextVisualization cStack = new HTMLContextVisualization("********************************"); cStack.push(currentNode); - if(toggleCStackDisplay){ - cStack.show(); - } - - // Fine to call this this.contextStack = (ContextStack)cStack.getContextStack(); - // System.out.println(cStack.getContextStack()); - - // Need to debug why first line causes NullPointerException before SimplifiedContextStack constructor called this.sStack = new SimplifiedContextStack(contextStack); sStack.generateHTMLFile(); - //Control loop + //Start of display + System.out.println("Enter characters, and 'q' to quit."); + if(toggleCStackDisplay){ + cStack.show(); + } + if(toggleNameDisplay){ + printName(currentNode); + } + + //Main Control loop loop: do { + //After each command is done the user is prompted again System.out.print(">DEBUGGER-PROMPT$"); userInput = inp.nextLine(); userInputList = userInput.split(" "); - //Each case has a set of conditionals to make everything is in order befor running - //in the final case they call a helper function that does most of the work + //The basic structure is we check if the user input matches any expected input + //If so we call the corresponding function where the work is done + //Most IO is done in this function and most logic is done in the auxiliary functions switch (userInputList[0]) { + //used for going to a parent of the current node case "up": case "u": if (userInputList.length != 1) { - System.out.println("invalid, correct usage: up<>"); + System.out.println("invalid, correct usage: up"); }else{ - //TODO: lots of this logic already happens in up() we can get rid of it here - if (currentNode.getParent().getParent() instanceof TopNode || currentNode.getParent() == null){ + //Conditinal makes sure there is a parent to go up to + if (currentNode.isRoot()){ System.out.println("Root Node has no parent"); - }else if (currentNode.getParent() == null){ - System.out.println("Null parent"); }else{ - nodeStack.push(currentNode); - currentNode = up(); + //If so we can go to that node + up(); + //Print all information the user wants if(toggleNameDisplay){ printName(currentNode); } - // if we navigate up to a parent, push it on to the stack (?) - cStack.pop(); - sStack.generateHTMLFile(); - // when we push, update and show the context if(toggleCStackDisplay){ cStack.show(); } + + //Update the json and html to the new node + updateDisplay(); } } break; - //Would be cool to call down on strings in addition to ints + //Used to navigate to children case "down": case "d": - int childNum = -1; - if(currentNode.getNode().hasForward()){ - System.out.println("can't go down on a forwarding node"); - break; - } - else if (userInputList.length == 1) { - System.out.println("Which child?"); + String childName = ""; + + //If the user does not provide a child we should list them out + if (userInputList.length == 1) { String currentProduction = currentNode.undecorate().getProdleton().getTypeUnparse(); String[] listCurrentProduction = currentProduction.split("\\s+"); String[] childNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length); - childNum = chooseFormList(inp, childNames); - if(childNum == -1){ - break; - } - }else if(userInputList.length == 2){ - try{ - childNum = Integer.parseInt(userInputList[1]); - }catch (NumberFormatException e) { - System.out.println("invalid, correct usage: down "); - break; - } + System.out.println("Which child?"); + displayArray(childNames); + System.out.print(">DEBUGGER-PROMPT$"); + childName = inp.nextLine(); + } + //Otherwise they should have typed one in + else if(userInputList.length == 2){ + childName = userInputList[1]; }else{ System.out.println("invalid, correct usage: down "); break; } - childNode = down(childNum); - - if(childNode == null){ - System.out.println("invalid child number"); - break; - } - else{ - //TODO: This logic should move to the down function - nodeStack.push(currentNode); - currentNode = childNode; - if(toggleNameDisplay){ - printName(currentNode); - } - // if we navigate down to a child, push it on to the stack - cStack.push(currentNode); - sStack.generateHTMLFile(); - // when we push, update and show the context - if(toggleCStackDisplay){ - cStack.show(); + try{ + if(down(childName) == -1){ + System.out.println("invalid child"); } + }catch(NullPointerException e){ + System.out.println("Null pointer"); + break; + }catch(IndexOutOfBoundsException e){ + System.out.println("Index out of bound"); + break; + } + if(toggleNameDisplay){ + printName(currentNode); } + // when we push, update and show the context + if(toggleCStackDisplay){ + cStack.show(); + } + updateDisplay(); break; case "undo": @@ -614,37 +605,117 @@ public void setCurrentNode(DecoratedNode node) currentNode = node; } - public DecoratedNode up() + //Replaces currentNode with its parent + public void up() { - if (currentNode.getParent() != null) - { - // printProduction(currentNode); - // System.out.println("No Null parent!"); - // System.out.println(currentNode); - // System.out.println(currentNode.getParent()); - printProduction(currentNode.getParent()); - currentNode = (DecoratedNode) currentNode.getParent(); - return currentNode; + //NodeStack contains past nodes not current ones + nodeStack.push(currentNode); + + //Updates curretnNode + currentNode = (DecoratedNode) currentNode.getParent(); + + //Update the various other stacks + cStack.pop(); + sStack.generateHTMLFile(); + } + + //HACK: This function currently get the file line by going through the first attribute + //This means it will not work if there is no attribute. For future work it would be nice + //if nodes could access the file and have there own file line. + public void updateDisplay() + { + //First we want to update the json to point at the top of the current production + List attributeList = allAttributesList(currentNode); + Map lazyMap = allAttributesLazyMap(currentNode); + Lazy attributeLazy = lazyMap.get(attributeList.get(0)); + NLocation loc = attributeLazy.getSourceLocation(); + if(loc != null) { + String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); + int attributeLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); + int currentLineNumber = 1; + int productionLineNum = 0; + + try (BufferedReader reader = new BufferedReader(new FileReader(file))){ + String line; + while ((line = reader.readLine()) != null) { + //HACK:Relies on the the fact that "::=" is only and always used in production declarations + if (line.contains("::=")) { + productionLineNum = currentLineNumber; + } + if (currentLineNumber >= attributeLine) { + break; + } + currentLineNumber++; + } + + writeTojson(file, productionLineNum, productionLineNum); + // add a client server here, when it called send 1 + sendMessageToExtension("1"); + }catch (IOException e) { + e.printStackTrace(); + } + } + + //Next we want to update the html file with the attribute values + Map attributeMap = allAttributesThunkMap(currentNode); + try (BufferedWriter writer = new BufferedWriter(new FileWriter("attribute_values.html"))) { + writer.write("\n"); + writer.write("\n"); + writer.write("\n"); + writer.write("
\n");
+            for (Map.Entry entry : attributeMap.entrySet()) {
+                String key = entry.getKey();
+                Object value = entry.getValue();
+                if(value instanceof Thunk){
+                    writer.write(key + ": THUNKING...");
+                }else{
+                    writer.write(key + ": " + Util.genericShow(value));
+                }
+                writer.newLine();
+            }
+            writer.write("
\n"); + writer.write("\n"); + writer.write("\n"); + }catch (IOException e) { + System.err.println("Error writing to file: " + e.getMessage()); } - return null; } - public DecoratedNode down(int child) + //Given a child name (or prefix) updates the currentNode to that child + public Integer down(String childName) { + //Find the index of the given childName + String currentProduction = currentNode.undecorate().getProdleton().getTypeUnparse(); + String[] listCurrentProduction = currentProduction.split("\\s+"); + String[] childNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length); + int childNum = Arrays.binarySearch(childNames, childName); + + //If the child was not found we check if the input was a prefix + if(childNum < 0){ + childNum = prefixSearch(childNames, childName); + } + + //Try to return the child at the corresponding index String childProductions[] = currentNode.undecorate().getProdleton().getChildTypes(); - try{ - if(childProductions[child].equals("null")){ - return null; + if(childProductions[childNum].equals("null")){ + return -1; + } + nodeStack.push(currentNode); + currentNode = currentNode.childDecorated(childNum); + // if we navigate down to a child, push it on to the stack + cStack.push(currentNode); + sStack.generateHTMLFile(); + return 1; + } + + public Integer prefixSearch(String[] array, String prefix) + { + for (int i = 0; i < array.length; i++) { + if (array[i].startsWith(prefix)) { + return i; // Return the first element with the specified prefix } - DecoratedNode childNode = currentNode.childDecorated(child); - return childNode; - }catch(NullPointerException e){ - System.out.println("Null pointer"); - return null; - }catch(IndexOutOfBoundsException e){ - System.out.println("Index out of bound"); - return null; } + return -1; } public DecoratedNode forwards(DecoratedNode node) @@ -707,7 +778,6 @@ public void printEquation(DecoratedNode node, String attriburteName) if (lazyMap.containsKey(attriburteName)) { Lazy attributeLazy = lazyMap.get(attriburteName); NLocation loc = attributeLazy.getSourceLocation(); - String qualifier = Integer.toHexString(System.identityHashCode(this)); if(loc != null) { String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); @@ -727,7 +797,6 @@ public void writeTojson(String filename, int lineNumber, int endline) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(".debugger_communicator.json"))) { String currentDirectory = System.getProperty("user.dir"); - System.out.println(currentDirectory); int lastIndex = filename.lastIndexOf("/"); String fileEnd = filename.substring(lastIndex + 1); writer.write("{\"file_path\": \"" + currentDirectory + "/" + fileEnd + "\", \"line_begin\": " + lineNumber + ", \"line_end\": " + endline+ "}"); @@ -860,7 +929,6 @@ public void printAttrFromName(DecoratedNode node, String printAttribute){ //Higlights the data of the specified attribute public void attributeDataHTML(DecoratedNode node, String printAttribute){ Map attributeMap = allAttributesThunkMap(node); - //Map attributeMap = allAttributesObjectMap(node); try (BufferedWriter writer = new BufferedWriter(new FileWriter("attribute_values.html"))) { writer.write("\n"); writer.write("\n"); @@ -876,7 +944,6 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){ }else{ if(value instanceof Thunk){ writer.write(key + ": THUNKING..."); - //writer.write("" + key + ": THUNKING..." + ""); }else{ writer.write(key + ": " + Util.genericShow(value)); } @@ -884,7 +951,6 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){ writer.newLine(); } writer.write("\n"); - //writer.write("\n"); writer.write("\n"); writer.write("\n"); @@ -905,7 +971,6 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner if (lazyMap.containsKey(attriburteName)) { Lazy attributeLazy = lazyMap.get(attriburteName); NLocation loc = attributeLazy.getSourceLocation(); - String qualifier = Integer.toHexString(System.identityHashCode(this)); if(loc != null) { String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); int startLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); @@ -993,11 +1058,11 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner System.out.println(nextChildName); //Now that we know the child we can travle their - Integer nextChildNum = Arrays.binarySearch(childFullNames, nextChildName); + // Integer nextChildNum = Arrays.binarySearch(childFullNames, nextChildName); //Wierd bug, we can't go up after goinf down in alogdebugg - DecoratedNode nextNode = down(nextChildNum); - //TODO: This logic should move to the down function - currentNode = nextNode; + if (down(nextChildName) == -1){ + System.out.println("invalid child"); + } // System.out.println(); // System.out.println("currentNode:"); @@ -1006,7 +1071,7 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner //We also know what attribute they want to investigate //it should have the same end as the chosen attribute - List attributeList = allAttributesList(nextNode); + List attributeList = allAttributesList(currentNode); String nextAttributeName = ""; //list should be list of attributes for (String element : attributeList) { @@ -1019,7 +1084,7 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner //recursive time if(nextChildName != ""){ - algorithmicDebugg(nextNode, nextAttributeName, inp); + algorithmicDebugg(currentNode, nextAttributeName, inp); } return -1; } @@ -1180,6 +1245,40 @@ public static Map allAttributesLazyMap(DecoratedNode node) return attributeMap; } + //Should be in util? + public static void displayArray(String[] array){ + for (String element : array){ + System.out.println(element); + } + } + + //For letting users type tab to autofill with an element of the input list + public static String autofill(String[] options, Scanner inp){ + while (true) { + String input = inp.nextLine(); + if (input.isEmpty()) { + continue; + } + if (input.endsWith("\t")) { // Check if Tab key is pressed + String prefix = input.substring(0, input.lastIndexOf("\t")); + return autoComplete(prefix, options); + } else { + // Handle regular input + return input; + } + } + } + + //helper for autofill + private static String autoComplete(String prefix, String[] options) { + for (String option : options) { + if (option.startsWith(prefix)) { + return option; + } + } + return ""; + } + //Should be in util? public static Integer chooseFormList(Scanner inp, String[] list){ for (int i = 0; i < list.length; i++){ From 62538cd3845b2af734cc1e54b990082df47a011f Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Mon, 22 Apr 2024 23:19:58 -0500 Subject: [PATCH 54/64] more cleaning and commenting --- runtime/java/src/common/Debug.java | 637 ++++++++++++++++------------- 1 file changed, 352 insertions(+), 285 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 1bea8edb1..ddec83f35 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -49,15 +49,16 @@ public void runingDebug(DecoratedNode tree) { String[] userInputList; //Variables for termainal displays - boolean toggleNameDisplay = false; - boolean toggleCStackDisplay = true; - boolean toggleHeadlessAttributes = false; - String[] toggleChoices = {"nameDisplay", "cStackDisplay", "fullAttributeNames"}; + this.toggleNameDisplay = false; + this.toggleCStackDisplay = true; + this.toggleHeadlessAttributes = false; + this.toggleChoices = new String[] {"nameDisplay", "cStackDisplay", "fullAttributeNames"}; //A few Place holder variable DecoratedNode childNode; this.root = tree; this.currentNode = tree; + //This stack is used for the undo command this.nodeStack = new Stack(); @@ -91,27 +92,19 @@ public void runingDebug(DecoratedNode tree) { //used for going to a parent of the current node case "up": case "u": + + //up should not have any arguments if (userInputList.length != 1) { System.out.println("invalid, correct usage: up"); - }else{ - //Conditinal makes sure there is a parent to go up to - if (currentNode.isRoot()){ - System.out.println("Root Node has no parent"); - }else{ - //If so we can go to that node - up(); - //Print all information the user wants - if(toggleNameDisplay){ - printName(currentNode); - } - if(toggleCStackDisplay){ - cStack.show(); - } - - //Update the json and html to the new node - updateDisplay(); - } + break; } + + //If so we can go to that node + if (up() == -1) + break; + + //Update the json and html and terminal to the new node + updateDisplay(); break; //Used to navigate to children @@ -128,18 +121,22 @@ public void runingDebug(DecoratedNode tree) { System.out.print(">DEBUGGER-PROMPT$"); childName = inp.nextLine(); } + //Otherwise they should have typed one in else if(userInputList.length == 2){ childName = userInputList[1]; - }else{ - System.out.println("invalid, correct usage: down "); + } + + //We do not expect more than 2 arguments for down + else{ + System.out.println("invalid, correct usage: down "); break; } + //Now that we have the childname we can try to go to it try{ - if(down(childName) == -1){ + if(down(childName) == -1) System.out.println("invalid child"); - } }catch(NullPointerException e){ System.out.println("Null pointer"); break; @@ -147,247 +144,130 @@ else if(userInputList.length == 2){ System.out.println("Index out of bound"); break; } - if(toggleNameDisplay){ - printName(currentNode); - } - // when we push, update and show the context - if(toggleCStackDisplay){ - cStack.show(); - } + + //Update the json and html and terminal to the new node updateDisplay(); break; + //used to go back to the last node traked on nodeStack case "undo": + //undo should not have any arguments if (userInputList.length != 1) { - System.out.println("invalid, correct usage: undo<>"); - }else{ - if(nodeStack.empty()){ - System.out.println("invalid no node to undo"); - } - else{ - DecoratedNode newNode = nodeStack.pop(); - currentNode = newNode; - //System.out.println("undoing last movement"); - if(toggleNameDisplay){ - printName(currentNode); - } - // remove from the stack - cStack.pop(); - sStack.generateHTMLFile(); - if(toggleCStackDisplay){ - cStack.show(); - } - } + System.out.println("invalid, correct usage: undo"); + break; } + + if(undo() == -1) + break; + + //Update the json and html and terminal to the new node + updateDisplay(); break; + //used to access forward nodes case "forwards": case "f": + //forwards should not have any arguments if (userInputList.length != 1) { System.out.println("invalid, correct usage: forwards<>"); - }else{ - childNode = forwards(currentNode); - if(childNode == null){ - System.out.println("invalid no node to forward"); - } - else{ - System.out.println("going forward"); - currentNode = childNode; - if(toggleNameDisplay){ - printName(currentNode); - } - // if we navigate to a forward, push it on to the stack - cStack.push(currentNode); - sStack.generateHTMLFile(); - // when we push, update and show the context - if(toggleCStackDisplay){ - cStack.show(); - } - } + break; } - break; - - //TODO: known bug, don't know how to represent higher order nodes as decoratedNodes - //Known caues: its becaues the CStack suff is not being updated when we go down, - //this logic needs to move to the down function! - //probaly a general update of organizing what goes in fucntions is in order - case "into": - //A bit reptative right now but when I get a idea on how to list only the higer order nodes It will be better - String attributeNameinto = ""; - Integer attributeNuminto = 0; - List attributeListinto = allAttributesList(currentNode); - if (userInputList.length == 1) { - System.out.println("Which attribute?"); - String[] attriburteArrayinto = attributeListinto.toArray(new String[attributeListinto.size()]); - attributeNuminto = chooseFormList(inp, attriburteArrayinto); - if(attributeNuminto == -1){ - break; - }else if(attributeNuminto >= attributeListinto.size()){ - System.out.println("Invaild attribute number"); - break; - }else{ - attributeNameinto = attributeListinto.get(attributeNuminto); - } - }else if(userInputList.length == 2){ - try{ - attributeNuminto = Integer.parseInt(userInputList[1]); - attributeNameinto = attributeListinto.get(attributeNuminto); - }catch (NumberFormatException e) { - System.out.println("invalid, correct usage: view "); - break; - }catch (IndexOutOfBoundsException e){ - System.out.println("Index out of bounds"); - break; - } - }else{ - System.out.println("invalid, correct usage: into "); + //try to move forward + if(forwards() == -1) break; - } - childNode = into(currentNode, attributeNameinto); - if(childNode == null){ - System.out.println("invalid input"); - } - else{ - System.out.println("going into"); - currentNode = childNode; - // if(toggleNameDisplay){ - // printName(currentNode); - // } - // // if we navigate to a forward, push it on to the stack - // cStack.push(currentNode); - // // when we push, update and show the context - // cStack.show(); - } + + //Update the json and html and terminal to the new node + updateDisplay(); break; - case "backtrack": case "backwrads": case "b": + //used to access parents that forwarded to this node + case "backtrack": case "backwards": case "b": + //backtrack should not have any arguments if (userInputList.length != 1) { System.out.println("invalid, correct usage: backtrack<>"); - }else{ - childNode = backtrack(currentNode); - if(childNode == null){ - System.out.println("invalid no node to backtrack to"); - } - else{ - System.out.println("going backwrds"); - currentNode = childNode; - if(toggleNameDisplay){ - printName(currentNode); - } - // if we navigate backwards, pop (?) - cStack.pop(); - sStack.generateHTMLFile(); - // when we push, update and show the context - if(toggleCStackDisplay){ - cStack.show(); - } - } + break; } + + //try to move backwards + if(backtrack() == -1) + break; + + //Update the json and html and terminal to the new node + updateDisplay(); break; + //Used to specify what displays the user want to see case "toggle": - String toggelChoice = ""; + String toggleInput = ""; + + //If the user does not provide a child we should list them out if (userInputList.length == 1) { - toggelChoice = toggleChoices[chooseFormList(inp, toggleChoices)]; - }else if (userInputList.length == 2){ - toggelChoice = userInputList[1]; - } - if(toggelChoice.equals("nameDisplay")){ - if(toggleNameDisplay){ - System.out.println("Production Display off"); - toggleNameDisplay = false; - }else{ - System.out.println("Production Display on"); - toggleNameDisplay = true; - } - }else if(toggelChoice.equals("fullAttributeNames")){ - if(toggleHeadlessAttributes){ - System.out.println("Headless Attributes off"); - toggleHeadlessAttributes = false; - }else{ - System.out.println("Headless Attributes on"); - toggleHeadlessAttributes = true; - } - }else if(toggelChoice.equals("cStackDisplay")){ - if(toggleCStackDisplay){ - System.out.println("cStack Display off"); - toggleCStackDisplay = false; - }else{ - System.out.println("cStack Display on"); - toggleCStackDisplay = true; - } - }else{ - System.out.println("legal toggles: nameDisplay, fullAttributeNames, cStackDisplay"); + System.out.println("Which toggle?"); + displayArray(toggleChoices); + System.out.print(">DEBUGGER-PROMPT$"); + toggleInput = inp.nextLine(); } - break; - + + //Otherwise they should have typed one in + else if (userInputList.length == 2){ + toggleInput = userInputList[1]; + } - //Display the production - case "prod": - if (userInputList.length != 1) { - System.out.println("invalid, correct usage: prod<>"); - }else{ - printProduction(currentNode); + //We do not expect more than 2 arguments for toggle + else{ + System.out.println("invalid, correct usage: toggle "); + break; } + + //Activate the toggle + toggle(toggleInput); break; + //used to display the production name on the terminal case "name": + + //name should not have any arguments if (userInputList.length != 1) { - System.out.println("invalid, correct usage: prod<>"); - }else{ - printName(currentNode); + System.out.println("invalid, correct usage: name"); + break; } + + //Print the name + printName(currentNode); break; - //Makes html of the production with the specific production highlighted - case "eq": - String attributeNameView = ""; - Integer attributeNumView = 0; - List attributeListView = allAttributesList(currentNode); + //used to jump to a specific equation + case "equation": case "eq": + String attributeNameInput = ""; + + //If the user does not provide a attribute we should list them out if (userInputList.length == 1) { + List attributeListView = allAttributesList(currentNode); + String[] attributeArrayView = attributeListView.toArray(new String[attributeListView.size()]); System.out.println("Which attribute?"); - String[] attriburteArrayView = attributeListView.toArray(new String[attributeListView.size()]); - attributeNumView = chooseFormList(inp, attriburteArrayView); - if(attributeNumView == -1){ - break; - }else if(attributeNumView >= attributeListView.size()){ - System.out.println("Invaild attribute number"); - break; - }else{ - attributeNameView = attributeListView.get(attributeNumView); - } - }else if(userInputList.length == 2){ - try{ - attributeNumView = Integer.parseInt(userInputList[1]); - attributeNameView = attributeListView.get(attributeNumView); - }catch (NumberFormatException e) { - System.out.println("invalid, correct usage: view "); - break; - }catch (IndexOutOfBoundsException e){ - System.out.println("Index out of bounds"); - break; - } - }else{ - System.out.println("invalid, correct usage: into "); + displayArray(attributeArrayView); + System.out.print(">DEBUGGER-PROMPT$"); + attributeNameInput = inp.nextLine(); + } + + //Otherwise they should have typed one in + else if(userInputList.length == 2){ + attributeNameInput = userInputList[1]; + } + + //We do not expect more than 2 arguments for eq + else{ + System.out.println("invalid, correct usage: eq "); break; } - printEquation(currentNode, attributeNameView) ; - attributeDataHTML(currentNode, ""); - // if(childNode == null){ - // System.out.println("invalid input"); - // } - // else{ - // System.out.println("going into"); - // currentNode = childNode; - // // if(toggleNameDisplay){ - // // printName(currentNode); - // // } - // // // if we navigate to a forward, push it on to the stack - // // cStack.push(currentNode); - // // // when we push, update and show the context - // // cStack.show(); - // } + try{ + if(equationHelper(attributeNameInput) == -1) + System.out.println("invalid attribute"); + }catch (IndexOutOfBoundsException e){ + System.out.println("Index out of bounds"); + break; + } break; //List synthesized attributes @@ -510,6 +390,57 @@ else if(userInputList.length == 2){ } break; + //TODO: known bug, don't know how to represent higher order nodes as decoratedNodes + //TODO: Implemeting this funtion could be done in future work + // case "into": + // //A bit reptative right now but when I get a idea on how to list only the higer order nodes It will be better + // String attributeNameinto = ""; + // Integer attributeNuminto = 0; + // List attributeListinto = allAttributesList(currentNode); + // if (userInputList.length == 1) { + // System.out.println("Which attribute?"); + // String[] attriburteArrayinto = attributeListinto.toArray(new String[attributeListinto.size()]); + // attributeNuminto = chooseFormList(inp, attriburteArrayinto); + // if(attributeNuminto == -1){ + // break; + // }else if(attributeNuminto >= attributeListinto.size()){ + // System.out.println("Invaild attribute number"); + // break; + // }else{ + // attributeNameinto = attributeListinto.get(attributeNuminto); + // } + // }else if(userInputList.length == 2){ + // try{ + // attributeNuminto = Integer.parseInt(userInputList[1]); + // attributeNameinto = attributeListinto.get(attributeNuminto); + // }catch (NumberFormatException e) { + // System.out.println("invalid, correct usage: view "); + // break; + // }catch (IndexOutOfBoundsException e){ + // System.out.println("Index out of bounds"); + // break; + // } + // }else{ + // System.out.println("invalid, correct usage: into "); + // break; + // } + // childNode = into(currentNode, attributeNameinto); + // if(childNode == null){ + // System.out.println("invalid input"); + // } + // else{ + // System.out.println("going into"); + // currentNode = childNode; + // // if(toggleNameDisplay){ + // // printName(currentNode); + // // } + // // // if we navigate to a forward, push it on to the stack + // // cStack.push(currentNode); + // // // when we push, update and show the context + // // cStack.show(); + // } + // break; + case "help": if (userInputList.length == 1) { System.out.println("call help with one of these keywords to see its functionality:"); @@ -596,6 +527,10 @@ else if(userInputList.length == 2){ HashMap currentNodeLocalAttrs; private int currentLine; private int currentColumn; + private boolean toggleNameDisplay; + private boolean toggleCStackDisplay; + private boolean toggleHeadlessAttributes; + private String[] toggleChoices; public void setCurrentNode(DecoratedNode node) { @@ -606,8 +541,15 @@ public void setCurrentNode(DecoratedNode node) } //Replaces currentNode with its parent - public void up() + public Integer up() { + + //Make sure there is a parent to go up to + if (currentNode.isRoot()){ + System.out.println("Root Node has no parent"); + return -1; + } + //NodeStack contains past nodes not current ones nodeStack.push(currentNode); @@ -617,6 +559,7 @@ public void up() //Update the various other stacks cStack.pop(); sStack.generateHTMLFile(); + return 1; } //HACK: This function currently get the file line by going through the first attribute @@ -625,36 +568,44 @@ public void up() public void updateDisplay() { //First we want to update the json to point at the top of the current production - List attributeList = allAttributesList(currentNode); - Map lazyMap = allAttributesLazyMap(currentNode); - Lazy attributeLazy = lazyMap.get(attributeList.get(0)); - NLocation loc = attributeLazy.getSourceLocation(); - if(loc != null) { - String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); - int attributeLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); - int currentLineNumber = 1; - int productionLineNum = 0; - - try (BufferedReader reader = new BufferedReader(new FileReader(file))){ - String line; - while ((line = reader.readLine()) != null) { - //HACK:Relies on the the fact that "::=" is only and always used in production declarations - if (line.contains("::=")) { - productionLineNum = currentLineNumber; - } - if (currentLineNumber >= attributeLine) { - break; + try{ + List attributeList = allAttributesList(currentNode); + Map lazyMap = allAttributesLazyMap(currentNode); + Lazy attributeLazy = lazyMap.get(attributeList.get(0)); + //FIXME: Known bug breaks after we forward + NLocation loc = attributeLazy.getSourceLocation(); + if(loc != null) { + String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); + int attributeLine = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); + int currentLineNumber = 1; + int productionLineNum = 0; + + try (BufferedReader reader = new BufferedReader(new FileReader(file))){ + String line; + while ((line = reader.readLine()) != null) { + //HACK:Relies on the the fact that "::=" is only and always used in production declarations + if (line.contains("::=")) { + productionLineNum = currentLineNumber; + } + if (currentLineNumber >= attributeLine) { + break; + } + currentLineNumber++; } - currentLineNumber++; - } - writeTojson(file, productionLineNum, productionLineNum); - // add a client server here, when it called send 1 - sendMessageToExtension("1"); - }catch (IOException e) { - e.printStackTrace(); - } + writeTojson(file, productionLineNum, productionLineNum); + // add a client server here, when it called send 1 + sendMessageToExtension("1"); + }catch (IOException e) { + e.printStackTrace(); + } + } + } + catch(NullPointerException e) + { + System.out.println("Failed to update json"); } + //Next we want to update the html file with the attribute values Map attributeMap = allAttributesThunkMap(currentNode); @@ -679,6 +630,14 @@ public void updateDisplay() }catch (IOException e) { System.err.println("Error writing to file: " + e.getMessage()); } + + //Finally Print all information the user wants + if(toggleNameDisplay){ + printName(currentNode); + } + if(toggleCStackDisplay){ + cStack.show(); + } } //Given a child name (or prefix) updates the currentNode to that child @@ -702,55 +661,164 @@ public Integer down(String childName) } nodeStack.push(currentNode); currentNode = currentNode.childDecorated(childNum); - // if we navigate down to a child, push it on to the stack + + // if we navigate down to a child, push it on to the stacks cStack.push(currentNode); sStack.generateHTMLFile(); return 1; } + //helper for finding a element with a specific prefix public Integer prefixSearch(String[] array, String prefix) { for (int i = 0; i < array.length; i++) { if (array[i].startsWith(prefix)) { - return i; // Return the first element with the specified prefix + return i; } } return -1; } - public DecoratedNode forwards(DecoratedNode node) + //will go back in the stack + public Integer undo(){ + //Can't undo if no nodes have been visited + if(nodeStack.empty()){ + System.out.println("invalid no node to undo"); + return -1; + } + + //Now we can undo by just calling on the stack we tracked for this purpose + DecoratedNode newNode = nodeStack.pop(); + currentNode = newNode; + + //Update all stacks + cStack.pop(); + sStack.generateHTMLFile(); + + return 1; + } + + //updates the currentNode to its forward child + public Integer forwards() { - if (node.getNode().hasForward()){ - currentNode = node.forward(); - return currentNode; + if (currentNode.getNode().hasForward()){ + nodeStack.push(currentNode); + currentNode = currentNode.forward(); + + // if we navigate to a forward, push it on to the stack + cStack.push(currentNode); + sStack.generateHTMLFile(); + return 1; } - return null; + System.out.println("invalid no node to forward"); + return -1; } - public DecoratedNode backtrack(DecoratedNode node) - { - currentNode = node.getForwardParent(); - return currentNode; + //updates the currentNode to its backwards parent + public Integer backtrack() + { + DecoratedNode nextNode = currentNode.getForwardParent(); + if(nextNode == null){ + System.out.println("invalid no node to backtrack to"); + return -1; + } + nodeStack.push(currentNode); + currentNode = nextNode; + // if we navigate backwards, pop (?) + cStack.pop(); + sStack.generateHTMLFile(); + + return 1; + } + + //Just an organizational function, turns toggles on/off + public Integer toggle(String toggleInput){ + String toggleChoice = ""; + + //Given the toggleInput we can find the toggleChoice + if(Arrays.asList(toggleChoices).contains(toggleInput)){ + toggleChoice = toggleInput; + }else{ + int toggleNum = prefixSearch(toggleChoices, toggleInput); + if(toggleNum > -1){ + toggleChoice = toggleChoices[toggleNum]; + }else{ + System.out.println("No such toggle"); + return -1; + } + } + + //finally we can update the corresponding toggle + if(toggleChoice.equals("nameDisplay")){ + if(toggleNameDisplay){ + System.out.println("Production Display off"); + toggleNameDisplay = false; + }else{ + System.out.println("Production Display on"); + toggleNameDisplay = true; + } + }else if(toggleChoice.equals("fullAttributeNames")){ + if(toggleHeadlessAttributes){ + System.out.println("Headless Attributes off"); + toggleHeadlessAttributes = false; + }else{ + System.out.println("Headless Attributes on"); + toggleHeadlessAttributes = true; + } + }else if(toggleChoice.equals("cStackDisplay")){ + if(toggleCStackDisplay){ + System.out.println("cStack Display off"); + toggleCStackDisplay = false; + }else{ + System.out.println("cStack Display on"); + toggleCStackDisplay = true; + } + }else{ + System.out.println("legal toggles: nameDisplay, fullAttributeNames, cStackDisplay"); + } + return 1; } - //Most user frindly print + //User friendly print public void printName(DecoratedNode node) { - String partentProduction = node.undecorate().getProdleton().getTypeUnparse(); - System.out.println(partentProduction); + String parentProduction = node.undecorate().getProdleton().getTypeUnparse(); + System.out.println(parentProduction); } - - //Gives production - public void printProduction(DecoratedNode node) + + //calls + public Integer equationHelper(String attributeName) { - String name = node.undecorate().getProdleton().getName(); - String childProductions[] = node.undecorate().getProdleton().getChildTypes(); - System.out.print(name + " "); - for (int i = 0; i < childProductions.length; i++){ - System.out.print(childProductions[i] + " "); + //Find the index of the given childName + List attributeList = allAttributesList(currentNode); + String[] attributeArray = attributeList.toArray(new String[attributeList.size()]); + int attributeNum = Arrays.binarySearch(attributeArray, attributeName); + + //If the attribute was not found we check if the input was a prefix + if(attributeNum < 0){ + attributeNum = prefixSearch(attributeArray, attributeName); + } + + //If the attribute was still not found we check if the input was a suffix + if(attributeNum < 0){ + attributeNum = suffixSearch(attributeArray, ":" + attributeName); + } + + //Try to display the attribute at the corresponding index + displayEquation(currentNode, attributeArray[attributeNum]) ; + attributeDataHTML(currentNode, ""); + return 1; + } + + //helper for finding a element with a specific suffix + public static Integer suffixSearch(String[] array, String suffix) { + for (int i = 0; i < array.length; i++) { + if (array[i].endsWith(suffix)) { + return i; + } } - System.out.print("\n"); + return -1; } @@ -772,7 +840,7 @@ private void sendMessageToExtension(String message) { // makes html of the production containing the inputed attribute name // the specific attribute is highlighted - public void printEquation(DecoratedNode node, String attriburteName) + public void displayEquation(DecoratedNode node, String attriburteName) { Map lazyMap = allAttributesLazyMap(node); if (lazyMap.containsKey(attriburteName)) { @@ -807,7 +875,7 @@ public void writeTojson(String filename, int lineNumber, int endline) - //Helper for printEquation + //Helper for displayEquation public static void equationHTML(String filename, int lineNumber, int endline) { //System.out.println("in print content"); try (BufferedReader br1 = new BufferedReader(new FileReader(filename)); @@ -1057,16 +1125,15 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner } System.out.println(nextChildName); - //Now that we know the child we can travle their + //Now that we know the child we can travel their // Integer nextChildNum = Arrays.binarySearch(childFullNames, nextChildName); - //Wierd bug, we can't go up after goinf down in alogdebugg + //Wierd bug, we can't go up after going down in alogdebugg if (down(nextChildName) == -1){ System.out.println("invalid child"); } // System.out.println(); // System.out.println("currentNode:"); - // printProduction(currentNode); // System.out.println(); //We also know what attribute they want to investigate From 646e3603037d55a539efed0229e27f93479aac13 Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 23 Apr 2024 13:43:04 -0500 Subject: [PATCH 55/64] comments and code style---all camel case now --- runtime/java/src/common/ContextStack.java | 11 +- .../src/common/FileContextVisualization.java | 3 - .../java/src/common/NodeContextMessage.java | 164 ++++++++-------- .../java/src/common/SimplifiedContextBox.java | 60 +++--- .../src/common/SimplifiedContextStack.java | 176 +++++++++--------- 5 files changed, 217 insertions(+), 197 deletions(-) diff --git a/runtime/java/src/common/ContextStack.java b/runtime/java/src/common/ContextStack.java index dce956ad2..0b56f570e 100644 --- a/runtime/java/src/common/ContextStack.java +++ b/runtime/java/src/common/ContextStack.java @@ -21,14 +21,16 @@ public class ContextStack { public void push(DecoratedNode n) { + this.height++; - NodeContextMessage ncm = new NodeContextMessage(n, this.next_index++); + NodeContextMessage ncm = new NodeContextMessage(n, this.nextIndex++); this.stack.push(ncm); } public NodeContextMessage pop() { + this.height--; - this.next_index--; + this.nextIndex--; return this.stack.pop(); } @@ -36,7 +38,7 @@ public NodeContextMessage peak() { return this.stack.peek(); } - public int get_height() { + public int getHeight() { return this.height; } @@ -45,6 +47,7 @@ public Iterator iterator() { } public NodeContextMessage get(int stackIndex) { + // Index 0 is the bottom of the stack if (stackIndex >= 0 && stackIndex < this.stack.size()) { return this.stack.get(stackIndex); @@ -56,5 +59,5 @@ public NodeContextMessage get(int stackIndex) { private Stack stack = new Stack(); private int height = 0; // Used for indices - private int next_index = 1; + private int nextIndex = 1; } diff --git a/runtime/java/src/common/FileContextVisualization.java b/runtime/java/src/common/FileContextVisualization.java index cbeffeef9..ca6a0e154 100644 --- a/runtime/java/src/common/FileContextVisualization.java +++ b/runtime/java/src/common/FileContextVisualization.java @@ -19,9 +19,6 @@ public FileContextVisualization(String filename, String border) { @Override public void show() { - File file = new File(this.filename); - - try{ FileWriter myWriter = new FileWriter(this.filename); Iterator iterator = this.contextStack.iterator(); diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index 79b21bcc4..dc0032431 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -26,133 +26,142 @@ // file lines as well. But they are not needed for the current version of // the SimplifiedContextStack). -// TODO. Perhaps show file lines in the SimplifiedContextStack as well, at least -// for "Tree Order" 0 nodes. // SECTION 4. (labels). Labels represents whether the current node is involved with // horizontal edges. Current possible labels are is-contractuma and is-redex // (for forwarding relationship) and is-attribute-root (for higher-order attribute subtree roots). // Labels are currently extracted from DecoratedNode itself. +// If showing intermediate full stack representation (ContextStack), then use GetSection_(). +// If accessing stored information for a + // TODO. Add a new contextualization label/header framework for REFERENCE ATTRIBUTES. +// TODO. Simplify this class. Remove all GetSection_() methods and just use a stack of +// NodeContextMessages as a store of information to make SimplifiedContextBoxes +// directly in SimplifiedContextStack + + public class NodeContextMessage { // String representations for each section. public String GetSection0() { - return Integer.toString(this.num_index); + return Integer.toString(this.numIndex); } public String GetSection1() { String res = ""; - boolean first_set = false; - if (this.translation_x > 0) { - res += "TRANSLATION-" + this.translation_x; - first_set = true; + boolean firstSet = false; + if (this.translationX > 0) { + res += "TRANSLATION-" + this.translationX; + firstSet = true; } - if (this.higher_order_y > 0) { - if (first_set) { + if (this.higherOrderY > 0) { + if (firstSet) { res += " & "; } - res += "HIGHER-ORDER-" + this.higher_order_y; + res += "HIGHER-ORDER-" + this.higherOrderY; } return res; } public String GetSection2() { - return this.text_repr; + return this.textRepr; } public String GetSection3() { - String res = "prod: " + this.prod_name + "\n" + - this.filename + " lines: " + this.fc_start.getRow() + - ":" + this.fc_start.getCol() + " -> " + this.fc_end.getRow() + - ":" + this.fc_end.getCol(); + + String res = "prod: " + this.prodName + "\n" + + this.filename + " lines: " + this.fcStart.getRow() + + ":" + this.fcStart.getCol() + " -> " + this.fcEnd.getRow() + + ":" + this.fcEnd.getCol(); return res; } // Not mutually exclusive labels public String GetSection4() { + String res = ""; - if (this.is_redex) { + if (this.isRedex) { res += "*is-redex\n"; } - if (this.is_contractum) { - res += "*is-contractum of " + this.contractum_of + "\n"; + if (this.isContractum) { + res += "*is-contractum of " + this.contractumOf + "\n"; } - if (this.is_attribute_root) { + if (this.isAttributeRoot) { res += "*is-attribute_root\n"; } return res; } // Constructor for NodeContextMessage - public NodeContextMessage(DecoratedNode node, int num_index) { + public NodeContextMessage(DecoratedNode node, int numIndex) { // Set the current index. Keep track of it in the stack // to make decrementing on pop() easy - this.num_index = num_index; + this.numIndex = numIndex; // Necessary order. // Section 2 - this.prod_name = node.getNode().getName(); - this.fill_in_rows_and_cols(node); + this.prodName = node.getNode().getName(); + this.fillInRowsAndCols(node); // Section 4 - this.set_labels(node); + this.setLabels(node); // Section 1--headers depend on label attributes - this.initialize_headers(node); + this.initializeHeaders(node); // Section 3. Determine file lines last // because they depend on computing boolean attributes - if ((this.translation_x > 0) || (this.higher_order_y > 0) || - this.is_attribute_root || this.is_contractum) { + if ((this.translationX > 0) || (this.higherOrderY > 0) || + this.isAttributeRoot || this.isContractum) { // If headers are represent (non-"order" 0 node), its pretty print is used. - this.pretty_print(node); + this.prettyPrint(node); } else { // Otherwise file times are used for the text/concrete syntax representation. - this.pull_filelines(); + this.pullFilelines(); } } - // Set translation_x and translation_x bools here - private void initialize_headers(DecoratedNode node) { + // Set translationX and higherOrderY bools here + private void initializeHeaders(DecoratedNode node) { - this.translation_x = node.getIsTranslation(); - this.higher_order_y = node.getIsAttribute(); + this.translationX = node.getIsTranslation(); + this.higherOrderY = node.getIsAttribute(); } // Use file location method written in DecoratedNode - private void fill_in_rows_and_cols(DecoratedNode node){ - this.fc_start = node.getStartCoordinates(); - this.fc_end = node.getEndCoordinates(); + private void fillInRowsAndCols(DecoratedNode node){ + + this.fcStart = node.getStartCoordinates(); + this.fcEnd = node.getEndCoordinates(); this.filename = node.getFilename(); } // Labels currently only regard forwarding and higher-order attributes. - private void set_labels(DecoratedNode node) { + private void setLabels(DecoratedNode node) { - this.is_redex = node.getIsRedex(); - this.is_contractum = node.getIsContractum(); - this.is_attribute_root = node.getIsAttributeRoot(); + this.isRedex = node.getIsRedex(); + this.isContractum = node.getIsContractum(); + this.isAttributeRoot = node.getIsAttributeRoot(); // Only relevant if these attributes are true - this.contractum_of = this.num_index - 1; - this.attribute_of = this.num_index - 1; + this.contractumOf = this.numIndex - 1; + this.attributeOf = this.numIndex - 1; } // access pp attribute if present - private void pretty_print(DecoratedNode node) { + private void prettyPrint(DecoratedNode node) { - this.text_repr = node.getPrettyPrint(); + this.textRepr = node.getPrettyPrint(); } // Basically extract file lines from row x col y to // row x' to y' for the two FileCoordinates this class stores. - private void pull_filelines() { + private void pullFilelines() { // Currently not the most efficient but should get the job done for now try (BufferedReader br = new BufferedReader(new FileReader(this.filename))) { @@ -160,12 +169,12 @@ private void pull_filelines() { int row = 1; int col = 1; String res = ""; - for (; row < this.fc_start.getRow(); row++) { + for (; row < this.fcStart.getRow(); row++) { // Skip these rows. String line = br.readLine(); } // Advance to starting char - for (; col < this.fc_start.getCol(); col++) { + for (; col < this.fcStart.getCol(); col++) { //Single char read // System.out.println("skipping col: " + col); int c = br.read(); @@ -174,13 +183,13 @@ private void pull_filelines() { // Now in correct row to start actually noting down file contents // Get whole lines here - for (; row < this.fc_end.getRow(); row++) { + for (; row < this.fcEnd.getRow(); row++) { // System.out.println("reading row: " + row); res += br.readLine(); res += '\n'; // Since not added with readLine() } // Now row = row.end - for (; col <= this.fc_end.getCol(); col++) { + for (; col <= this.fcEnd.getCol(); col++) { // System.out.println("reading col: " + col); char c = (char)br.read(); res += Character.toString(c); @@ -188,8 +197,8 @@ private void pull_filelines() { // Done. Can close file now br.close(); - // Just set filebytes (text_repr) to res - this.text_repr = res; + // Just set filebytes (textRepr) to res + this.textRepr = res; } catch (IOException e) { System.out.println("ERROR READING FROM FILE " + this.filename); @@ -208,31 +217,31 @@ public String toString() { // Section 0. Every context box will have a numeric index label - private int num_index; - // private static int next_index = 0; + private int numIndex; // Section 1. Header will contain TRANSLATION and/or HIGHER-ORDER public int getTranslationX() { - return this.translation_x; + return this.translationX; } + private int translationX; + public int getHigherOrderY() { - return this.higher_order_y; + return this.higherOrderY; } - private int translation_x; - private int higher_order_y; + private int higherOrderY; // Section 2. Actual text representation // (either copied from file or prity print (pp) represenation) public String getTextRepr() { - return this.text_repr; + return this.textRepr; } - private String text_repr; + private String textRepr; // Section 3. Production name and file lines public String getProdName() { - return this.prod_name; + return this.prodName; } - private String prod_name; + private String prodName; public String getFilenmae() { return this.filename; @@ -240,39 +249,40 @@ public String getFilenmae() { private String filename; public FileCoordinate getFileCoordianteStart() { - return this.fc_start; + return this.fcStart; } - private FileCoordinate fc_start; + private FileCoordinate fcStart; public FileCoordinate getFileCoordianteEnd() { - return this.fc_end; + return this.fcEnd; } - private FileCoordinate fc_end; + private FileCoordinate fcEnd; - // Section 4. Labels and associated info - private boolean is_redex; - private boolean is_contractum; - private int contractum_of; - private boolean is_attribute_root; - private int attribute_of; + // Section 4. Labels and associated info public boolean isRedex() { - return is_redex; + return isRedex; } + private boolean isRedex; public boolean isContractum() { - return is_contractum; + return isContractum; } + private boolean isContractum; public int getContractumOf() { - return contractum_of; + return contractumOf; } - + private int contractumOf; + public boolean isAttributeRoot() { - return is_attribute_root; + return isAttributeRoot; } + private boolean isAttributeRoot; public int getAttributeOf() { - return attribute_of; + return attributeOf; } + private int attributeOf; + } \ No newline at end of file diff --git a/runtime/java/src/common/SimplifiedContextBox.java b/runtime/java/src/common/SimplifiedContextBox.java index 1c905c60f..fa726b129 100644 --- a/runtime/java/src/common/SimplifiedContextBox.java +++ b/runtime/java/src/common/SimplifiedContextBox.java @@ -20,17 +20,17 @@ // have been navigated across. // Text Syntax represents the current path through concrete syntax. -// text_syntax should store parsed concrete syntax when (x, y) from tree order +// textSyntax should store parsed concrete syntax when (x, y) from tree order // are both 0. Otherwise, it will be the pretty print representation. This is for // the first production associated with a SimplifiedContextBox (widest-spanning) -// syntax_to_highlight should be highlighted within text_syntax. It represents +// syntaxToHighlight should be highlighted within textSyntax. It represents // the deepest (least-spanning) navigated-to node within the path of productions // such a box represents. // TODO: some extra information while doing tree traversal // will be needed to make highlighting unique -// if there are mulitple instances of syntax_to_highlight within text_syntax. +// if there are mulitple instances of syntaxToHighlight within textSyntax. // Productions Visited. Just a list of production names this box's abstract // syntax tree path represents. They should be added with increasing tree depth. @@ -43,21 +43,20 @@ // When adding/generating HTML, the headers are added within SimplifiedContextStack. - public class SimplifiedContextBox { // 4 sections // 1. Tree Order - public int translation_x; - public int higher_order_y; + public int translationX; + public int higherOrderY; // 2. Text Syntax - public String text_syntax; - public String syntax_to_highlight; + public String textSyntax; + public String syntaxToHighlight; // 3. Productions Visited - public ProductionName prods_visited[]; + public ProductionName prodsVisited[]; // 4. Interesting Features public List features; @@ -66,31 +65,31 @@ public class SimplifiedContextBox { // For HTML: no labels added public String getTreeOrderHTML() { - if (this.translation_x == 0 && this.higher_order_y == 0) { + if (this.translationX == 0 && this.higherOrderY == 0) { return "0"; } String res = ""; - if (this.translation_x > 0) { - res += "TRANSLATION-" + this.translation_x; + if (this.translationX > 0) { + res += "TRANSLATION-" + this.translationX; } - if (this.higher_order_y > 0) { - res = ", HIGHER-ORDER-" + this.higher_order_y; + if (this.higherOrderY > 0) { + res = ", HIGHER-ORDER-" + this.higherOrderY; } return res; } public String getAllSyntaxHTML() { - return this.text_syntax; + return this.textSyntax; } - public String getsyntax_to_highlightHTML() { - return this.syntax_to_highlight; + public String getsyntaxToHighlightHTML() { + return this.syntaxToHighlight; } public String getProductionsVisitedHTML() { String res = ""; - for (int i = 0; i < this.prods_visited.length; i++) { - res += this.prods_visited[i].toString() + "; "; + for (int i = 0; i < this.prodsVisited.length; i++) { + res += this.prodsVisited[i].toString() + "; "; } return res; } @@ -106,7 +105,6 @@ public String getFeaturesHTML() { return res; } - public String getHTMLBox() { // Section 1: Tree Order @@ -120,7 +118,7 @@ public String getHTMLBox() { res += "

" + this.getAllSyntaxHTML() + "

"; res += "

TO HIGHLIGHT

"; - res += "

" + this.getsyntax_to_highlightHTML() + "

"; + res += "

" + this.getsyntaxToHighlightHTML() + "

"; // Section 3: Productions Visited res += "

Productions Visited:

"; @@ -136,36 +134,39 @@ public String getHTMLBox() { public String getSection1Str() { String top = "Tree Order: "; - if (this.translation_x == 0 && this.higher_order_y == 0) { + if (this.translationX == 0 && this.higherOrderY == 0) { return top + "0\n"; } top += "\n"; String trans = ""; - if (this.translation_x > 0) { - trans = "TRANSLATION-" + this.translation_x + "\n"; + if (this.translationX > 0) { + trans = "TRANSLATION-" + this.translationX + "\n"; } String higher = ""; - if (this.higher_order_y > 0) { - higher = "HIGHER-ORDER-" + this.higher_order_y + "\n"; + if (this.higherOrderY > 0) { + higher = "HIGHER-ORDER-" + this.higherOrderY + "\n"; } return top + trans + higher; } public String getSection2Str() { + String header1 = "^^^^^ALL SYNTAX^^^^^\n"; String header2 = "\n^^^^^TO HIGHLIGHT^^^^^\n"; - return header1 + this.text_syntax + header2 + this.syntax_to_highlight + "\n"; + return header1 + this.textSyntax + header2 + this.syntaxToHighlight + "\n"; } public String getSection3Str() { + String res = "Productions Visited: \n"; - for (int i = 0; i < this.prods_visited.length; i++) { - res += "\t" + this.prods_visited[i].toString() + "\n"; + for (int i = 0; i < this.prodsVisited.length; i++) { + res += "\t" + this.prodsVisited[i].toString() + "\n"; } return res; } public String getSection4Str() { + if (this.features.size() == 0) { return ""; } @@ -177,6 +178,7 @@ public String getSection4Str() { } public String toString() { + return getSection1Str() + this.sectionSep + diff --git a/runtime/java/src/common/SimplifiedContextStack.java b/runtime/java/src/common/SimplifiedContextStack.java index a39b572fb..54eec9c4d 100644 --- a/runtime/java/src/common/SimplifiedContextStack.java +++ b/runtime/java/src/common/SimplifiedContextStack.java @@ -19,13 +19,13 @@ // over a ContextStack to generate a simplified (one node per tree order/ // horizontal-edge encountered) stack. -// Its ContextStack member full_stack is dynamically updated while debugging occurs. +// Its ContextStack member fullStack is dynamically updated while debugging occurs. // Then, extracting a contextualization from a SimplifiedContextStack requires // calling updateSimplifiedStack() to create an updated SimplifiedContextStack -// (of SimplifiedConextBox objects) based on the current state of the ContextStack full_stack. +// (of SimplifiedConextBox objects) based on the current state of the ContextStack fullStack. -// TODO. Move full_stack updating directly into here, -// i.e., push/pop nodes into the simplifiedStack directly. +// TODO. Move fullStack updating directly into here, +// i.e., push/pop nodes into the simplified stack directly. // TODO. Find better than O(n^2) time complexity for production name assignment. @@ -34,36 +34,39 @@ public class SimplifiedContextStack { - public SimplifiedContextStack(ContextStack full_stack) { - this.full_stack = full_stack; - this.partition = new int[full_stack.get_height()]; + public SimplifiedContextStack(ContextStack fullStack) { + this.fullStack = fullStack; + this.partition = new int[fullStack.getHeight()]; this.filename = "simpleDebugContext.txt"; - this.filename_html = "simpleDebugContext.html"; + this.filenameHTML = "simpleDebugContext.html"; } - public SimplifiedContextStack(ContextStack full_stack, String fn) { - this.full_stack = full_stack; - this.partition = new int[full_stack.get_height()]; + public SimplifiedContextStack(ContextStack fullStack, String fn) { + this.fullStack = fullStack; + this.partition = new int[fullStack.getHeight()]; this.filename = fn; - this.filename_html = "simpleDebugContext.html"; + this.filenameHTML = "simpleDebugContext.html"; } - public SimplifiedContextStack(ContextStack full_stack, String fn, String fn_html) { - this.full_stack = full_stack; - this.partition = new int[full_stack.get_height()]; + public SimplifiedContextStack(ContextStack fullStack, String fn, String fnHTML) { + this.fullStack = fullStack; + this.partition = new int[fullStack.getHeight()]; this.filename = fn; - this.filename_html = fn_html; + this.filenameHTML = fnHTML; } + // KEY function called immediately when generateHTMLFile() or show() are called. - // Updates this.simple_stack based on any changes to this.full_stack + // Updates this.simpleStack based on any changes to this.fullStack private void updateSimplifiedStack() { - this.need_set_all_prods = true; + this.needSetAllProds = true; this.makeSimplifiedStack(); } + // Create a basic text representation public void show(){ + this.updateSimplifiedStack(); String border = "*******************"; @@ -71,8 +74,8 @@ public void show(){ FileWriter myWriter = new FileWriter(this.filename); // Want to go backwards through stack. Render it from top down in the file // java stack iterator doesn't support going backwards - for (int i = this.simple_stack.size() - 1; i >= 0; i--) { - SimplifiedContextBox sbox = this.simple_stack.get(i); + for (int i = this.simpleStack.size() - 1; i >= 0; i--) { + SimplifiedContextBox sbox = this.simpleStack.get(i); myWriter.write(border + "\n" + sbox.toString() + "\n" + border); } myWriter.close(); @@ -82,17 +85,19 @@ public void show(){ } } + // Main function with extract a contextualization out. Must push to/pop to the separate ContextStack // that was used to create public void generateHTMLFile() { + this.updateSimplifiedStack(); - try (FileWriter myWriter = new FileWriter(this.filename_html)) { + try (FileWriter myWriter = new FileWriter(this.filenameHTML)) { myWriter.write("Simplified Context Stack\n"); // Iterate through the stack in reverse order - for (int i = this.simple_stack.size() - 1; i >= 0; i--) { - SimplifiedContextBox sbox = this.simple_stack.get(i); + for (int i = this.simpleStack.size() - 1; i >= 0; i--) { + SimplifiedContextBox sbox = this.simpleStack.get(i); myWriter.write(sbox.getHTMLBox()); @@ -110,25 +115,25 @@ public void generateHTMLFile() { private void makeSimplifiedStack() { // Clear previous simplified stack to get a brand new one - this.simple_stack = new Stack(); + this.simpleStack = new Stack(); this.fillInPartition(); // Now make one box per partition - int prev_partition_index = 0; + int prevPartitionIndex = 0; int start = 0; int end = -1; // System.out.println(this.partition[0]); for (int i = 0; i < this.partition.length; i++) { - if (this.partition[i] > prev_partition_index) { + if (this.partition[i] > prevPartitionIndex) { // Make box on existing start and end SimplifiedContextBox sbox = this.makeSimplifiedBox(start, end); - this.simple_stack.push(sbox); + this.simpleStack.push(sbox); start = i; end = start; - prev_partition_index++; + prevPartitionIndex++; } else { end++; @@ -136,7 +141,7 @@ private void makeSimplifiedStack() { } // Last one SimplifiedContextBox sbox = this.makeSimplifiedBox(start, end); - this.simple_stack.push(sbox); + this.simpleStack.push(sbox); } @@ -153,20 +158,20 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { // 4 sections to fill in SimplifiedContextBox sbox = new SimplifiedContextBox(); - NodeContextMessage first = this.full_stack.get(i); - NodeContextMessage last = this.full_stack.get(j); + NodeContextMessage first = this.fullStack.get(i); + NodeContextMessage last = this.fullStack.get(j); // 1. Tree Order Trivial - sbox.translation_x = first.getTranslationX(); - sbox.higher_order_y = first.getHigherOrderY(); + sbox.translationX = first.getTranslationX(); + sbox.higherOrderY = first.getHigherOrderY(); // 2. Text Syntax (highlight later when rendering) - sbox.text_syntax = first.getTextRepr(); - sbox.syntax_to_highlight = last.getTextRepr(); + sbox.textSyntax = first.getTextRepr(); + sbox.syntaxToHighlight = last.getTextRepr(); // 3. Need some counting logic to keep track of unique indices this.SetAllProds(); - sbox.prods_visited = Arrays.copyOfRange(this.productions, i, j + 1); + sbox.prodsVisited = Arrays.copyOfRange(this.productions, i, j + 1); // Make features list now (list, not array, since unknown length) sbox.features = new ArrayList(); @@ -175,12 +180,13 @@ private SimplifiedContextBox makeSimplifiedBox(int i, int j) { return sbox; } - // Helper to iterate through a sequence of NodeContextMessages within this.full_stack, + + // Helper to iterate through a sequence of NodeContextMessages within this.fullStack, // extract their labels, and create a Feature list. private void fillInFeaturesList(SimplifiedContextBox sbox, int i, int j) { for (int k = i; k <= j; k++) { - NodeContextMessage node = this.full_stack.get(k); + NodeContextMessage node = this.fullStack.get(k); if (node.isRedex()) { String nodeName = productions[k].toString(); @@ -216,18 +222,18 @@ private void fillInFeaturesList(SimplifiedContextBox sbox, int i, int j) { // new indices. private void SetAllProds() { - if (! this.need_set_all_prods) { + if (! this.needSetAllProds) { return; } // Only do this once // Not worried about multiple instances of SimplifiedContextStack; // rather, don't want to do this for every SimplifiedContextBox created - ProductionName all_prods[] = new ProductionName[this.full_stack.get_height()]; + ProductionName allProds[] = new ProductionName[this.fullStack.getHeight()]; - for (int index = 0; index < this.full_stack.get_height(); index++) { - ProductionName pn = new ProductionName(this.full_stack.get(index).getProdName(), -1); - all_prods[index] = pn; + for (int index = 0; index < this.fullStack.getHeight(); index++) { + ProductionName pn = new ProductionName(this.fullStack.get(index).getProdName(), -1); + allProds[index] = pn; } @@ -237,87 +243,89 @@ private void SetAllProds() { // Unique prod names get the 0 index (not to be displayed) // Non-unique prod names are numbered from 1..n, so need extra // scan afterwards to separate unique 1 -> 0 from actual 1 - for (int prod_index = 0; prod_index < all_prods.length; prod_index++) { + for (int prodIndex = 0; prodIndex < allProds.length; prodIndex++) { - int seq_num = 1; - String name = all_prods[prod_index].name; + int seqNum = 1; + String name = allProds[prodIndex].name; - for (int visit_index = 0; visit_index < prod_index; visit_index++) { - String cur_name = all_prods[visit_index].name; - if (cur_name.compareTo(name) == 0) { - seq_num++; + for (int visitIndex = 0; visitIndex < prodIndex; visitIndex++) { + String curName = allProds[visitIndex].name; + if (curName.compareTo(name) == 0) { + seqNum++; } } - all_prods[prod_index].index = seq_num; + allProds[prodIndex].index = seqNum; } // All prod indices >= 1. Find if need to differentiate 1 into 0 now // if truly unique and not start of 1..n sequence of indices - for (int prod_index = 0; prod_index < all_prods.length; prod_index++) { + for (int prodIndex = 0; prodIndex < allProds.length; prodIndex++) { - if (all_prods[prod_index].index == 1) { - boolean is_unique = true; - for (int k = 0; k < all_prods.length; k++) { - if (k != prod_index && - (all_prods[k].name.compareTo(all_prods[prod_index].name) == 0)) { - is_unique = false; + if (allProds[prodIndex].index == 1) { + boolean isUnique = true; + for (int k = 0; k < allProds.length; k++) { + if (k != prodIndex && + (allProds[k].name.compareTo(allProds[prodIndex].name) == 0)) { + isUnique = false; break; } } - if (is_unique) { - all_prods[prod_index].index = 0; + if (isUnique) { + allProds[prodIndex].index = 0; } } } - this.productions = all_prods; - this.need_set_all_prods = false; + this.productions = allProds; + this.needSetAllProds = false; return; } - // Determine partition of this.full_stack based on different headers. + + // Determine partition of this.fullStack based on different headers. // All nodes of the same header go into one partition element. // Denote the partition by different sequential indices in the this.partition array. private void fillInPartition() { - this.partition = new int[full_stack.get_height()]; + this.partition = new int[fullStack.getHeight()]; - int previous_x = 0; - int previous_y = 0; - int partition_index = 0; - for (int i = 0; i < this.full_stack.get_height(); i++) { - NodeContextMessage node = this.full_stack.get(i); - int cur_x = node.getTranslationX(); - int cur_y = node.getHigherOrderY(); - if (cur_x == previous_x && cur_y == previous_y) { + int previousX = 0; + int previousY = 0; + int partitionIndex = 0; + for (int i = 0; i < this.fullStack.getHeight(); i++) { + NodeContextMessage node = this.fullStack.get(i); + int curX = node.getTranslationX(); + int curY = node.getHigherOrderY(); + if (curX == previousX && curY == previousY) { // Within same set of partition - this.partition[i] = partition_index; + this.partition[i] = partitionIndex; } else { - previous_x = cur_x; - previous_y = cur_y; + previousX = curX; + previousY = curY; // Increment partition index - partition_index++; - this.partition[i] = partition_index; + partitionIndex++; + this.partition[i] = partitionIndex; } } } + // The "full"/verbose stack holding the complete path of navigated-to nodes // from root to the current node in a stack (basically maintain DFS traversal). - // Currently, nodes must be pushed/popped separately to full_stack first. - // TODO. Merge full_stack navigation into this stack. - private ContextStack full_stack; + // Currently, nodes must be pushed/popped separately to fullStack first. + // TODO. Merge fullStack navigation into this stack. + private ContextStack fullStack; private String filename; - private String filename_html; + private String filenameHTML; - // Actual contextualization comes from file rendering of the simple_stack. - private Stack simple_stack = + // Actual contextualization comes from file rendering of the simpleStack. + private Stack simpleStack = new Stack(); - private boolean need_set_all_prods = true; + private boolean needSetAllProds = true; private ProductionName productions[]; // Put 0 for each respective element in the first From 16f46d41801ccee5e6b575f665ab695f0757f4c8 Mon Sep 17 00:00:00 2001 From: Cauth006 Date: Thu, 25 Apr 2024 12:29:30 -0500 Subject: [PATCH 56/64] Finsihed cleaning and commenting debugg, algrithmic debugg now shows LHS data, old functions removed --- runtime/java/src/common/Debug.java | 712 ++++++++++------------------- 1 file changed, 251 insertions(+), 461 deletions(-) diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index ddec83f35..05d5d3880 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -48,7 +48,7 @@ public void runingDebug(DecoratedNode tree) { String userInput; String[] userInputList; - //Variables for termainal displays + //Variables for terminal displays this.toggleNameDisplay = false; this.toggleCStackDisplay = true; this.toggleHeadlessAttributes = false; @@ -133,7 +133,7 @@ else if(userInputList.length == 2){ break; } - //Now that we have the childname we can try to go to it + //Now that we have the child name we can try to go to it try{ if(down(childName) == -1) System.out.println("invalid child"); @@ -149,7 +149,8 @@ else if(userInputList.length == 2){ updateDisplay(); break; - //used to go back to the last node traked on nodeStack + //used to go back to the last node tracked on nodeStack + //FIXME: has some unexpected errors with forwarding nodes case "undo": //undo should not have any arguments if (userInputList.length != 1) { @@ -270,179 +271,129 @@ else if(userInputList.length == 2){ } break; - //List synthesized attributes - case "listSynth": - if (userInputList.length != 1 && userInputList.length != 2) { - System.out.println("invalid, correct usage: listSynth"); - }else{ - if(listSynth(currentNode) == 0){ - System.out.println("no synthesized attributes"); - } - } - break; - - //List inherited attributes - case "listInher": - if (userInputList.length != 1 && userInputList.length != 2) { - System.out.println("invalid, correct usage: listInher "); - }else{ - if(listInher(currentNode) == 0){ - System.out.println("no inherited attributes"); - } + //used to list all attributes on the terminal + case "update": case "l": + //update should not have any arguments + if (userInputList.length != 1) { + System.out.println("invalid, correct usage: list"); + break; } - break; - //list all attributes - case "list": case "l": - if (userInputList.length != 1 && userInputList.length != 2) { - System.out.println("invalid, correct usage: list"); - }else{ - printAttributes(currentNode, toggleHeadlessAttributes); - } + //Do the update + updateDisplay(); break; - //Show the values of a specific attribute - //Clear the prefix that is identical - //Print names of children not just types -- HARD! + //used to evaluate specific attributes case "view": case "v": - String attributeName = ""; - Integer attributeNum = 0; - List attributeList = allAttributesList(currentNode); + String attributeInput = ""; + + //If the user does not provide a child we should list them out if (userInputList.length == 1) { + List attributeList = allAttributesList(currentNode); + String[] attributeArray = attributeList.toArray(new String[attributeList.size()]); System.out.println("Which attribute?"); - String[] attriburteArray = attributeList.toArray(new String[attributeList.size()]); - attributeNum = chooseFormList(inp, attriburteArray); - if(attributeNum == -1){ - break; - }else if(attributeNum >= attributeList.size()){ - System.out.println("Invaild attribute number"); - break; - }else{ - attributeName = attributeList.get(attributeNum); - } - }else if(userInputList.length == 2){ - try{ - attributeNum = Integer.parseInt(userInputList[1]); - attributeName = attributeList.get(attributeNum); - }catch (NumberFormatException e) { - System.out.println("invalid, correct usage: view "); - break; - }catch (IndexOutOfBoundsException e){ - System.out.println("Index out of bounds"); - break; - } - }else{ - System.out.println("invalid, correct usage: view "); + displayArray(attributeArray); + System.out.print(">DEBUGGER-PROMPT$"); + attributeInput = inp.nextLine(); + } + + //Otherwise they should have typed one in + else if(userInputList.length == 2){ + attributeInput = userInputList[1]; + } + + //We do not expect more than 2 arguments for down + else{ + System.out.println("invalid, correct usage: view "); break; } - printAttrFromName(currentNode, attributeName); - attributeDataHTML(currentNode, attributeName); + + //Now that we have the attribute name we can try to go to it + if (attributeDataHTML(currentNode, attributeInput) == -1){ + System.out.println("invalid input"); + } break; - case "algoDebugg": case "a": - attributeName = ""; - attributeNum = 0; - attributeList = allAttributesList(currentNode); + //Proof of concept function starts a algorithmic debugging session with a given attribute + case "algoDebug": case "a": + String attributeName = ""; + + //If the user does not provide a attribute we should list them out if (userInputList.length == 1) { + List attributeList = allAttributesList(currentNode); + String[] attributeArray = attributeList.toArray(new String[attributeList.size()]); System.out.println("Which attribute?"); - String[] attriburteArray = attributeList.toArray(new String[attributeList.size()]); - attributeNum = chooseFormList(inp, attriburteArray); - if(attributeNum == -1){ - break; - }else if(attributeNum >= attributeList.size()){ - System.out.println("Invaild attribute number"); - break; - }else{ - attributeName = attributeList.get(attributeNum); - } - }else if(userInputList.length == 2){ - try{ - attributeNum = Integer.parseInt(userInputList[1]); - attributeName = attributeList.get(attributeNum); - }catch (NumberFormatException e) { - System.out.println("invalid, correct usage: view "); - break; - }catch (IndexOutOfBoundsException e){ - System.out.println("Index out of bounds"); - break; - } - }else{ + displayArray(attributeArray); + System.out.print(">DEBUGGER-PROMPT$"); + attributeName = inp.nextLine(); + } + + + //Otherwise they should have typed one in + else if(userInputList.length == 2){ + attributeName = userInputList[1]; + } + + //We do not expect more than 2 arguments for down + else{ System.out.println("invalid, correct usage: view "); break; } - //printAttrFromName(currentNode, attributeName); - algorithmicDebugg(currentNode, attributeName, inp); - break; - - case "local": - if (userInputList.length != 1 && userInputList.length != 2) { - System.out.println("invalid, correct usage: local "); - }else{ - List listLocals = getLocalAttrs(currentNode); - if(listLocals.size() == 0){ - System.out.println("no inherited attributes"); - }else{ - for (String localAttribute : listLocals){ - System.out.println("Attribute = " + localAttribute); - } - } - } + algorithmicDebug(currentNode, attributeName, inp); break; //TODO: known bug, don't know how to represent higher order nodes as decoratedNodes - //TODO: Implemeting this funtion could be done in future work + //TODO: Implementing this function could be done in future work // case "into": - // //A bit reptative right now but when I get a idea on how to list only the higer order nodes It will be better - // String attributeNameinto = ""; - // Integer attributeNuminto = 0; - // List attributeListinto = allAttributesList(currentNode); + // String attributeNameInto = ""; + + // //If the user does not provide a child we should list them out // if (userInputList.length == 1) { + // List attributeListInto = allAttributesList(currentNode); + // String[] attributeArrayInto = attributeNameInto.toArray(new String[attributeListinto.size()]); // System.out.println("Which attribute?"); - // String[] attriburteArrayinto = attributeListinto.toArray(new String[attributeListinto.size()]); - // attributeNuminto = chooseFormList(inp, attriburteArrayinto); - // if(attributeNuminto == -1){ - // break; - // }else if(attributeNuminto >= attributeListinto.size()){ - // System.out.println("Invaild attribute number"); - // break; - // }else{ - // attributeNameinto = attributeListinto.get(attributeNuminto); - // } - // }else if(userInputList.length == 2){ - // try{ - // attributeNuminto = Integer.parseInt(userInputList[1]); - // attributeNameinto = attributeListinto.get(attributeNuminto); - // }catch (NumberFormatException e) { - // System.out.println("invalid, correct usage: view "); - // break; - // }catch (IndexOutOfBoundsException e){ - // System.out.println("Index out of bounds"); - // break; - // } - // }else{ - // System.out.println("invalid, correct usage: into "); + // displayArray(attributeArrayInto); + // System.out.print(">DEBUGGER-PROMPT$"); + // childName = inp.nextLine(); + // } + + // //Otherwise they should have typed one in + // else if(userInputList.length == 2){ + // childName = userInputList[1]; + // } + + // //We do not expect more than 2 arguments for into + // else{ + // System.out.println("invalid, correct usage: down "); + // break; + // } + + // if (into(currentNode, attributeNameInto) == -1){ + // System.out.println("invalid input"); // break; // } - // childNode = into(currentNode, attributeNameinto); // if(childNode == null){ // System.out.println("invalid input"); // } // else{ // System.out.println("going into"); // currentNode = childNode; - // // if(toggleNameDisplay){ - // // printName(currentNode); - // // } - // // // if we navigate to a forward, push it on to the stack - // // cStack.push(currentNode); - // // // when we push, update and show the context - // // cStack.show(); + // if(toggleNameDisplay){ + // printName(currentNode); + // } + // // if we navigate to a forward, push it on to the stack + // cStack.push(currentNode); + // // when we push, update and show the context + // cStack.show(); // } // break; + //Display legal operations case "help": - if (userInputList.length == 1) { + + //If called alone give operation names + if (userInputList.length != 2) { System.out.println("call help with one of these keywords to see its functionality:"); System.out.println("toggle "); System.out.println("up"); @@ -452,13 +403,12 @@ else if(userInputList.length == 2){ System.out.println("backtrack"); System.out.println("prod"); System.out.println("eq"); - System.out.println("listSynth"); - System.out.println("listInher"); - System.out.println("local"); - System.out.println("list"); - System.out.println("into"); + System.out.println("update"); System.out.println("exit"); - }else if(userInputList.length == 2){ + } + + //More detailed information about specific calls + else if(userInputList.length == 2){ if(userInputList[1].equals("up")){ System.out.println("The current node changes to its the parent"); }else if(userInputList[1].equals("down")){ @@ -479,11 +429,7 @@ else if(userInputList.length == 2){ System.out.println("prints the production of the current node"); }else if(userInputList[1].equals("eq")){ System.out.println("prints the equation of the current node"); - }else if(userInputList[1].equals("listSynth")){ - System.out.println("prints the Synthisized attributes of the current node"); - }else if(userInputList[1].equals("listInher")){ - System.out.println("prints the inherited attributes of the current node"); - }else if(userInputList[1].equals("list")){ + }else if(userInputList[1].equals("update")){ System.out.println("prints the attributes of the current node"); }else if(userInputList[1].equals("local")){ System.out.println("prints the local attributes of the current node"); @@ -498,33 +444,29 @@ else if(userInputList.length == 2){ }else{ System.out.println("try just calling help"); } - }else{ - System.out.println("try just calling help"); - } break; //Many ways to leave - case "exit": - case "q": - case "quit": + case "exit": case "q": case "quit": System.out.println("debugger out"); break loop; + + //If the user call anything illegal default: System.out.println("invalid input call help for legal inputs"); break; } } while(true); } + + //variable declarations private DecoratedNode root; private DecoratedNode currentNode; private Stack nodeStack; private FileContextVisualization cStack; private ContextStack contextStack; private SimplifiedContextStack sStack; - HashMap currentNodeSynthAttrs; - HashMap currentNodeInhAttrs; - HashMap currentNodeLocalAttrs; private int currentLine; private int currentColumn; private boolean toggleNameDisplay; @@ -532,14 +474,6 @@ else if(userInputList.length == 2){ private boolean toggleHeadlessAttributes; private String[] toggleChoices; - public void setCurrentNode(DecoratedNode node) - { - currentNodeSynthAttrs = null; - currentNodeInhAttrs = null; - currentNodeLocalAttrs = null; - currentNode = node; - } - //Replaces currentNode with its parent public Integer up() { @@ -553,7 +487,7 @@ public Integer up() //NodeStack contains past nodes not current ones nodeStack.push(currentNode); - //Updates curretnNode + //Updates currentNode currentNode = (DecoratedNode) currentNode.getParent(); //Update the various other stacks @@ -593,7 +527,7 @@ public void updateDisplay() currentLineNumber++; } - writeTojson(file, productionLineNum, productionLineNum); + writeToJson(file, productionLineNum, productionLineNum); // add a client server here, when it called send 1 sendMessageToExtension("1"); }catch (IOException e) { @@ -701,7 +635,7 @@ public Integer undo(){ //updates the currentNode to its forward child public Integer forwards() { - if (currentNode.getNode().hasForward()){ + if (isContractum(currentNode)){ nodeStack.push(currentNode); currentNode = currentNode.forward(); @@ -787,26 +721,19 @@ public void printName(DecoratedNode node) System.out.println(parentProduction); } - //calls - public Integer equationHelper(String attributeName) + //Finds the corresponding equation updates the display + public Integer equationHelper(String attributeInput) { - //Find the index of the given childName + //Gets the attribute name from a user input List attributeList = allAttributesList(currentNode); String[] attributeArray = attributeList.toArray(new String[attributeList.size()]); - int attributeNum = Arrays.binarySearch(attributeArray, attributeName); - - //If the attribute was not found we check if the input was a prefix - if(attributeNum < 0){ - attributeNum = prefixSearch(attributeArray, attributeName); - } - - //If the attribute was still not found we check if the input was a suffix - if(attributeNum < 0){ - attributeNum = suffixSearch(attributeArray, ":" + attributeName); + String attributeName = inputArrayFinder(attributeArray, attributeInput); + if(attributeName.equals("")){ + return -1; } //Try to display the attribute at the corresponding index - displayEquation(currentNode, attributeArray[attributeNum]) ; + displayEquation(currentNode, attributeName) ; attributeDataHTML(currentNode, ""); return 1; } @@ -821,7 +748,7 @@ public static Integer suffixSearch(String[] array, String suffix) { return -1; } - + //Helper for communicating with VS Code extension server private void sendMessageToExtension(String message) { String host = "127.0.0.1"; // Host of the VS Code extension server int port = 19387; @@ -838,30 +765,28 @@ private void sendMessageToExtension(String message) { } } - // makes html of the production containing the inputed attribute name - // the specific attribute is highlighted - public void displayEquation(DecoratedNode node, String attriburteName) + // Popup the file and line where the attribute is defined + public void displayEquation(DecoratedNode node, String attributeName) { Map lazyMap = allAttributesLazyMap(node); - if (lazyMap.containsKey(attriburteName)) { - Lazy attributeLazy = lazyMap.get(attriburteName); + if (lazyMap.containsKey(attributeName)) { + Lazy attributeLazy = lazyMap.get(attributeName); NLocation loc = attributeLazy.getSourceLocation(); if(loc != null) { + //Get the data from the NLocation String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); int endline = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); - equationHTML(file, line, endline); - writeTojson(file, line, endline); - // add a client server here, when it called send 1 + //write this data to a Json and tell the server to refresh + writeToJson(file, line, endline); sendMessageToExtension("1"); } } } - // makes html of the production containing the inputed attribute name - // the specific attribute is highlighted - public void writeTojson(String filename, int lineNumber, int endline) + // Helper for displayEquation + public void writeToJson(String filename, int lineNumber, int endline) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(".debugger_communicator.json"))) { String currentDirectory = System.getProperty("user.dir"); @@ -873,106 +798,6 @@ public void writeTojson(String filename, int lineNumber, int endline) } } - - - //Helper for displayEquation - public static void equationHTML(String filename, int lineNumber, int endline) { - //System.out.println("in print content"); - try (BufferedReader br1 = new BufferedReader(new FileReader(filename)); - BufferedWriter writer = new BufferedWriter(new FileWriter("current_production.html"))) { - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); - String line; - int currentLineNumber = 1; - int productionLineNum = 0; - while ((line = br1.readLine()) != null) { - //HACK:Relies on the the fact that "::=" is only and always used in production declarations - if (line.contains("::=")) { - productionLineNum = currentLineNumber; - } - if (currentLineNumber >= lineNumber ) { - break; - } - currentLineNumber++; - } - currentLineNumber = 1; - br1.close(); - BufferedReader br2 = new BufferedReader(new FileReader(filename)); - writer.write("
\n");
-            while ((line = br2.readLine()) != null) {
-                if(currentLineNumber == lineNumber){
-                    writer.write("");
-                }
-                if (currentLineNumber >= productionLineNum) {
-                    writer.write(line);
-                    if(currentLineNumber == endline){
-                        writer.write("");
-                        writer.newLine();
-                    }
-                    writer.newLine();
-                }
-                //HACK:Relies on the the fact that the line "}" is only and always used in production ends
-                if (currentLineNumber >= productionLineNum && line.trim().equals("}")) {
-                    break; 
-                }
-                currentLineNumber++;
-            }
-            writer.write("
\n"); - writer.write("\n"); - writer.write("\n"); - }catch (IOException e) { - e.printStackTrace(); - } - } - - //Old function not sure if we still want it - public int listSynth(DecoratedNode node) - { - RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); - RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - Set synAttrSet = nonterminalton.getAllSynth(); - int numAttr = 0; - - for (String synAttr : synAttrSet) - { - System.out.println("Attribute = " + synAttr); - numAttr++; - } - return numAttr; - } - - //Old function not sure if we still want it - public int listInher(DecoratedNode node) - { - RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); - RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - Set inhAttrSet = nonterminalton.getAllInh(); - int numAttr = 0; - - for (String inhAttr : inhAttrSet) - { - System.out.println("Attribute = " + inhAttr); - numAttr++; - } - return numAttr; - } - - //Prints all attributes using allAttributesList - public void printAttributes(DecoratedNode node, boolean toggleHeadlessAttributes){ - List attributeList = allAttributesList(node); - if(toggleHeadlessAttributes){ - attributeList = removeHeaders(allAttributesList(node)); - } - int i = 0; - - for (String attribute : attributeList) - { - System.out.println(Integer.toString(i) + ": " + attribute); - i++; - } - } - //Should this be in Util? public List removeHeaders(List stringList){ List headlessList = new ArrayList<>(); @@ -987,15 +812,16 @@ public List removeHeaders(List stringList){ return headlessList; } - public void printAttrFromName(DecoratedNode node, String printAttribute){ - Map attributeMap = allAttributesThunkMap(node); - @SuppressWarnings("unchecked") - Object finalThunk = attributeMap.get(printAttribute); - System.out.println(Util.genericShow(Util.demand(finalThunk))); - } + //Highlights the data of the specified attribute + public Integer attributeDataHTML(DecoratedNode node, String attributeName){ + //Gets the attribute name from a user input + List attributeList = allAttributesList(currentNode); + String[] attributeArray = attributeList.toArray(new String[attributeList.size()]); + String highlightAttribute = inputArrayFinder(attributeArray, attributeName); + if(attributeName.equals("")){ + return -1; + } - //Higlights the data of the specified attribute - public void attributeDataHTML(DecoratedNode node, String printAttribute){ Map attributeMap = allAttributesThunkMap(node); try (BufferedWriter writer = new BufferedWriter(new FileWriter("attribute_values.html"))) { writer.write("\n"); @@ -1005,7 +831,7 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){ for (Map.Entry entry : attributeMap.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); - if (key.equals(printAttribute)){ + if (key.equals(highlightAttribute)){ writer.write(""); writer.write(key + ": " + Util.genericShow(Util.demand(value))); writer.write(""); @@ -1025,19 +851,52 @@ public void attributeDataHTML(DecoratedNode node, String printAttribute){ }catch (IOException e) { System.err.println("Error writing to file: " + e.getMessage()); } + return 0; } - //HACK: this entire prossess is based on string meddling + //Given a user input search an array for something that looks close enough + //should be in util? + public String inputArrayFinder(String[] array, String input){ + int index = Arrays.binarySearch(array, input); + String returnString = ""; + + //If the string was not found we check if the input was a prefix + if(index < 0){ + index = prefixSearch(array, input); + } + + //If the string was still not found we check if the input was a suffix + if(index < 0){ + index = suffixSearch(array, ":" + input); + } + + //The string is not in the array + if(index < 0){ + return ""; + } + + return array[index]; + } + + //HACK: this entire process is based on string meddling //A better way to do this would be to have each attribute know what other attributes generate it //This way we would not need to rely on specific string formatting - //Should probaly not be pushed to - public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner inp) + public int algorithmicDebug(DecoratedNode node, String attributeInput, Scanner inp) { - //Gets the equation we are on + //Gets the attribute name from a user input + List attributeList = allAttributesList(currentNode); + String[] attributeArray = attributeList.toArray(new String[attributeList.size()]); + String attributeName = inputArrayFinder(attributeArray, attributeInput); + if(attributeName.equals("")){ + System.out.print("invalid input"); + return -1; + } + + //Print out the equation for the given attribute String equationString = ""; Map lazyMap = allAttributesLazyMap(node); - if (lazyMap.containsKey(attriburteName)) { - Lazy attributeLazy = lazyMap.get(attriburteName); + if (lazyMap.containsKey(attributeName)) { + Lazy attributeLazy = lazyMap.get(attributeName); NLocation loc = attributeLazy.getSourceLocation(); if(loc != null) { String filePath = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); @@ -1045,7 +904,7 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner int endLine = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); System.out.println("Equation:"); - try { + try { equationString = getLines(filePath, startLine, endLine); System.out.println(); } catch (IOException e) { @@ -1057,27 +916,23 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner //Next we want to get the LHS of the equation System.out.println("Data:"); Map attributeMap = allAttributesThunkMap(node); - String partentProduction = node.undecorate().getProdleton().getTypeUnparse(); int index1 = partentProduction.indexOf("::"); - int index2 = attriburteName.indexOf(":"); - String parentNameInEquation = partentProduction.substring(0, index1) + "." + attriburteName.substring(index2+1); - System.out.println(parentNameInEquation + ": " + Util.genericShow(Util.demand(attributeMap.get(attriburteName)))); + int index2 = attributeName.indexOf(":"); + String parentNameInEquation = partentProduction.substring(0, index1) + "." + attributeName.substring(index2+1); + System.out.println(parentNameInEquation + ": " + Util.genericShow(Util.demand(attributeMap.get(attributeName)))); //This generates a list of all children of the production and splits them - //into the attribute front name (ex. ds) and bakc name (ex. DeclList) + //into the attribute front name (ex. l) and back name (ex. value) String currentProduction = node.undecorate().getProdleton().getTypeUnparse(); String[] listCurrentProduction = currentProduction.split("\\s+"); String[] childFullNames = Arrays.copyOfRange(listCurrentProduction, 2, listCurrentProduction.length); String[] childFrontNames = new String[childFullNames.length]; String[] childBackNames = new String[childFullNames.length]; for (int i = 0; i < childFullNames.length; i++) { - // System.out.println("childFullNames[i]: " + childFullNames[i]); index1 = childFullNames[i].indexOf("::"); - // System.out.println(childFullNames[i].substring(0, index1)+ "."); childFrontNames[i] = childFullNames[i].substring(0, index1) + "."; index2 = childFullNames[i].indexOf(":"); - // System.out.println(childFullNames[i].substring(index2+2)); childBackNames[i] = childFullNames[i].substring(index2+2); } @@ -1094,29 +949,51 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner } } } - // for (String attribute : dependentAttributes) { - // System.out.println(attribute); - // } + + //For each of these relevant component we want to print to data at that component + for (String attribute : dependentAttributes) { + String[] attributeComponents = attribute.split("\\."); + String childName = ""; + for (int i = 0; i < childFullNames.length; i++){ + if (childFullNames[i].startsWith(attributeComponents[0] + "::")) { + DecoratedNode childNode = currentNode.childDecorated(i); + Map childMap = allAttributesThunkMap(childNode); + for (Map.Entry entry : childMap.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (key.endsWith(":" + attributeComponents[1])){ + System.out.println(attribute + ": " + Util.genericShow(Util.demand(value))); + } + } + } + } + } //Next the user will pick which of these variables they want to further investigate //We split this into 2 parts index 0 is the Front name (ex. ds) //the second is the attribute (ex. pp) String[] dependentAttributesArray = dependentAttributes.toArray(new String[0]); int inputInt = -1; + String chosenAttributeInput = ""; if(dependentAttributesArray.length > 0){ System.out.println(); System.out.println("Pick the next node to investigate"); - inputInt = chooseFormList(inp, dependentAttributesArray); + displayArray(dependentAttributesArray); + System.out.print(">DEBUGGER-PROMPT$"); + chosenAttributeInput = inp.nextLine(); }else{ return 0; } - if(inputInt == -1) + + String chosenAttribute = inputArrayFinder(dependentAttributesArray, chosenAttributeInput); + if(chosenAttribute.equals("")){ + System.out.print("invalid input"); return -1; - String chosenAttribute = dependentAttributesArray[inputInt]; + } String[] chosenAttributeComponents = chosenAttribute.split("\\."); - //Baed on what the user chose we can solve for the child they want to travle to - //Becaues it will have the same Front name as the variable (ex. ds.pp -> ds::DeclList) + //Based on what the user chose we can solve for the child they want to travel to + //Because it will have the same Front name as the variable (ex. ds.pp -> ds::DeclList) String nextChildName = ""; for (String fullName : childFullNames){ if (fullName.startsWith(chosenAttributeComponents[0] + "::")) { @@ -1126,21 +1003,14 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner System.out.println(nextChildName); //Now that we know the child we can travel their - // Integer nextChildNum = Arrays.binarySearch(childFullNames, nextChildName); - //Wierd bug, we can't go up after going down in alogdebugg + //Integer nextChildNum = Arrays.binarySearch(childFullNames, nextChildName); if (down(nextChildName) == -1){ System.out.println("invalid child"); } - // System.out.println(); - // System.out.println("currentNode:"); - // System.out.println(); - //We also know what attribute they want to investigate //it should have the same end as the chosen attribute - List attributeList = allAttributesList(currentNode); String nextAttributeName = ""; - //list should be list of attributes for (String element : attributeList) { String[] parts = element.split(":"); if (parts.length == 2 && chosenAttributeComponents[1].startsWith(parts[1])) { @@ -1151,12 +1021,12 @@ public int algorithmicDebugg(DecoratedNode node, String attriburteName, Scanner //recursive time if(nextChildName != ""){ - algorithmicDebugg(currentNode, nextAttributeName, inp); + algorithmicDebug(currentNode, nextAttributeName, inp); } return -1; } - //helper foralgorithmicDebugg + //helper for algorithmicDebugg public static String getLines(String filePath, int startLine, int endLine) throws IOException { String returnString = ""; try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { @@ -1198,18 +1068,22 @@ public static List getLocalAttrs(DecoratedNode node) //TODO: Add access to higher order attriburte //Translation attribute or Decorated, locals only locals should all be decorated - public DecoratedNode into(DecoratedNode node, String attriburteName){ - Map attributeMap = allAttributesObjectMap(node); - if (attributeMap.containsKey(attriburteName)) { - System.out.println("In into function"); - Object attributeObject = attributeMap.get(attriburteName); - return (DecoratedNode) attributeObject; //Does not work class translator.Pprogram cannot be cast to class common.DecoratedNode - } - return null; - } + // public Integer into(DecoratedNode node, String attributeInput){ + // String attributeName = inputArrayFinder(attributeArray, attributeInput); + // if(attributeName.equals("")){ + // return -1; + // } + + // Map attributeMap = allAttributesThunkMap(node); // will have to eval the thunk + // if (attributeMap.containsKey(attributeName)) { + // Object attributeObject = attributeMap.get(attributeName); + // currentNode = (DecoratedNode) attributeObject.demand(); //Does not work class translator.Pprogram cannot be cast to class common.DecoratedNode + // } + // return 0; + // } - //Helper for printing Attributes + //Creates a list of all Attributes public static List allAttributesList(DecoratedNode node) { RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); @@ -1223,58 +1097,35 @@ public static List allAttributesList(DecoratedNode node) return attributeList; } - //Deprecated: please use allAttributesThunkMap - public static Map allAttributesObjectMap(DecoratedNode node) - { - List attributeList = allAttributesList(node); - RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); - RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); - Map attributeMap = new HashMap<>(); - - for(String attribute : attributeList) - { - if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ - //System.out.println("Synthisized!!! \"" + attribute + "\""); - Integer index = nonterminalton.getSynOccursIndex(attribute); - Lazy synthAttribute = node.getNode().getSynthesized(index); //breaks for forwarded nodes - Object o = synthAttribute.eval(node); //.sythisized() found in Decorated node add thunks (.sythisizedlazy() then eval ) - attributeMap.put(attribute, o); - }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ - //System.out.println("Inherited!!!"); - Integer index = nonterminalton.getInhOccursIndex(attribute); - Object o = node.evalInhSomehowButPublic(index); - attributeMap.put(attribute, o); - }else{ //Should be local - //System.out.println("local!!!"); - List listLocals = getLocalAttrs(node); - Integer index = listLocals.indexOf(attribute); - Lazy localAttribute = node.getNode().getLocal(index); - Object o = localAttribute.eval(node); - attributeMap.put(attribute, o); - } - } - return attributeMap; - } - //Creates a map of attribute names to there thunks that can be demanded to get the values of the attributes public static Map allAttributesThunkMap(DecoratedNode node) { List attributeList = allAttributesList(node); + + //Thunks are found in a nodes Nonterminalton RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); Map attributeMap = new HashMap<>(); + //Find the corresponding thunk for each attribute for(String attribute : attributeList) { + //Synthesized attributes if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ Integer index = nonterminalton.getSynOccursIndex(attribute); Object o = node.contextSynthesizedLazy(index); attributeMap.put(attribute, o); - }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + } + + //Inherited attributes + else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ Integer index = nonterminalton.getInhOccursIndex(attribute); Object o = node.contextInheritedLazy(index); attributeMap.put(attribute, o); - }else{ //Should be local + } + + //Local attributes + else{ List listLocals = getLocalAttrs(node); Integer index = listLocals.indexOf(attribute); Object o = node.localLazy(index); @@ -1288,21 +1139,31 @@ public static Map allAttributesThunkMap(DecoratedNode node) public static Map allAttributesLazyMap(DecoratedNode node) { List attributeList = allAttributesList(node); + + //Lazy are found in a nodes Nonterminalton RTTIManager.Prodleton prodleton = node.getNode().getProdleton(); RTTIManager.Nonterminalton nonterminalton = prodleton.getNonterminalton(); Map attributeMap = new HashMap<>(); + //Find the corresponding Lazy for each attribute for(String attribute : attributeList) { + //Synthesized attributes if(nonterminalton.getSynOccursIndices().keySet().contains(attribute)){ Integer index = nonterminalton.getSynOccursIndex(attribute); Lazy synthAttribute = node.getNode().getSynthesized(index); //breaks for forwarded nodes attributeMap.put(attribute, synthAttribute); - }else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ + } + + //Inherited attributes + else if(nonterminalton.getInhOccursIndices().keySet().contains(attribute)){ Integer index = nonterminalton.getInhOccursIndex(attribute); Lazy inheritedAttribute = node.getInheritedAttribute(index); attributeMap.put(attribute, inheritedAttribute); - }else{ //Should be local + } + + //Local attributes + else{ List listLocals = getLocalAttrs(node); Integer index = listLocals.indexOf(attribute); Lazy localAttribute = node.getNode().getLocal(index); @@ -1312,88 +1173,17 @@ public static Map allAttributesLazyMap(DecoratedNode node) return attributeMap; } + //Prints a array to the terminal //Should be in util? public static void displayArray(String[] array){ for (String element : array){ System.out.println(element); } } - - //For letting users type tab to autofill with an element of the input list - public static String autofill(String[] options, Scanner inp){ - while (true) { - String input = inp.nextLine(); - if (input.isEmpty()) { - continue; - } - if (input.endsWith("\t")) { // Check if Tab key is pressed - String prefix = input.substring(0, input.lastIndexOf("\t")); - return autoComplete(prefix, options); - } else { - // Handle regular input - return input; - } - } - } - - //helper for autofill - private static String autoComplete(String prefix, String[] options) { - for (String option : options) { - if (option.startsWith(prefix)) { - return option; - } - } - return ""; - } - - //Should be in util? - public static Integer chooseFormList(Scanner inp, String[] list){ - for (int i = 0; i < list.length; i++){ - System.out.println(Integer.toString(i) + ": " + list[i]); - } - - boolean continueLoop = true; - int returnInt = -1; - String stopper = ""; - while(continueLoop){ - System.out.print(">DEBUGGER-PROMPT$"); - if (inp.hasNextInt()) { - returnInt = inp.nextInt(); - inp.nextLine(); - continueLoop = false; - }else{ - stopper = inp.nextLine(); - if (stopper.equals("q")){ - continueLoop = false; - }else{ - System.out.println("Please choose an integer or q to exit"); - } - } - } - return returnInt; - - } + //Returns true if the given node has a forward child public boolean isContractum(DecoratedNode node) { return node.getNode().hasForward(); } - - public static class StringObjectPair { - private String stringValue; - private Object objectValue; - - public StringObjectPair(String stringValue, Object objectValue) { - this.stringValue = stringValue; - this.objectValue = objectValue; - } - - public String getString() { - return stringValue; - } - - public Object getObject() { - return objectValue; - } - } -} +} \ No newline at end of file From f5bab766685a90682d04690d0fa65608ef83ceb1 Mon Sep 17 00:00:00 2001 From: meng0181 Date: Thu, 25 Apr 2024 16:46:52 -0500 Subject: [PATCH 57/64] update vscode extension support for agnosis debugger --- support/vs-code/agnosis/.eslintrc.json | 30 + support/vs-code/agnosis/.vscode-test.mjs | 5 + .../vs-code/agnosis/.vscode/extensions.json | 8 + support/vs-code/agnosis/.vscode/launch.json | 22 + support/vs-code/agnosis/.vscode/settings.json | 11 + support/vs-code/agnosis/.vscode/tasks.json | 20 + support/vs-code/agnosis/.vscodeignore | 11 + support/vs-code/agnosis/CHANGELOG.md | 9 + support/vs-code/agnosis/README.md | 71 + support/vs-code/agnosis/package-lock.json | 3030 +++++++++++++++++ support/vs-code/agnosis/package.json | 61 + support/vs-code/agnosis/src/extension.ts | 189 + .../agnosis/src/test/extension.test.ts | 15 + support/vs-code/agnosis/tsconfig.json | 17 + .../agnosis/vsc-extension-quickstart.md | 43 + 15 files changed, 3542 insertions(+) create mode 100644 support/vs-code/agnosis/.eslintrc.json create mode 100644 support/vs-code/agnosis/.vscode-test.mjs create mode 100644 support/vs-code/agnosis/.vscode/extensions.json create mode 100644 support/vs-code/agnosis/.vscode/launch.json create mode 100644 support/vs-code/agnosis/.vscode/settings.json create mode 100644 support/vs-code/agnosis/.vscode/tasks.json create mode 100644 support/vs-code/agnosis/.vscodeignore create mode 100644 support/vs-code/agnosis/CHANGELOG.md create mode 100644 support/vs-code/agnosis/README.md create mode 100644 support/vs-code/agnosis/package-lock.json create mode 100644 support/vs-code/agnosis/package.json create mode 100644 support/vs-code/agnosis/src/extension.ts create mode 100644 support/vs-code/agnosis/src/test/extension.test.ts create mode 100644 support/vs-code/agnosis/tsconfig.json create mode 100644 support/vs-code/agnosis/vsc-extension-quickstart.md diff --git a/support/vs-code/agnosis/.eslintrc.json b/support/vs-code/agnosis/.eslintrc.json new file mode 100644 index 000000000..86c86f379 --- /dev/null +++ b/support/vs-code/agnosis/.eslintrc.json @@ -0,0 +1,30 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/naming-convention": [ + "warn", + { + "selector": "import", + "format": [ "camelCase", "PascalCase" ] + } + ], + "@typescript-eslint/semi": "warn", + "curly": "warn", + "eqeqeq": "warn", + "no-throw-literal": "warn", + "semi": "off" + }, + "ignorePatterns": [ + "out", + "dist", + "**/*.d.ts" + ] +} \ No newline at end of file diff --git a/support/vs-code/agnosis/.vscode-test.mjs b/support/vs-code/agnosis/.vscode-test.mjs new file mode 100644 index 000000000..b62ba25f0 --- /dev/null +++ b/support/vs-code/agnosis/.vscode-test.mjs @@ -0,0 +1,5 @@ +import { defineConfig } from '@vscode/test-cli'; + +export default defineConfig({ + files: 'out/test/**/*.test.js', +}); diff --git a/support/vs-code/agnosis/.vscode/extensions.json b/support/vs-code/agnosis/.vscode/extensions.json new file mode 100644 index 000000000..db70f8889 --- /dev/null +++ b/support/vs-code/agnosis/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "dbaeumer.vscode-eslint", + "ms-vscode.extension-test-runner" + ] +} diff --git a/support/vs-code/agnosis/.vscode/launch.json b/support/vs-code/agnosis/.vscode/launch.json new file mode 100644 index 000000000..2e70650cd --- /dev/null +++ b/support/vs-code/agnosis/.vscode/launch.json @@ -0,0 +1,22 @@ +// A launch configuration that compiles the extension and then opens it inside a new window +// Use IntelliSense to learn about possible attributes. +// Hover to view descriptions of existing attributes. +// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Run Extension", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}", + "--folder-uri=file:///home/linglong/College/example_expr_translator/translator" + ], + "outFiles": [ + "${workspaceFolder}/out/**/*.js" + ], + "preLaunchTask": "${defaultBuildTask}" + } + ] +} diff --git a/support/vs-code/agnosis/.vscode/settings.json b/support/vs-code/agnosis/.vscode/settings.json new file mode 100644 index 000000000..30bf8c2d3 --- /dev/null +++ b/support/vs-code/agnosis/.vscode/settings.json @@ -0,0 +1,11 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "files.exclude": { + "out": false // set this to true to hide the "out" folder with the compiled JS files + }, + "search.exclude": { + "out": true // set this to false to include "out" folder in search results + }, + // Turn off tsc task auto detection since we have the necessary tasks as npm scripts + "typescript.tsc.autoDetect": "off" +} \ No newline at end of file diff --git a/support/vs-code/agnosis/.vscode/tasks.json b/support/vs-code/agnosis/.vscode/tasks.json new file mode 100644 index 000000000..3b17e53b6 --- /dev/null +++ b/support/vs-code/agnosis/.vscode/tasks.json @@ -0,0 +1,20 @@ +// See https://go.microsoft.com/fwlink/?LinkId=733558 +// for the documentation about the tasks.json format +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "watch", + "problemMatcher": "$tsc-watch", + "isBackground": true, + "presentation": { + "reveal": "never" + }, + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/support/vs-code/agnosis/.vscodeignore b/support/vs-code/agnosis/.vscodeignore new file mode 100644 index 000000000..72aa0fe2e --- /dev/null +++ b/support/vs-code/agnosis/.vscodeignore @@ -0,0 +1,11 @@ +.vscode/** +.vscode-test/** +src/** +.gitignore +.yarnrc +vsc-extension-quickstart.md +**/tsconfig.json +**/.eslintrc.json +**/*.map +**/*.ts +**/.vscode-test.* diff --git a/support/vs-code/agnosis/CHANGELOG.md b/support/vs-code/agnosis/CHANGELOG.md new file mode 100644 index 000000000..05d1b64fc --- /dev/null +++ b/support/vs-code/agnosis/CHANGELOG.md @@ -0,0 +1,9 @@ +# Change Log + +All notable changes to the "agnosis" extension will be documented in this file. + +Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. + +## [Unreleased] + +- Initial release \ No newline at end of file diff --git a/support/vs-code/agnosis/README.md b/support/vs-code/agnosis/README.md new file mode 100644 index 000000000..d0b5417bf --- /dev/null +++ b/support/vs-code/agnosis/README.md @@ -0,0 +1,71 @@ +# agnosis README + +This is the README for your extension "agnosis". After writing up a brief description, we recommend including the following sections. + +## Features + +Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. + +For example if there is an image subfolder under your extension project workspace: + +\!\[feature X\]\(images/feature-x.png\) + +> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. + +## Requirements + +If you have any requirements or dependencies, add a section describing those and how to install and configure them. + +## Extension Settings + +Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. + +For example: + +This extension contributes the following settings: + +* `myExtension.enable`: Enable/disable this extension. +* `myExtension.thing`: Set to `blah` to do something. + +## Known Issues + +Calling out known issues can help limit users opening duplicate issues against your extension. + +## Release Notes + +Users appreciate release notes as you update your extension. + +### 1.0.0 + +Initial release of ... + +### 1.0.1 + +Fixed issue #. + +### 1.1.0 + +Added features X, Y, and Z. + +--- + +## Following extension guidelines + +Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension. + +* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines) + +## Working with Markdown + +You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: + +* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux). +* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux). +* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets. + +## For more information + +* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) +* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) + +**Enjoy!** diff --git a/support/vs-code/agnosis/package-lock.json b/support/vs-code/agnosis/package-lock.json new file mode 100644 index 000000000..0f3ea9373 --- /dev/null +++ b/support/vs-code/agnosis/package-lock.json @@ -0,0 +1,3030 @@ +{ + "name": "agnosis", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "agnosis", + "version": "0.0.1", + "devDependencies": { + "@types/mocha": "^10.0.6", + "@types/node": "18.x", + "@types/vscode": "^1.88.0", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "@vscode/test-cli": "^0.0.6", + "@vscode/test-electron": "^2.3.9", + "eslint": "^8.56.0", + "typescript": "^5.3.3" + }, + "engines": { + "vscode": "^1.88.0" + } + }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/js": { + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "dev": true + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@tootallnate/once": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", + "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, + "node_modules/@types/mocha": { + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.6.tgz", + "integrity": "sha512-dJvrYWxP/UcXm36Qn36fxhUKu8A/xMRXVT2cliFF1Z7UA9liG5Psj3ezNSZw+5puH2czDXRLcXQxf8JbJt0ejg==", + "dev": true + }, + "node_modules/@types/node": { + "version": "18.19.31", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.31.tgz", + "integrity": "sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/semver": { + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", + "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", + "dev": true + }, + "node_modules/@types/vscode": { + "version": "1.88.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.88.0.tgz", + "integrity": "sha512-rWY+Bs6j/f1lvr8jqZTyp5arRMfovdxolcqGi+//+cPDOh8SBvzXH90e7BiSXct5HJ9HGW6jATchbRTpTJpEkw==", + "dev": true + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.7.1.tgz", + "integrity": "sha512-KwfdWXJBOviaBVhxO3p5TJiLpNuh2iyXyjmWN0f1nU87pwyvfS0EmjC6ukQVYVFJd/K1+0NWGPDXiyEyQorn0Q==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/type-utils": "7.7.1", + "@typescript-eslint/utils": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^7.0.0", + "eslint": "^8.56.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.7.1.tgz", + "integrity": "sha512-vmPzBOOtz48F6JAGVS/kZYk4EkXao6iGrD838sp1w3NQQC0W8ry/q641KU4PrG7AKNAf56NOcR8GOpH8l9FPCw==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/typescript-estree": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.56.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.7.1.tgz", + "integrity": "sha512-PytBif2SF+9SpEUKynYn5g1RHFddJUcyynGpztX3l/ik7KmZEv19WCMhUBkHXPU9es/VWGD3/zg3wg90+Dh2rA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1" + }, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.7.1.tgz", + "integrity": "sha512-ZksJLW3WF7o75zaBPScdW1Gbkwhd/lyeXGf1kQCxJaOeITscoSl0MjynVvCzuV5boUz/3fOI06Lz8La55mu29Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "7.7.1", + "@typescript-eslint/utils": "7.7.1", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.56.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.7.1.tgz", + "integrity": "sha512-AmPmnGW1ZLTpWa+/2omPrPfR7BcbUU4oha5VIbSbS1a1Tv966bklvLNXxp3mrbc+P2j4MNOTfDffNsk4o0c6/w==", + "dev": true, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.7.1.tgz", + "integrity": "sha512-CXe0JHCXru8Fa36dteXqmH2YxngKJjkQLjxzoj6LYwzZ7qZvgsLSc+eqItCrqIop8Vl2UKoAi0StVWu97FQZIQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/visitor-keys": "7.7.1", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.7.1.tgz", + "integrity": "sha512-QUvBxPEaBXf41ZBbaidKICgVL8Hin0p6prQDu6bbetWo39BKbWJxRsErOzMNT1rXvTll+J7ChrbmMCXM9rsvOQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.15", + "@types/semver": "^7.5.8", + "@typescript-eslint/scope-manager": "7.7.1", + "@typescript-eslint/types": "7.7.1", + "@typescript-eslint/typescript-estree": "7.7.1", + "semver": "^7.6.0" + }, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.56.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.7.1.tgz", + "integrity": "sha512-gBL3Eq25uADw1LQ9kVpf3hRM+DWzs0uZknHYK3hq4jcTPqVCClHGDnB6UUUV2SFeBeA4KWHWbbLqmbGcZ4FYbw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "7.7.1", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, + "node_modules/@vscode/test-cli": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/@vscode/test-cli/-/test-cli-0.0.6.tgz", + "integrity": "sha512-4i61OUv5PQr3GxhHOuUgHdgBDfIO/kXTPCsEyFiMaY4SOqQTgkTmyZLagHehjOgCfsXdcrJa3zgQ7zoc+Dh6hQ==", + "dev": true, + "dependencies": { + "@types/mocha": "^10.0.2", + "c8": "^9.1.0", + "chokidar": "^3.5.3", + "enhanced-resolve": "^5.15.0", + "glob": "^10.3.10", + "minimatch": "^9.0.3", + "mocha": "^10.2.0", + "supports-color": "^9.4.0", + "yargs": "^17.7.2" + }, + "bin": { + "vscode-test": "out/bin.mjs" + } + }, + "node_modules/@vscode/test-electron": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.9.tgz", + "integrity": "sha512-z3eiChaCQXMqBnk2aHHSEkobmC2VRalFQN0ApOAtydL172zXGxTwGrRtviT5HnUB+Q+G3vtEYFtuQkYqBzYgMA==", + "dev": true, + "dependencies": { + "http-proxy-agent": "^4.0.1", + "https-proxy-agent": "^5.0.0", + "jszip": "^3.10.1", + "semver": "^7.5.2" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "node_modules/c8": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/c8/-/c8-9.1.0.tgz", + "integrity": "sha512-mBWcT5iqNir1zIkzSPyI3NCR9EZCVI3WUD+AVO17MVWTSFNyUueXE82qTeampNtTr+ilN/5Ua3j24LgbCKjDVg==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@istanbuljs/schema": "^0.1.3", + "find-up": "^5.0.0", + "foreground-child": "^3.1.1", + "istanbul-lib-coverage": "^3.2.0", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.1.6", + "test-exclude": "^6.0.0", + "v8-to-istanbul": "^9.0.0", + "yargs": "^17.7.2", + "yargs-parser": "^21.1.1" + }, + "bin": { + "c8": "bin/c8.js" + }, + "engines": { + "node": ">=14.14.0" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/cliui/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "node_modules/enhanced-resolve": { + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.16.0.tgz", + "integrity": "sha512-O+QWCviPNSSLAD9Ucn8Awv+poAkqn3T1XY5/N7kR7rQO9yfSGWkYZDwpJ+iKF7B8rxaQKWngSqACpgzeapSyoA==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/escalade": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", + "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.0", + "@humanwhocodes/config-array": "^0.11.14", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "bin": { + "flat": "cli.js" + } + }, + "node_modules/flat-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "dev": true + }, + "node_modules/foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/glob": { + "version": "10.3.12", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", + "integrity": "sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.6", + "minimatch": "^9.0.1", + "minipass": "^7.0.4", + "path-scurry": "^1.10.2" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/http-proxy-agent": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", + "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", + "dev": true, + "dependencies": { + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dev": true, + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "dev": true + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jackspeak": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", + "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "dev": true, + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "node_modules/jszip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "dev": true, + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "dev": true, + "dependencies": { + "immediate": "~3.0.5" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lru-cache": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.1.tgz", + "integrity": "sha512-tS24spDe/zXhWbNPErCHs/AGOzbKGHT+ybSBqmdLm8WZ1xXLWvH8Qn71QPAlqVhd0qUTWjy+Kl9JmISgDdEjsA==", + "dev": true, + "engines": { + "node": "14 || >=16.14" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/minimatch": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", + "dev": true, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/mocha": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.4.0.tgz", + "integrity": "sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==", + "dev": true, + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "8.1.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/mocha/node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/mocha/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/mocha/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/mocha/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/mocha/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mocha/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/mocha/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/mocha/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optionator": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "dev": true, + "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "dev": true + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.2.tgz", + "integrity": "sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==", + "dev": true, + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/rimraf/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/rimraf/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/rimraf/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "dev": true + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/string-width/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/string-width/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.4.0.tgz", + "integrity": "sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-api-utils": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", + "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", + "dev": true, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/v8-to-istanbul": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz", + "integrity": "sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "dev": true + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/support/vs-code/agnosis/package.json b/support/vs-code/agnosis/package.json new file mode 100644 index 000000000..9ceb69edd --- /dev/null +++ b/support/vs-code/agnosis/package.json @@ -0,0 +1,61 @@ +{ + "name": "agnosis", + "displayName": "model_1", + "description": "a vscode extension for silver debugger", + "version": "0.0.1", + "engines": { + "vscode": "^1.87.0" + }, + "categories": [ + "Debuggers" + ], + "activationEvents": [], + "main": "./out/extension.js", + "contributes": { + "commands": [ + { + "command": "agnosis.helloWorld", + "title": "Hello World" + }, + { + "command": "agnosis.launchSilver", + "title": "Launch Silver" + }, + { + "command": "agnosis.RunSilver", + "title": "RunSilver" + }, + { + "command": "agnosis.RunCompile", + "title": "RunCompile" + }, + { + "command": "agnosis.HighlightSilver", + "title": "HighlightSilver" + }, + { + "command": "agnosis.showAttributeValuesHtml", + "title": "showAttributeValuesHtml" + } + ] + }, + "scripts": { + "vscode:prepublish": "npm run compile", + "compile": "tsc -p ./", + "watch": "tsc -watch -p ./", + "pretest": "npm run compile && npm run lint", + "lint": "eslint src --ext ts", + "test": "vscode-test" + }, + "devDependencies": { + "@types/vscode": "^1.87.0", + "@types/mocha": "^10.0.6", + "@types/node": "18.x", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "eslint": "^8.56.0", + "typescript": "^5.3.3", + "@vscode/test-cli": "^0.0.6", + "@vscode/test-electron": "^2.3.9" + } +} diff --git a/support/vs-code/agnosis/src/extension.ts b/support/vs-code/agnosis/src/extension.ts new file mode 100644 index 000000000..bcb207642 --- /dev/null +++ b/support/vs-code/agnosis/src/extension.ts @@ -0,0 +1,189 @@ +// The module 'vscode' contains the VS Code extensibility API +// Import the module and reference it with the alias vscode in your code below +import * as vscode from 'vscode'; +import { WorkspaceFolder, DebugConfiguration, ProviderResult, CancellationToken } from 'vscode'; +import * as fs from 'fs'; +import * as path from 'path'; +import * as net from 'net'; + +let server: net.Server; + +// This method is called when your extension is activated +// Your extension is activated the very first time the command is executed +export function activate(context: vscode.ExtensionContext) { + + // Use the console to output diagnostic information (console.log) and errors (console.error) + // This line of code will only be executed once when your extension is activated + console.log('Congratulations, your extension "agnosis" is now active! And silver is on!'); + const terminal = vscode.window.createTerminal('Silver'); + // pop out the new terminal + terminal.show(); + // listen to port 24352 + + + + + let currentPath = vscode.workspace.workspaceFolders?.[0].uri.path || ''; + let current_path_split = currentPath.split('/'); + + + + // read the .debugger_communicator.json file, into a dictionary, it's under workspace folder + + // The command has been defined in the package.json file + // Now provide the implementation of the command with registerCommand + // The commandId parameter must match the command field in package.json + let disposable = vscode.commands.registerCommand('agnosis.helloWorld', () => { + // The code you place here will be executed every time your command is executed + // Display a message box to the user + vscode.window.showInformationMessage('hheeeeeeeeeelo'); + }); + + let launchSilver_dispoable = vscode.commands.registerCommand('agnosis.launchSilver', () => { + vscode.window.showInformationMessage('Launching Silver...'); + // run the command of silver in terminal + terminal.show(); + vscode.window.showInformationMessage(currentPath); + + }); + let run_compiler = vscode.commands.registerCommand('agnosis.RunCompile', () => { + vscode.window.showInformationMessage('Running Compiler...'); + terminal.sendText(`./silver-compile --force-origins --clean`); + }); + + + let run_traslator = vscode.commands.registerCommand('agnosis.RunSilver', () => { + vscode.window.showInformationMessage('Running Translator...'); + terminal.sendText(`./silver-compile --force-origins --clean`); + // get current open tab file name + let working_file = vscode.window.activeTextEditor?.document.fileName || ''; + let working_file_split = working_file.split('/'); + working_file = working_file_split[working_file_split.length - 1]; + let direct_folder = current_path_split[current_path_split.length - 1]; + + vscode.window.showInformationMessage(working_file); + terminal.sendText(`java -jar ${direct_folder}.jar ${working_file}`); + }); + + + let HighlightSilver = vscode.commands.registerCommand('agnosis.HighlightSilver', () => { + let currentPath = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : ''; + let debugger_communicator_path = path.join(currentPath, '.debugger_communicator.json'); + + interface FileHighlightInfo { + file_path: string; + line_begin: number; + line_end: number; + } + + fs.readFile(debugger_communicator_path, 'utf8', (err, data) => { + if (err) { + console.error(err); + return; + } + try { + let filesToHighlightDic: FileHighlightInfo = JSON.parse(data); + // if line_begin and line_end are the same value, make line_end + 1 + if (filesToHighlightDic.line_begin === filesToHighlightDic.line_end) { + filesToHighlightDic.line_end++; + } + + let viewColumn: vscode.ViewColumn; + + // Attempt to find an already opened document + const openedTextEditor = vscode.window.visibleTextEditors.find(editor => editor.document.uri.fsPath === filesToHighlightDic.file_path); + + if (openedTextEditor) { + // If the file is already open, use the existing view column + viewColumn = openedTextEditor.viewColumn ?? vscode.ViewColumn.One; + highlightRange(openedTextEditor, filesToHighlightDic); + } else { + // Determine view column if not already open + viewColumn = vscode.window.visibleTextEditors.length > 1 ? vscode.window.activeTextEditor?.viewColumn ?? vscode.ViewColumn.One : vscode.ViewColumn.Beside; + vscode.workspace.openTextDocument(filesToHighlightDic.file_path).then(doc => { + vscode.window.showTextDocument(doc, viewColumn).then(editor => { + highlightRange(editor, filesToHighlightDic); + }); + }); + } + } catch (parseErr) { + console.error('Error parsing JSON:', parseErr); + } + }); + + function highlightRange(editor: vscode.TextEditor, highlightInfo: FileHighlightInfo) { + editor.selection = new vscode.Selection( + new vscode.Position(highlightInfo.line_begin - 1, 0), + new vscode.Position(highlightInfo.line_end - 1, 0) + ); + editor.revealRange(editor.selection); + } + }); + + + let currentPanel: vscode.WebviewPanel | undefined = undefined; + + const showAttributeValuesHtml = vscode.commands.registerCommand('agnosis.showAttributeValuesHtml', () => { + if (!currentPanel) { + currentPanel = vscode.window.createWebviewPanel( + 'attributeValues', + 'Attribute Values', + vscode.ViewColumn.One, + { enableScripts: true } + ); + + currentPanel.onDidDispose(() => { + currentPanel = undefined; + }); + } + + const updateWebviewContent = () => { + const filePath = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : ''; + const htmlPath = path.join(filePath, 'attribute_values.html'); + const htmlContent = fs.readFileSync(htmlPath, 'utf8'); + if (currentPanel) { + currentPanel.webview.html = htmlContent; + } + }; + + updateWebviewContent(); + + const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.workspace.workspaceFolders![0], 'attribute_values.html')); + watcher.onDidChange(updateWebviewContent); + watcher.onDidDelete(updateWebviewContent); + watcher.onDidCreate(updateWebviewContent); + + }); + + + const server = net.createServer(socket => { + socket.on('data', data => { + let message = data.toString().trim(); + if (message === '1') { + vscode.commands.executeCommand('agnosis.HighlightSilver'); + } + }); + }); + + server.listen(19387, '127.0.0.1', () => { + console.log('Server listening on port 19387'); + }); + + + + context.subscriptions.push(showAttributeValuesHtml); + context.subscriptions.push(disposable); + context.subscriptions.push(launchSilver_dispoable); + context.subscriptions.push(run_traslator); + context.subscriptions.push(run_compiler); + context.subscriptions.push(HighlightSilver); + context.subscriptions.push({ dispose: () => server.close() }); +} + +// This method is called when your extension is deactivated +export function deactivate() { + if (server) { + server.close(); + } + +} diff --git a/support/vs-code/agnosis/src/test/extension.test.ts b/support/vs-code/agnosis/src/test/extension.test.ts new file mode 100644 index 000000000..4ca0ab419 --- /dev/null +++ b/support/vs-code/agnosis/src/test/extension.test.ts @@ -0,0 +1,15 @@ +import * as assert from 'assert'; + +// You can import and use all API from the 'vscode' module +// as well as import your extension to test it +import * as vscode from 'vscode'; +// import * as myExtension from '../../extension'; + +suite('Extension Test Suite', () => { + vscode.window.showInformationMessage('Start all tests.'); + + test('Sample test', () => { + assert.strictEqual(-1, [1, 2, 3].indexOf(5)); + assert.strictEqual(-1, [1, 2, 3].indexOf(0)); + }); +}); diff --git a/support/vs-code/agnosis/tsconfig.json b/support/vs-code/agnosis/tsconfig.json new file mode 100644 index 000000000..6954702e0 --- /dev/null +++ b/support/vs-code/agnosis/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "Node16", + "target": "ES2022", + "outDir": "out", + "lib": [ + "ES2022" + ], + "sourceMap": true, + "rootDir": "src", + "strict": true /* enable all strict type-checking options */ + /* Additional Checks */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + } +} diff --git a/support/vs-code/agnosis/vsc-extension-quickstart.md b/support/vs-code/agnosis/vsc-extension-quickstart.md new file mode 100644 index 000000000..3d8ce067d --- /dev/null +++ b/support/vs-code/agnosis/vsc-extension-quickstart.md @@ -0,0 +1,43 @@ +# Welcome to your VS Code Extension + +## What's in the folder + +* This folder contains all of the files necessary for your extension. +* `package.json` - this is the manifest file in which you declare your extension and command. + * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. +* `src/extension.ts` - this is the main file where you will provide the implementation of your command. + * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. + * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. + +## Get up and running straight away + +* Press `F5` to open a new window with your extension loaded. +* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. +* Set breakpoints in your code inside `src/extension.ts` to debug your extension. +* Find output from your extension in the debug console. + +## Make changes + +* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. +* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. + +## Explore the API + +* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. + +## Run tests + +* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner) +* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered. +* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A` +* See the output of the test result in the Test Results view. +* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder. + * The provided test runner will only consider files matching the name pattern `**.test.ts`. + * You can create folders inside the `test` folder to structure your tests any way you want. + +## Go further + +* [Follow UX guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) to create extensions that seamlessly integrate with VS Code's native interface and patterns. + * Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). + * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace. + * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). From ae1f08e7b48ad1de5a1df17f132c62eb0b4dc0ff Mon Sep 17 00:00:00 2001 From: meng0181 Date: Thu, 25 Apr 2024 16:57:09 -0500 Subject: [PATCH 58/64] clean some temperate files in agnosis vscode extension --- support/vs-code/agnosis/.gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 support/vs-code/agnosis/.gitignore diff --git a/support/vs-code/agnosis/.gitignore b/support/vs-code/agnosis/.gitignore new file mode 100644 index 000000000..0b60dfa12 --- /dev/null +++ b/support/vs-code/agnosis/.gitignore @@ -0,0 +1,5 @@ +out +dist +node_modules +.vscode-test/ +*.vsix From ad6983f9d74aa387e26e9dcfc7650346eac76b4e Mon Sep 17 00:00:00 2001 From: meng0181 Date: Thu, 2 May 2024 15:34:12 -0500 Subject: [PATCH 59/64] update command showSimpleDebugContext --- support/vs-code/agnosis/.vscode/launch.json | 2 +- support/vs-code/agnosis/package.json | 4 + support/vs-code/agnosis/src/extension.ts | 104 +++++++++++++------- 3 files changed, 76 insertions(+), 34 deletions(-) diff --git a/support/vs-code/agnosis/.vscode/launch.json b/support/vs-code/agnosis/.vscode/launch.json index 2e70650cd..b064923a8 100644 --- a/support/vs-code/agnosis/.vscode/launch.json +++ b/support/vs-code/agnosis/.vscode/launch.json @@ -11,7 +11,7 @@ "request": "launch", "args": [ "--extensionDevelopmentPath=${workspaceFolder}", - "--folder-uri=file:///home/linglong/College/example_expr_translator/translator" + "--folder-uri=file:///home/tardis/Documents/example_expr_translator-main/translator" ], "outFiles": [ "${workspaceFolder}/out/**/*.js" diff --git a/support/vs-code/agnosis/package.json b/support/vs-code/agnosis/package.json index 9ceb69edd..3b587dfde 100644 --- a/support/vs-code/agnosis/package.json +++ b/support/vs-code/agnosis/package.json @@ -36,6 +36,10 @@ { "command": "agnosis.showAttributeValuesHtml", "title": "showAttributeValuesHtml" + }, + { + "command": "agnosis.showSimpleDebugContext", + "title": "showSimpleDebugContext" } ] }, diff --git a/support/vs-code/agnosis/src/extension.ts b/support/vs-code/agnosis/src/extension.ts index bcb207642..7554fe682 100644 --- a/support/vs-code/agnosis/src/extension.ts +++ b/support/vs-code/agnosis/src/extension.ts @@ -54,7 +54,7 @@ export function activate(context: vscode.ExtensionContext) { let run_traslator = vscode.commands.registerCommand('agnosis.RunSilver', () => { vscode.window.showInformationMessage('Running Translator...'); - terminal.sendText(`./silver-compile --force-origins --clean`); + // terminal.sendText(`./silver-compile --force-origins --clean`); // get current open tab file name let working_file = vscode.window.activeTextEditor?.document.fileName || ''; let working_file_split = working_file.split('/'); @@ -121,39 +121,73 @@ export function activate(context: vscode.ExtensionContext) { }); - let currentPanel: vscode.WebviewPanel | undefined = undefined; - - const showAttributeValuesHtml = vscode.commands.registerCommand('agnosis.showAttributeValuesHtml', () => { - if (!currentPanel) { - currentPanel = vscode.window.createWebviewPanel( - 'attributeValues', - 'Attribute Values', - vscode.ViewColumn.One, - { enableScripts: true } - ); - - currentPanel.onDidDispose(() => { - currentPanel = undefined; - }); - } - - const updateWebviewContent = () => { - const filePath = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : ''; - const htmlPath = path.join(filePath, 'attribute_values.html'); - const htmlContent = fs.readFileSync(htmlPath, 'utf8'); - if (currentPanel) { - currentPanel.webview.html = htmlContent; - } - }; - updateWebviewContent(); - - const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.workspace.workspaceFolders![0], 'attribute_values.html')); - watcher.onDidChange(updateWebviewContent); - watcher.onDidDelete(updateWebviewContent); - watcher.onDidCreate(updateWebviewContent); - - }); + let attributeValuesPanel: vscode.WebviewPanel | undefined = undefined; + let simpleDebugContextPanel: vscode.WebviewPanel | undefined = undefined; + + const showAttributeValuesHtml = vscode.commands.registerCommand('agnosis.showAttributeValuesHtml', () => { + if (!attributeValuesPanel) { + attributeValuesPanel = vscode.window.createWebviewPanel( + 'attributeValues', + 'Attribute Values', + vscode.ViewColumn.One, + { enableScripts: true } + ); + + attributeValuesPanel.onDidDispose(() => { + attributeValuesPanel = undefined; + }); + } + + const updateAttributeValues = () => { + const filePath: string = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : ''; + const htmlPath: string = path.join(filePath, 'attribute_values.html'); + const htmlContent: string = fs.readFileSync(htmlPath, 'utf8'); + if (attributeValuesPanel) { + attributeValuesPanel.webview.html = htmlContent; + } + }; + + updateAttributeValues(); + + const attributeWatcher: vscode.FileSystemWatcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.workspace.workspaceFolders![0], 'attribute_values.html')); + attributeWatcher.onDidChange(updateAttributeValues); + attributeWatcher.onDidDelete(updateAttributeValues); + attributeWatcher.onDidCreate(updateAttributeValues); + }); + + const showSimpleDebugContext = vscode.commands.registerCommand('agnosis.showSimpleDebugContext', () => { + if (!simpleDebugContextPanel) { + simpleDebugContextPanel = vscode.window.createWebviewPanel( + 'simpleDebugContext', + 'Simple Debug Context', + vscode.ViewColumn.Two, // Optionally, place this in another column + { enableScripts: true } + ); + + simpleDebugContextPanel.onDidDispose(() => { + simpleDebugContextPanel = undefined; + }); + } + + const updateSimpleDebugContext = () => { + const filePath: string = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : ''; + const htmlPath: string = path.join(filePath, 'simpleDebugContext.html'); + const htmlContent: string = fs.readFileSync(htmlPath, 'utf8'); + if (simpleDebugContextPanel) { + simpleDebugContextPanel.webview.html = htmlContent; + } + }; + + updateSimpleDebugContext(); + + const simpleDebugWatcher: vscode.FileSystemWatcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.workspace.workspaceFolders![0], 'simpleDebugContext.html')); + simpleDebugWatcher.onDidChange(updateSimpleDebugContext); + simpleDebugWatcher.onDidDelete(updateSimpleDebugContext); + simpleDebugWatcher.onDidCreate(updateSimpleDebugContext); + }); + + const server = net.createServer(socket => { @@ -161,6 +195,9 @@ export function activate(context: vscode.ExtensionContext) { let message = data.toString().trim(); if (message === '1') { vscode.commands.executeCommand('agnosis.HighlightSilver'); + // run showAttributeValuesHtml + vscode.commands.executeCommand('agnosis.showAttributeValuesHtml'); + vscode.commands.executeCommand('agnosis.showSimpleDebugContext'); } }); }); @@ -172,6 +209,7 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(showAttributeValuesHtml); + context.subscriptions.push(showSimpleDebugContext); context.subscriptions.push(disposable); context.subscriptions.push(launchSilver_dispoable); context.subscriptions.push(run_traslator); From 5650f01d641dbe2d5b45dd6140e593f8d0800f4d Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Thu, 2 May 2024 17:58:21 -0500 Subject: [PATCH 60/64] moved everything added to decorated node into nodecontextmessage --- .vscode/settings.json | 3 +- runtime/java/src/common/Debug.java | 11 +- runtime/java/src/common/DecoratedNode.java | 450 +++++++++--------- .../java/src/common/NodeContextMessage.java | 229 ++++++++- 4 files changed, 457 insertions(+), 236 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 86b1fe3c2..22b7c76da 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,6 @@ "silver.jvmArgs": "-Xmx10G -Xss40M", "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable", "silver.compilerJar": "jars/silver.compiler.composed.Default.jar", - "java.compile.nullAnalysis.mode": "automatic" + "java.compile.nullAnalysis.mode": "automatic", + "liveServer.settings.port": 5501 } \ No newline at end of file diff --git a/runtime/java/src/common/Debug.java b/runtime/java/src/common/Debug.java index 05d5d3880..c62262425 100644 --- a/runtime/java/src/common/Debug.java +++ b/runtime/java/src/common/Debug.java @@ -474,12 +474,21 @@ else if(userInputList.length == 2){ private boolean toggleHeadlessAttributes; private String[] toggleChoices; + private boolean isRoot(DecoratedNode dn) { + return + dn.getParent() == null || + dn.getParent() instanceof TopNode || + dn.getParent().getParent() == null || + dn.getParent().getParent() instanceof TopNode; + } + //Replaces currentNode with its parent public Integer up() { + //Make sure there is a parent to go up to - if (currentNode.isRoot()){ + if (this.isRoot(currentNode)){ System.out.println("Root Node has no parent"); return -1; } diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index 5e2f6b30b..e1b8ddf6d 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -944,250 +944,250 @@ public final Object evalInhSomehowButPublic(final int attribute) { // getPrettyPrint() - private boolean isRedex; - private boolean isContractum; - private boolean isAttributeRoot; - private boolean needSetIsAttributeRoot = true; - - // Compute only once redex/contractum property - private boolean needComputeRedexContractum = true; - - public boolean getIsRedex() { - if (this.needComputeRedexContractum) { - this.computeRedexContractum(); - } - return this.isRedex; - } - public boolean getIsContractum() { - if (this.needComputeRedexContractum) { - this.computeRedexContractum(); - } - return this.isContractum; - } - - // Locally determing if redex and/or contractum - // through forwarding as the rewrite rule method - private void computeRedexContractum() { - if (!this.needComputeRedexContractum) { - return; - } - - if (this.self.hasForward()) { - this.isRedex = true; - } - else { - this.isRedex = false; - } + // private boolean isRedex; + // private boolean isContractum; + // private boolean isAttributeRoot; + // private boolean needSetIsAttributeRoot = true; + + // // Compute only once redex/contractum property + // private boolean needComputeRedexContractum = true; + + // public boolean getIsRedex() { + // if (this.needComputeRedexContractum) { + // this.computeRedexContractum(); + // } + // return this.isRedex; + // } + // public boolean getIsContractum() { + // if (this.needComputeRedexContractum) { + // this.computeRedexContractum(); + // } + // return this.isContractum; + // } + + // // Locally determing if redex and/or contractum + // // through forwarding as the rewrite rule method + // private void computeRedexContractum() { + // if (!this.needComputeRedexContractum) { + // return; + // } + + // if (this.self.hasForward()) { + // this.isRedex = true; + // } + // else { + // this.isRedex = false; + // } - if (this.forwardParent != null) { - this.isContractum = true; - } - else { - this.isContractum = false; - } - this.needComputeRedexContractum = false; - } - - // Wrapper for recursive helper - // Returns the first redex parent encountered or null if none - public DecoratedNode getRedex() { - return this.getRedexHelper(this); - } - - private DecoratedNode getRedexHelper(DecoratedNode dn) { - if (dn == null || dn.isRoot()) { - return null; - } + // if (this.forwardParent != null) { + // this.isContractum = true; + // } + // else { + // this.isContractum = false; + // } + // this.needComputeRedexContractum = false; + // } + + // // Wrapper for recursive helper + // // Returns the first redex parent encountered or null if none + // public DecoratedNode getRedex() { + // return this.getRedexHelper(this); + // } + + // private DecoratedNode getRedexHelper(DecoratedNode dn) { + // if (dn == null || dn.isRoot()) { + // return null; + // } - if (dn.isRedex) { - return dn; - } - else { - return getRedexHelper(dn.parent); - } - } - - // Wrapper for recursive helper - // Returns the first contractum parent encountered or null if none - public DecoratedNode getContractum() { - // Wrapper for recursive helper - return this.getContractumHelper(this); - } - private DecoratedNode getContractumHelper(DecoratedNode dn) { - if (dn == null || dn.isRoot()) { - return null; - } + // if (dn.isRedex) { + // return dn; + // } + // else { + // return getRedexHelper(dn.parent); + // } + // } + + // // Wrapper for recursive helper + // // Returns the first contractum parent encountered or null if none + // public DecoratedNode getContractum() { + // // Wrapper for recursive helper + // return this.getContractumHelper(this); + // } + // private DecoratedNode getContractumHelper(DecoratedNode dn) { + // if (dn == null || dn.isRoot()) { + // return null; + // } - if (dn.isContractum) { - return dn; - } - else { - return getContractumHelper(dn.parent); - } - } - - // Get filename the associated with the concrete syntax location - // origin tacking follows back from this node - public String getFilename() { + // if (dn.isContractum) { + // return dn; + // } + // else { + // return getContractumHelper(dn.parent); + // } + // } + + // // Get filename the associated with the concrete syntax location + // // origin tacking follows back from this node + // public String getFilename() { - boolean res = this.self instanceof silver.core.Alocation; - res = this.self instanceof Tracked; - - if(self == null) { - return ""; - } - NLocation loc = null; - if(self instanceof silver.core.Alocation) { - loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); - } else if(self instanceof Tracked) { - NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); - if(maybeLoc instanceof silver.core.Pjust) { - loc = (silver.core.NLocation)maybeLoc.getChild(0); - } - } - if(loc != null) { - String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); - return file; - } + // boolean res = this.self instanceof silver.core.Alocation; + // res = this.self instanceof Tracked; + + // if(self == null) { + // return ""; + // } + // NLocation loc = null; + // if(self instanceof silver.core.Alocation) { + // loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); + // } else if(self instanceof Tracked) { + // NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); + // if(maybeLoc instanceof silver.core.Pjust) { + // loc = (silver.core.NLocation)maybeLoc.getChild(0); + // } + // } + // if(loc != null) { + // String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); + // return file; + // } - return ""; - } + // return ""; + // } - // Get start coordinates for the file location associated with - // the concrete syntax location origin tacking follows back from this node - public FileCoordinate getStartCoordinates() { + // // Get start coordinates for the file location associated with + // // the concrete syntax location origin tacking follows back from this node + // public FileCoordinate getStartCoordinates() { - if(self == null) { - return new FileCoordinate(-2, -2); - } - NLocation loc = null; - if(self instanceof silver.core.Alocation) { - loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); - } else if(self instanceof Tracked) { - NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); - if(maybeLoc instanceof silver.core.Pjust) { - loc = (silver.core.NLocation)maybeLoc.getChild(0); - } - } - if(loc != null) { - int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); - int col = (Integer)loc.synthesized(silver.core.Init.silver_core_column__ON__silver_core_Location); - return new FileCoordinate(line, col); - } + // if(self == null) { + // return new FileCoordinate(-2, -2); + // } + // NLocation loc = null; + // if(self instanceof silver.core.Alocation) { + // loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); + // } else if(self instanceof Tracked) { + // NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); + // if(maybeLoc instanceof silver.core.Pjust) { + // loc = (silver.core.NLocation)maybeLoc.getChild(0); + // } + // } + // if(loc != null) { + // int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); + // int col = (Integer)loc.synthesized(silver.core.Init.silver_core_column__ON__silver_core_Location); + // return new FileCoordinate(line, col); + // } - return new FileCoordinate(-1, -1); - } + // return new FileCoordinate(-1, -1); + // } - // Get end coordinates for the file location associated with - // the concrete syntax location origin tacking follows back from this node - public FileCoordinate getEndCoordinates() { + // // Get end coordinates for the file location associated with + // // the concrete syntax location origin tacking follows back from this node + // public FileCoordinate getEndCoordinates() { - if(self == null) { - return new FileCoordinate(-2, -2); - } - NLocation loc = null; - if(self instanceof silver.core.Alocation) { - loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); - } else if(self instanceof Tracked) { - NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); - if(maybeLoc instanceof silver.core.Pjust) { - loc = (silver.core.NLocation)maybeLoc.getChild(0); - } - } - if(loc != null) { - int line = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); - int col = (Integer)loc.synthesized(silver.core.Init.silver_core_endColumn__ON__silver_core_Location); - return new FileCoordinate(line, col); - } + // if(self == null) { + // return new FileCoordinate(-2, -2); + // } + // NLocation loc = null; + // if(self instanceof silver.core.Alocation) { + // loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); + // } else if(self instanceof Tracked) { + // NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); + // if(maybeLoc instanceof silver.core.Pjust) { + // loc = (silver.core.NLocation)maybeLoc.getChild(0); + // } + // } + // if(loc != null) { + // int line = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); + // int col = (Integer)loc.synthesized(silver.core.Init.silver_core_endColumn__ON__silver_core_Location); + // return new FileCoordinate(line, col); + // } - return new FileCoordinate(-1, -1); - } + // return new FileCoordinate(-1, -1); + // } - // Access pretty print attribute - // through this function (a synthesized attribute) - // "pp" is the standard pretty print name - public String getPrettyPrint() { + // // Access pretty print attribute + // // through this function (a synthesized attribute) + // // "pp" is the standard pretty print name + // public String getPrettyPrint() { - int numAttrs = this.self.getNumberOfSynAttrs(); - for (int i = 0; i < numAttrs; i++) { + // // int numAttrs = this.self.getNumberOfSynAttrs(); + // // for (int i = 0; i < numAttrs; i++) { - // Search until find name that is "pp" - String name = this.self.getNameOfSynAttr(i); - // Want last three characters to be ":pp" - if (name.substring(name.length() - 3).toLowerCase().equals(":pp")) { - Object pp = evalSyn(i); - return pp.toString(); - } - } - System.err.println("No pretty print (pp) attribute defined--using genericShow() instead"); - return Util.genericShow(this).toString(); - } - - // only set isAttributeRoot once - public boolean getIsAttributeRoot() { - if (this.needSetIsAttributeRoot) { - this.setIsAttributeRoot(); - this.needSetIsAttributeRoot = false; - } - return this.isAttributeRoot; - } - - // Catch program "root" - public boolean isRoot() { - return - this.parent == null || - this.parent instanceof TopNode || - this.parent.parent == null || - this.parent.parent instanceof TopNode; - } + // // // Search until find name that is "pp" + // // String name = this.self.getNameOfSynAttr(i); + // // // Want last three characters to be ":pp" + // // if (name.substring(name.length() - 3).toLowerCase().equals(":pp")) { + // // Object pp = evalSyn(i); + // // return pp.toString(); + // // } + // // } + // // System.err.println("No pretty print (pp) attribute defined--using genericShow() instead"); + // return Util.genericShow(this).toString(); + // } + + // // only set isAttributeRoot once + // public boolean getIsAttributeRoot() { + // if (this.needSetIsAttributeRoot) { + // this.setIsAttributeRoot(); + // this.needSetIsAttributeRoot = false; + // } + // return this.isAttributeRoot; + // } + + // // Catch program "root" + // public boolean isRoot() { + // return + // this.parent == null || + // this.parent instanceof TopNode || + // this.parent.parent == null || + // this.parent.parent instanceof TopNode; + // } - // Higher-order attribute roots are attributes of their parent nodes. - // Only do once. - public void setIsAttributeRoot() { + // // Higher-order attribute roots are attributes of their parent nodes. + // // Only do once. + // public void setIsAttributeRoot() { - if (! (this == null || this.isRoot())) { - Map map = Debug.allAttributesThunkMap(this.parent); - Collection values = map.values(); - for (Object obj: values) { - if (Util.demand(obj) == this) { - this.isAttributeRoot = true; - return; - } - } - } - this.isAttributeRoot = false; - } - - // Determine higher-order attribute nesting of this node. - public int getIsAttribute() { - if (this == null || this.isRoot()) { - return 0; - } - else { - if (this.getIsAttributeRoot()) { - return 1 + this.parent.getIsAttribute(); - } - return this.parent.getIsAttribute(); - } - } + // if (! (this == null || this.isRoot())) { + // Map map = Debug.allAttributesThunkMap(this.parent); + // Collection values = map.values(); + // for (Object obj: values) { + // if (Util.demand(obj) == this) { + // this.isAttributeRoot = true; + // return; + // } + // } + // } + // this.isAttributeRoot = false; + // } + + // // Determine higher-order attribute nesting of this node. + // public int getIsAttribute() { + // if (this == null || this.isRoot()) { + // return 0; + // } + // else { + // if (this.getIsAttributeRoot()) { + // return 1 + this.parent.getIsAttribute(); + // } + // return this.parent.getIsAttribute(); + // } + // } - // Determine how many forwarding edges were followed to get to this node. - public int getIsTranslation() { - // See how many parents are contractums - // Calling parent repeatedly will ignore forwarding nodes, so operate on - // getIsContractum only as the case to determine whether forwarding occurs or not - if (this == null || this.isRoot()) { - return 0; - } - else if (this.getIsContractum()) { - return 1 + this.parent.getIsTranslation(); - } - else { - return this.parent.getIsTranslation(); - } - } + // // Determine how many forwarding edges were followed to get to this node. + // public int getIsTranslation() { + // // See how many parents are contractums + // // Calling parent repeatedly will ignore forwarding nodes, so operate on + // // getIsContractum only as the case to determine whether forwarding occurs or not + // if (this == null || this.isRoot()) { + // return 0; + // } + // else if (this.getIsContractum()) { + // return 1 + this.parent.getIsTranslation(); + // } + // else { + // return this.parent.getIsTranslation(); + // } + // } } diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index dc0032431..68e96cc4a 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -3,6 +3,11 @@ import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; +import java.util.Collection; +import java.util.Map; + +import silver.core.NLocation; +import silver.core.NMaybe; // Core of the debugging contextualization implementation. // A NodeContextMessage records all debugging contextualization @@ -129,24 +134,24 @@ public NodeContextMessage(DecoratedNode node, int numIndex) { // Set translationX and higherOrderY bools here private void initializeHeaders(DecoratedNode node) { - this.translationX = node.getIsTranslation(); - this.higherOrderY = node.getIsAttribute(); + this.translationX = getIsTranslation(node); + this.higherOrderY = getIsAttribute(node); } // Use file location method written in DecoratedNode private void fillInRowsAndCols(DecoratedNode node){ - this.fcStart = node.getStartCoordinates(); - this.fcEnd = node.getEndCoordinates(); - this.filename = node.getFilename(); + this.fcStart = getStartCoordinates(node); + this.fcEnd = getEndCoordinates(node); + this.filename = getFilename(node); } // Labels currently only regard forwarding and higher-order attributes. private void setLabels(DecoratedNode node) { - this.isRedex = node.getIsRedex(); - this.isContractum = node.getIsContractum(); - this.isAttributeRoot = node.getIsAttributeRoot(); + this.isRedex = getIsRedex(node); + this.isContractum = getIsContractum(node); + this.isAttributeRoot = getIsAttributeRoot(node); // Only relevant if these attributes are true this.contractumOf = this.numIndex - 1; @@ -156,7 +161,7 @@ private void setLabels(DecoratedNode node) { // access pp attribute if present private void prettyPrint(DecoratedNode node) { - this.textRepr = node.getPrettyPrint(); + this.textRepr = getPrettyPrint(node); } // Basically extract file lines from row x col y to @@ -216,6 +221,212 @@ public String toString() { } + // Helper functions to extract info from DecoratedNode + public boolean getIsRedex(DecoratedNode dn) { + if (dn.getNode() == null) { + return false; + } + else if (dn.getNode().hasForward()) { + return true; + } + return false; + } + + public boolean getIsContractum(DecoratedNode dn) { + if (dn.getNode() == null) { + return false; + } + else if (dn.getForwardParent() != null) { + return true; + } + return false; + } + + public DecoratedNode getRedex(DecoratedNode dn) { + return this.getRedexHelper(dn); + } + + private DecoratedNode getRedexHelper(DecoratedNode dn) { + if (dn == null || isRoot(dn)) { + return null; + } + + if (getIsRedex(dn)) { + return dn; + } + else { + return getRedexHelper(dn.getParent()); + } + } + + public DecoratedNode getContractum(DecoratedNode dn) { + return this.getContractumHelper(dn); + } + + private DecoratedNode getContractumHelper(DecoratedNode dn) { + if (dn == null || isRoot(dn)) { + return null; + } + + if (getIsContractum(dn)) { + return dn; + } + else { + return getContractumHelper(dn.getParent()); + } + } + + // Get filename the associated with the concrete syntax location + // origin tacking follows back from this node + public String getFilename(DecoratedNode dn) { + + // boolean res = dn.getNode() instanceof silver.core.Alocation; + // res = dn.getNode() instanceof Tracked; + + if(dn.getNode() == null) { + return ""; + } + NLocation loc = null; + if(dn.getNode() instanceof silver.core.Alocation) { + loc = ((silver.core.Alocation)dn.getNode()).getAnno_silver_core_location(); + } else if(dn.getNode() instanceof Tracked) { + NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, dn.getNode()); + if(maybeLoc instanceof silver.core.Pjust) { + loc = (silver.core.NLocation)maybeLoc.getChild(0); + } + } + if(loc != null) { + String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); + return file; + } + + return ""; + } + + // Get start coordinates for the file location associated with + // the concrete syntax location origin tacking follows back from this node + public FileCoordinate getStartCoordinates(DecoratedNode dn) { + + if(dn.getNode() == null) { + return new FileCoordinate(-2, -2); + } + NLocation loc = null; + if(dn.getNode() instanceof silver.core.Alocation) { + loc = ((silver.core.Alocation)dn.getNode()).getAnno_silver_core_location(); + } else if(dn.getNode() instanceof Tracked) { + NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, dn.getNode()); + if(maybeLoc instanceof silver.core.Pjust) { + loc = (silver.core.NLocation)maybeLoc.getChild(0); + } + } + if(loc != null) { + int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); + int col = (Integer)loc.synthesized(silver.core.Init.silver_core_column__ON__silver_core_Location); + return new FileCoordinate(line, col); + } + + return new FileCoordinate(-1, -1); + } + + // Get end coordinates for the file location associated with + // the concrete syntax location origin tacking follows back from this node + public FileCoordinate getEndCoordinates(DecoratedNode dn) { + + if(dn.getNode() == null) { + return new FileCoordinate(-2, -2); + } + NLocation loc = null; + if(dn.getNode() instanceof silver.core.Alocation) { + loc = ((silver.core.Alocation)dn.getNode()).getAnno_silver_core_location(); + } else if(dn.getNode() instanceof Tracked) { + NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, dn.getNode()); + if(maybeLoc instanceof silver.core.Pjust) { + loc = (silver.core.NLocation)maybeLoc.getChild(0); + } + } + if(loc != null) { + int line = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); + int col = (Integer)loc.synthesized(silver.core.Init.silver_core_endColumn__ON__silver_core_Location); + return new FileCoordinate(line, col); + } + + return new FileCoordinate(-1, -1); + } + + // Access pretty print attribute + // through this function (a synthesized attribute) + // "pp" is the standard pretty print name + public String getPrettyPrint(DecoratedNode dn) { + + int numAttrs = dn.getNode().getNumberOfSynAttrs(); + for (int i = 0; i < numAttrs; i++) { + + // Search until find name that is "pp" + String name = dn.getNode().getNameOfSynAttr(i); + // Want last three characters to be ":pp" + if (name.substring(name.length() - 3).toLowerCase().equals(":pp")) { + Object pp = dn.synthesized(i); + return pp.toString(); + } + } + System.err.println("No pretty print (pp) attribute defined--using genericShow() instead"); + return Util.genericShow(this).toString(); + } + + // Catch program "root" + public boolean isRoot(DecoratedNode dn) { + return + dn.getParent() == null || + dn.getParent() instanceof TopNode || + dn.getParent().getParent() == null || + dn.getParent().getParent() instanceof TopNode; + } + + // only set isAttributeRoot once + public boolean getIsAttributeRoot(DecoratedNode dn) { + if (! (dn == null || isRoot(dn))) { + Map map = Debug.allAttributesThunkMap(dn.getParent()); + Collection values = map.values(); + for (Object obj: values) { + if (Util.demand(obj) == dn) { + return true; + } + } + } + return false; + } + + // Determine higher-order attribute nesting of this node. + public int getIsAttribute(DecoratedNode dn) { + if (dn == null || isRoot(dn)) { + return 0; + } + else { + if (getIsAttributeRoot(dn)) { + return 1 + getIsAttribute(dn.getParent()); + } + return getIsAttribute(dn.getParent()); + } + } + + // Determine how many forwarding edges were followed to get to this node. + public int getIsTranslation(DecoratedNode dn) { + // See how many parents are contractums + // Calling parent repeatedly will ignore forwarding nodes, so operate on + // getIsContractum only as the case to determine whether forwarding occurs or not + if (dn == null || isRoot(dn)) { + return 0; + } + else if (getIsContractum(dn)) { + return 1 + getIsTranslation(dn.getParent()); + } + else { + return getIsTranslation(dn.getParent()); + } + } + + + // Section 0. Every context box will have a numeric index label private int numIndex; From fd7e985bafbd7c095f6f28781cc5116d351463ea Mon Sep 17 00:00:00 2001 From: Lucas Kramer Date: Fri, 3 May 2024 11:41:50 -0500 Subject: [PATCH 61/64] Recognize the silver:langutil:pp/silver:langutil:unparse attrs --- .../java/src/common/NodeContextMessage.java | 23 +--------- runtime/java/src/common/Util.java | 43 ++++++++++++++++++- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index 68e96cc4a..7e5f70dc7 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -161,7 +161,7 @@ private void setLabels(DecoratedNode node) { // access pp attribute if present private void prettyPrint(DecoratedNode node) { - this.textRepr = getPrettyPrint(node); + this.textRepr = Util.getPrettyPrint(node); } // Basically extract file lines from row x col y to @@ -352,27 +352,6 @@ public FileCoordinate getEndCoordinates(DecoratedNode dn) { return new FileCoordinate(-1, -1); } - - // Access pretty print attribute - // through this function (a synthesized attribute) - // "pp" is the standard pretty print name - public String getPrettyPrint(DecoratedNode dn) { - - int numAttrs = dn.getNode().getNumberOfSynAttrs(); - for (int i = 0; i < numAttrs; i++) { - - // Search until find name that is "pp" - String name = dn.getNode().getNameOfSynAttr(i); - // Want last three characters to be ":pp" - if (name.substring(name.length() - 3).toLowerCase().equals(":pp")) { - Object pp = dn.synthesized(i); - return pp.toString(); - } - } - System.err.println("No pretty print (pp) attribute defined--using genericShow() instead"); - return Util.genericShow(this).toString(); - } - // Catch program "root" public boolean isRoot(DecoratedNode dn) { return diff --git a/runtime/java/src/common/Util.java b/runtime/java/src/common/Util.java index d2c5a324d..edc0f02a9 100644 --- a/runtime/java/src/common/Util.java +++ b/runtime/java/src/common/Util.java @@ -422,17 +422,56 @@ private static void hackyhackyUnparseList(ConsCell c, StringBuilder sb) { * @return A string representation. */ public static StringCatter genericShow(Object o) { + Object pp = null; try { Method genericPP = Class.forName("silver.langutil.reflect.PgenericPP") .getMethod("invoke", OriginContext.class, Object.class); + pp = genericPP.invoke(null, OriginContext.FFI_CONTEXT, o); + } catch(ClassNotFoundException | NoSuchMethodException | SecurityException | + IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return hackyhackyUnparse(o); + } + return showDoc(pp); + } + + /** + * Reflective wrapper around silver:langutil:pp:showDoc. + * + * @param pp The Document value to render + * @return A string representation. + */ + public static StringCatter showDoc(Object pp) { + try { Method showDoc = Class.forName("silver.langutil.pp.PshowDoc") .getMethod("invoke", OriginContext.class, Object.class, Object.class); - Object pp = genericPP.invoke(null, OriginContext.FFI_CONTEXT, o); return (StringCatter)showDoc.invoke(null, OriginContext.FFI_CONTEXT, 80, pp); } catch(ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return hackyhackyUnparse(o); + // If we already *have* a Document value, then the showDoc function should exist, + // so this should never happen. + throw new SilverInternalError("Error rendering pretty print", e); + } + } + + /** + * Get the pretty-print or unparse of a tree if available, + * otherwise falling back to genericShow. + * + * @param dn The tree to show + * @return A string representation. + */ + public static String getPrettyPrint(DecoratedNode dn) { + int numAttrs = dn.getNode().getNumberOfSynAttrs(); + for (int i = 0; i < numAttrs; i++) { + String attrName = dn.getNode().getNameOfSynAttr(i); + switch (attrName) { + case "silver:langutil:pp": + return showDoc(dn.synthesized(i)).toString(); + case "silver:langutil:unparse": + return dn.synthesized(i).toString(); + } } + return genericShow(dn.getNode()).toString(); } /** From 93df3a886331f37a77a566c1f3ba8a2494c24da3 Mon Sep 17 00:00:00 2001 From: Lucas Kramer Date: Fri, 3 May 2024 20:09:03 -0500 Subject: [PATCH 62/64] Bump up stack space in running test suites --- grammars/silver/testing/bin/TestSpecLang.sv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/silver/testing/bin/TestSpecLang.sv b/grammars/silver/testing/bin/TestSpecLang.sv index 423c8fb37..243ae7f9c 100644 --- a/grammars/silver/testing/bin/TestSpecLang.sv +++ b/grammars/silver/testing/bin/TestSpecLang.sv @@ -91,7 +91,7 @@ ts::Run ::= 'test' 'suite' jar::Jar_t local testSuiteResults :: IOVal = systemT ("cd " ++ ts.testFileDir ++ ";" ++ "rm -f " ++ ts.testFileName ++ ".output ; " ++ - " java -Xss6M -jar " ++ jar.lexeme ++ + " java -Xss30M -jar " ++ jar.lexeme ++ " >& " ++ ts.testFileName ++ ".output" , msgBefore ) ; From d0cc1ce46b143e42d55c804d6e25fc3e2195276a Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Tue, 7 May 2024 21:39:17 -0500 Subject: [PATCH 63/64] comment changes --- runtime/java/src/common/DecoratedNode.java | 275 ------------------ .../java/src/common/NodeContextMessage.java | 10 +- 2 files changed, 7 insertions(+), 278 deletions(-) diff --git a/runtime/java/src/common/DecoratedNode.java b/runtime/java/src/common/DecoratedNode.java index e1b8ddf6d..f9d01d83d 100644 --- a/runtime/java/src/common/DecoratedNode.java +++ b/runtime/java/src/common/DecoratedNode.java @@ -913,281 +913,6 @@ public final Object evalInhSomehowButPublic(final int attribute) { return evalInhViaFwdP(attribute); } - - // ************************************************************** - // Below here are all functions and attributes added to Decorated Node - // for debugging contextualization. - - // TODO. Make into Utils file. Will have worse time complexity though. - - // Functions - - // For labels in NodeContextMessageBox - // getRedex() - // getIsRedex() - // getContractum() - // getIsContractum() - // getIsAttributeRoot() - - // For headers for NodeContextMessageBox - // getIsAttribute() - // getIsTranslation() - - - // Getting concrete syntax from parsed file - // getFilename() - // getStartCoordinates() - // getEndCoordinates() - - // Concrete syntax alternative if node - // was created by rewrite rule or higher-order attribute - // getPrettyPrint() - - - // private boolean isRedex; - // private boolean isContractum; - // private boolean isAttributeRoot; - // private boolean needSetIsAttributeRoot = true; - - // // Compute only once redex/contractum property - // private boolean needComputeRedexContractum = true; - - // public boolean getIsRedex() { - // if (this.needComputeRedexContractum) { - // this.computeRedexContractum(); - // } - // return this.isRedex; - // } - // public boolean getIsContractum() { - // if (this.needComputeRedexContractum) { - // this.computeRedexContractum(); - // } - // return this.isContractum; - // } - - // // Locally determing if redex and/or contractum - // // through forwarding as the rewrite rule method - // private void computeRedexContractum() { - // if (!this.needComputeRedexContractum) { - // return; - // } - - // if (this.self.hasForward()) { - // this.isRedex = true; - // } - // else { - // this.isRedex = false; - // } - - // if (this.forwardParent != null) { - // this.isContractum = true; - // } - // else { - // this.isContractum = false; - // } - // this.needComputeRedexContractum = false; - // } - - // // Wrapper for recursive helper - // // Returns the first redex parent encountered or null if none - // public DecoratedNode getRedex() { - // return this.getRedexHelper(this); - // } - - // private DecoratedNode getRedexHelper(DecoratedNode dn) { - // if (dn == null || dn.isRoot()) { - // return null; - // } - - // if (dn.isRedex) { - // return dn; - // } - // else { - // return getRedexHelper(dn.parent); - // } - // } - - // // Wrapper for recursive helper - // // Returns the first contractum parent encountered or null if none - // public DecoratedNode getContractum() { - // // Wrapper for recursive helper - // return this.getContractumHelper(this); - // } - // private DecoratedNode getContractumHelper(DecoratedNode dn) { - // if (dn == null || dn.isRoot()) { - // return null; - // } - - // if (dn.isContractum) { - // return dn; - // } - // else { - // return getContractumHelper(dn.parent); - // } - // } - - // // Get filename the associated with the concrete syntax location - // // origin tacking follows back from this node - // public String getFilename() { - - // boolean res = this.self instanceof silver.core.Alocation; - // res = this.self instanceof Tracked; - - // if(self == null) { - // return ""; - // } - // NLocation loc = null; - // if(self instanceof silver.core.Alocation) { - // loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); - // } else if(self instanceof Tracked) { - // NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); - // if(maybeLoc instanceof silver.core.Pjust) { - // loc = (silver.core.NLocation)maybeLoc.getChild(0); - // } - // } - // if(loc != null) { - // String file = loc.synthesized(silver.core.Init.silver_core_filename__ON__silver_core_Location).toString(); - // return file; - // } - - // return ""; - // } - - // // Get start coordinates for the file location associated with - // // the concrete syntax location origin tacking follows back from this node - // public FileCoordinate getStartCoordinates() { - - // if(self == null) { - // return new FileCoordinate(-2, -2); - // } - // NLocation loc = null; - // if(self instanceof silver.core.Alocation) { - // loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); - // } else if(self instanceof Tracked) { - // NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); - // if(maybeLoc instanceof silver.core.Pjust) { - // loc = (silver.core.NLocation)maybeLoc.getChild(0); - // } - // } - // if(loc != null) { - // int line = (Integer)loc.synthesized(silver.core.Init.silver_core_line__ON__silver_core_Location); - // int col = (Integer)loc.synthesized(silver.core.Init.silver_core_column__ON__silver_core_Location); - // return new FileCoordinate(line, col); - // } - - // return new FileCoordinate(-1, -1); - // } - - // // Get end coordinates for the file location associated with - // // the concrete syntax location origin tacking follows back from this node - // public FileCoordinate getEndCoordinates() { - - // if(self == null) { - // return new FileCoordinate(-2, -2); - // } - // NLocation loc = null; - // if(self instanceof silver.core.Alocation) { - // loc = ((silver.core.Alocation)self).getAnno_silver_core_location(); - // } else if(self instanceof Tracked) { - // NMaybe maybeLoc = silver.core.PgetParsedOriginLocation.invoke(OriginContext.FFI_CONTEXT, self); - // if(maybeLoc instanceof silver.core.Pjust) { - // loc = (silver.core.NLocation)maybeLoc.getChild(0); - // } - // } - // if(loc != null) { - // int line = (Integer)loc.synthesized(silver.core.Init.silver_core_endLine__ON__silver_core_Location); - // int col = (Integer)loc.synthesized(silver.core.Init.silver_core_endColumn__ON__silver_core_Location); - // return new FileCoordinate(line, col); - // } - - // return new FileCoordinate(-1, -1); - // } - - - // // Access pretty print attribute - // // through this function (a synthesized attribute) - // // "pp" is the standard pretty print name - // public String getPrettyPrint() { - - // // int numAttrs = this.self.getNumberOfSynAttrs(); - // // for (int i = 0; i < numAttrs; i++) { - - // // // Search until find name that is "pp" - // // String name = this.self.getNameOfSynAttr(i); - // // // Want last three characters to be ":pp" - // // if (name.substring(name.length() - 3).toLowerCase().equals(":pp")) { - // // Object pp = evalSyn(i); - // // return pp.toString(); - // // } - // // } - // // System.err.println("No pretty print (pp) attribute defined--using genericShow() instead"); - // return Util.genericShow(this).toString(); - // } - - // // only set isAttributeRoot once - // public boolean getIsAttributeRoot() { - // if (this.needSetIsAttributeRoot) { - // this.setIsAttributeRoot(); - // this.needSetIsAttributeRoot = false; - // } - // return this.isAttributeRoot; - // } - - // // Catch program "root" - // public boolean isRoot() { - // return - // this.parent == null || - // this.parent instanceof TopNode || - // this.parent.parent == null || - // this.parent.parent instanceof TopNode; - // } - - // // Higher-order attribute roots are attributes of their parent nodes. - // // Only do once. - // public void setIsAttributeRoot() { - - // if (! (this == null || this.isRoot())) { - // Map map = Debug.allAttributesThunkMap(this.parent); - // Collection values = map.values(); - // for (Object obj: values) { - // if (Util.demand(obj) == this) { - // this.isAttributeRoot = true; - // return; - // } - // } - // } - // this.isAttributeRoot = false; - // } - - // // Determine higher-order attribute nesting of this node. - // public int getIsAttribute() { - // if (this == null || this.isRoot()) { - // return 0; - // } - // else { - // if (this.getIsAttributeRoot()) { - // return 1 + this.parent.getIsAttribute(); - // } - // return this.parent.getIsAttribute(); - // } - // } - - - // // Determine how many forwarding edges were followed to get to this node. - // public int getIsTranslation() { - // // See how many parents are contractums - // // Calling parent repeatedly will ignore forwarding nodes, so operate on - // // getIsContractum only as the case to determine whether forwarding occurs or not - // if (this == null || this.isRoot()) { - // return 0; - // } - // else if (this.getIsContractum()) { - // return 1 + this.parent.getIsTranslation(); - // } - // else { - // return this.parent.getIsTranslation(); - // } - // } } diff --git a/runtime/java/src/common/NodeContextMessage.java b/runtime/java/src/common/NodeContextMessage.java index 7e5f70dc7..3d601933d 100644 --- a/runtime/java/src/common/NodeContextMessage.java +++ b/runtime/java/src/common/NodeContextMessage.java @@ -11,7 +11,7 @@ // Core of the debugging contextualization implementation. // A NodeContextMessage records all debugging contextualization -// information we wish to keep about a navigated-to node. +// information we wish to keep about a navigated-to DecoratedNode node. // A stack of these makes up a "full" or verbose ContextStack. // The ContextStack is then compressed to yield a better @@ -31,14 +31,18 @@ // file lines as well. But they are not needed for the current version of // the SimplifiedContextStack). - // SECTION 4. (labels). Labels represents whether the current node is involved with // horizontal edges. Current possible labels are is-contractuma and is-redex // (for forwarding relationship) and is-attribute-root (for higher-order attribute subtree roots). // Labels are currently extracted from DecoratedNode itself. // If showing intermediate full stack representation (ContextStack), then use GetSection_(). -// If accessing stored information for a +// where _ is 1, 2, 3, or 4. +// If accessing stored information to generate a SimplifiedContextBox, +// use header/label getters directly, e.g. getIsRedex() or getProdName(). +// All label/header contextualization fields are set by the constuctor calling +// the necessary info section-generating functions; +// the DecoratedNode to contextualize is passed directly in the constructor. // TODO. Add a new contextualization label/header framework for REFERENCE ATTRIBUTES. From 4ebcfb42b42c629d6998e68b11d0915e4a97b97c Mon Sep 17 00:00:00 2001 From: Matthew Feraru Date: Wed, 8 May 2024 20:10:09 -0500 Subject: [PATCH 64/64] removed unused class --- runtime/java/src/common/FileRange.java | 87 -------------------------- 1 file changed, 87 deletions(-) delete mode 100644 runtime/java/src/common/FileRange.java diff --git a/runtime/java/src/common/FileRange.java b/runtime/java/src/common/FileRange.java deleted file mode 100644 index ec21decaf..000000000 --- a/runtime/java/src/common/FileRange.java +++ /dev/null @@ -1,87 +0,0 @@ -//package agnosis-context.libs.visualization; -package common; - -import static java.lang.Math.min; -import static java.lang.Math.max; - -/** - * A FileRange object represents a range of file coordinate between two FileCoordinate objects - */ -public class FileRange { - private final FileCoordinate coord1, coord2; - - /** - * Constructs a FileRange object with the bounds of two file coordinates. - * The file coordinates need not be supplied in a particular order. - * - * @param coord1 the first file coordinate bound - * @param coord2 the second file coordinate bound - */ - public FileRange(FileCoordinate coord1, FileCoordinate coord2) { - this.coord1 = coord1; - this.coord2 = coord2; - } - - /** - * Returns if the file range is contained inside of the file range represented - * by this object. - * - * @param range the range to be checked if it is contained - * @return if the range is contained in the range represented by this object - */ - public boolean contains(FileRange range) { - return this.contains(range.coord1) && this.contains(range.coord2); - } - - /** - * Returns if the file coordinate is contained inside of the file range represented - * by this object. - * - * @param coord the coordinate to be checked if it is contained - * @return if the coordinate is contained in the range represented by this object - */ - public boolean contains(FileCoordinate coord) { - FileCoordinate topLeft = this.getTopLeft(); - FileCoordinate bottomRight = this.getBottomRight(); - - if(coord.getRow() < topLeft.getRow() || coord.getRow() > bottomRight.getRow()) return false; - if(coord.getCol() < topLeft.getCol() || coord.getCol() > bottomRight.getCol()) return false; - - return true; - } - - /** - * Returns the file coordinate that represents the top left coordinate of the range. - * - * @return the file coordinate that represents the top left coordinate of the range - */ - public FileCoordinate getTopLeft() { - int row = min(coord1.getRow(), coord2.getRow()); - int col = min(coord1.getCol(), coord2.getCol()); - - if(coord1.getRow() == row && coord1.getCol() == col) return coord1; - if(coord2.getRow() == row && coord2.getCol() == col) return coord2; - - return new FileCoordinate(row, col); - } - - /** - * Returns the file coordinate that represents the bottom right coordinate of the range. - * - * @return the file coordinate that represents the bottom right coordinate of the range - */ - public FileCoordinate getBottomRight() { - int row = max(coord1.getRow(), coord2.getRow()); - int col = max(coord1.getCol(), coord2.getCol()); - - if(coord1.getRow() == row && coord1.getCol() == col) return coord1; - if(coord2.getRow() == row && coord2.getCol() == col) return coord2; - - return new FileCoordinate(row, col); - } - - @Override - public String toString() { - return String.format("%s -> %s", this.getTopLeft(), this.getBottomRight()); - } -}