MCPcopy Create free account
hub / github.com/antlr/codebuff / featureNameHeader

Method featureNameHeader

src/org/antlr/codebuff/Trainer.java:867–910  ·  view source on GitHub ↗
(FeatureMetaData[] FEATURES)

Source from the content-addressed store, hash-verified

865 }
866
867 public static String featureNameHeader(FeatureMetaData[] FEATURES) {
868 StringBuilder buf = new StringBuilder();
869 for (int i=0; i<FEATURES.length; i++) {
870 if ( FEATURES[i].type.equals(UNUSED) ) continue;
871 if ( i>0 ) buf.append(" ");
872 if ( i==INDEX_CUR_TOKEN_TYPE ) {
873 buf.append("| "); // separate prev from current tokens
874 }
875 int displayWidth = FEATURES[i].type.displayWidth;
876 buf.append(StringUtils.center(FEATURES[i].abbrevHeaderRows[0], displayWidth));
877 }
878 buf.append("\n");
879 for (int i=0; i<FEATURES.length; i++) {
880 if ( FEATURES[i].type.equals(UNUSED) ) continue;
881 if ( i>0 ) buf.append(" ");
882 if ( i==INDEX_CUR_TOKEN_TYPE ) {
883 buf.append("| "); // separate prev from current tokens
884 }
885 int displayWidth = FEATURES[i].type.displayWidth;
886 buf.append(StringUtils.center(FEATURES[i].abbrevHeaderRows[1], displayWidth));
887 }
888 buf.append("\n");
889 for (int i=0; i<FEATURES.length; i++) {
890 if ( FEATURES[i].type.equals(UNUSED) ) continue;
891 if ( i>0 ) buf.append(" ");
892 if ( i==INDEX_CUR_TOKEN_TYPE ) {
893 buf.append("| "); // separate prev from current tokens
894 }
895 int displayWidth = FEATURES[i].type.displayWidth;
896 buf.append(StringUtils.center("("+((int)FEATURES[i].mismatchCost)+")", displayWidth));
897 }
898 buf.append("\n");
899 for (int i=0; i<FEATURES.length; i++) {
900 if ( FEATURES[i].type.equals(UNUSED) ) continue;
901 if ( i>0 ) buf.append(" ");
902 if ( i==INDEX_CUR_TOKEN_TYPE ) {
903 buf.append("| "); // separate prev from current tokens
904 }
905 int displayWidth = FEATURES[i].type.displayWidth;
906 buf.append(Tool.sequence(displayWidth, "="));
907 }
908 buf.append("\n");
909 return buf.toString();
910 }
911
912 /** Make an index for fast lookup from Token to tree leaf */
913 public static Map<Token, TerminalNode> indexTree(ParserRuleContext root) {

Callers 3

getVotesBagMethod · 0.95
getPredictionAnalysisMethod · 0.95
computeConsistencyMethod · 0.95

Calls 4

sequenceMethod · 0.95
equalsMethod · 0.65
toStringMethod · 0.65
appendMethod · 0.45

Tested by

no test coverage detected