diff --git a/.gitignore b/.gitignore
index 24d6437..b83d222 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1 @@
-/target/
+/target/
diff --git a/pom.xml b/pom.xml
index 35aac59..7b95928 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,9 +3,9 @@
4.0.0
net.siisise
softlib-abnf
- 1.2.2
- jar
SoftLibABNF
+ 1.2.3
+ jar
Java ABNF parser CC
https://github.com/okomeki/SoftLib
@@ -92,25 +92,25 @@
net.siisise
softlib
- 1.1.8
+ [1.1.8,)
jar
org.junit.jupiter
junit-jupiter-api
- 5.9.1
+ 5.9.2
test
org.junit.jupiter
junit-jupiter-params
- 5.9.1
+ 5.9.2
test
org.junit.jupiter
junit-jupiter-engine
- 5.9.1
+ 5.9.2
test
diff --git a/src/main/java/net/siisise/abnf/ABNF.java b/src/main/java/net/siisise/abnf/ABNF.java
index 82ac8d1..39de880 100644
--- a/src/main/java/net/siisise/abnf/ABNF.java
+++ b/src/main/java/net/siisise/abnf/ABNF.java
@@ -81,7 +81,7 @@ static ABNF binlist(String binlist) {
}
/**
- *
+ * 1文字 Unicodeふる
* @param ch 文字
* @return 文字と一致するABNF
*/
@@ -101,8 +101,8 @@ static ABNFbin bin(String str) {
/**
* (仮)
- * @param b
- * @return
+ * @param b バイト
+ * @return 1バイトのABNF
*/
static ABNFbin bin(byte b) {
return new ABNFbin(new byte[] {b});
@@ -110,8 +110,8 @@ static ABNFbin bin(byte b) {
/**
* (仮)
- * @param bin
- * @return
+ * @param bin バイト列
+ * @return バイト列のABNF
*/
static ABNFbin bin(byte[] bin) {
return new ABNFbin(bin);
@@ -122,17 +122,17 @@ static ABNFbin bin(byte[] bin) {
* utf-8 をデコードするので0x80以上はバイト列と同じではない
* @param min 最小文字コード 0 - 0x10ffff
* @param max 最大文字コード 0 - 0x10ffff
- * @return
+ * @return 文字のABNF
*/
static ABNFrange range(int min, int max) {
return new ABNFrange(min, max);
}
/**
- * 1バイト比較
+ * 1バイト比較.
* @param min 最小コード 0x00 - 0xff
* @param max 最大コード 0x00 - 0xff
- * @return
+ * @return バイトのABNF
*/
static ABNFbinRange binRange(int min, int max) {
return new ABNFbinRange(min, max);
diff --git a/src/main/java/net/siisise/abnf/ABNFbin.java b/src/main/java/net/siisise/abnf/ABNFbin.java
index 58c4e6f..2b4715d 100644
--- a/src/main/java/net/siisise/abnf/ABNFbin.java
+++ b/src/main/java/net/siisise/abnf/ABNFbin.java
@@ -103,29 +103,6 @@ public int ch() {
int ch = CodePoint.utf8(src); // 1文字デコード
return src.length() == 0 ? ch : -1;
}
-/*
- static ABNF range = ABNF5234.ALPHA.or1(ABNF5234.DIGIT);
- static ABNF esc = ABNF5234.DQUOTE.or1(ABNF.range(0x0, 0x1f), ABNF.bin(0x7f));
-
- private String toJavaString(byte[] d) {
- ReadableBlock bl = ReadableBlock.wrap(d);
- StringBuilder sb = new StringBuilder();
- sb.append('"');
- while ( bl.length() > 0 ) {
- ReadableBlock res = esc.is(bl);
- if ( res != null) {
-
- } else {
- int cp = CodePoint.utf8(bl);
- if ( cp >= 0 ) {
- sb.appendCodePoint(cp);
- }
- }
- }
- sb.append('"');
- return sb.toString();
- }
-*/
/**
* @return Javaっぽくする
@@ -145,7 +122,6 @@ public String toJava() {
src.append(",");
}
src.append(toJavaCh(d));
-// src.append("0x").append(Integer.toHexString(((int)d) & 0xff).toUpperCase());
}
src.append("}");
}
diff --git a/src/main/java/net/siisise/abnf/ABNFmap.java b/src/main/java/net/siisise/abnf/ABNFmap.java
index 1f7ff7e..fe2996a 100644
--- a/src/main/java/net/siisise/abnf/ABNFmap.java
+++ b/src/main/java/net/siisise/abnf/ABNFmap.java
@@ -31,17 +31,31 @@ public class ABNFmap extends IsABNF {
private final List map = new ArrayList<>();
public ABNFmap() {
- name = "略";
+ name = "()";
}
public ABNFmap(String val) {
ReadableBlock pac = ReadableBlock.wrap(val);
+ StringBuilder n = new StringBuilder();
+ n.append("( ");
while (pac.size() > 0) {
+ if ( n.length() > 2) {
+ n.append(" / ");
+ }
int ch = CodePoint.utf8(pac);
if (!map.contains(ch)) {
map.add(ch);
+ if ( (ch >= 0x20 && ch <= 0x7e && ch != 0x22) ) {
+ n.append('"');
+ n.append(ch);
+ n.append('"');
+ } else {
+ n.append(hex(ch));
+ }
}
}
+ n.append(" )");
+ name = n.toString();
}
@Override
diff --git a/src/main/java/net/siisise/abnf/ABNFor.java b/src/main/java/net/siisise/abnf/ABNFor.java
index e58e373..425e34d 100644
--- a/src/main/java/net/siisise/abnf/ABNFor.java
+++ b/src/main/java/net/siisise/abnf/ABNFor.java
@@ -72,6 +72,11 @@ public ABNFor(String name, String chlist) {
}
}
+ /**
+ * 名前をつくる.
+ * @param abnfs
+ * @return
+ */
static String toName(BNF[] abnfs) {
StringBuilder sb = new StringBuilder();
//if ( list.length > 1) {
diff --git a/src/main/java/net/siisise/bnf/AbstractBNF.java b/src/main/java/net/siisise/bnf/AbstractBNF.java
index 7a13118..89ab465 100644
--- a/src/main/java/net/siisise/bnf/AbstractBNF.java
+++ b/src/main/java/net/siisise/bnf/AbstractBNF.java
@@ -332,7 +332,7 @@ protected static void mix(Match ret, Match sub) {
* @return っぽく
*/
protected String hex(int ch) {
- if (ch < 0x100) {
+ if (ch < 0x80) { // 文字としては 0x80以降は4桁にしておきたい
return "%x" + Integer.toHexString(0x100 + ch).substring(1);
} else if (ch < 0x10000) {
return "%x" + Integer.toHexString(0x10000 + ch).substring(1);
diff --git a/src/main/java/net/siisise/bnf/BNFCC.java b/src/main/java/net/siisise/bnf/BNFCC.java
index 6aebe44..3357de9 100644
--- a/src/main/java/net/siisise/bnf/BNFCC.java
+++ b/src/main/java/net/siisise/bnf/BNFCC.java
@@ -62,7 +62,7 @@ public static BNFCC abnf2bnf(BNFReg up) {
/**
* ABNF用
* @param BNFが無難
- * @param up
+ * @param up 取り込む定義
* @param cc ABNF5234.REG など
* @return ABNFが使えるよ
*/