Skip to content

Commit

Permalink
Central build対応 pom修正
Browse files Browse the repository at this point in the history
javadoc出力用修正
READMEなおし
  • Loading branch information
okomeki committed Jan 21, 2022
1 parent 9bdf0a1 commit 57ae1fc
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 70 deletions.
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# てきとーな ABNF ライブラリ
# SoftLibABNF Augumented BNF ライブラリ

Twitter @okomeki

## 概要

ABNFによるABNFのためのABNF
ABNFによるABNFのためのABNF parser または JavaCCのように ABNF compiler compiler と呼べばいいのかよくわからないもの

とりあえず作ってみたので公開する
RFC 5234 ABNF、RFC 7405の拡張を実装したもの

Expand All @@ -13,7 +14,7 @@ https://siisise.net/abnf.html せつめい
### 何ができるのか?

ABNFのパース、一致判定
rule単位でのパーサの埋め込み
rule単位での parser? builder? の埋め込み
メールアドレスの判定がしたい
URLの解析がしたい
IPv6アドレスの(以下同文)
Expand All @@ -25,8 +26,8 @@ rule単位でのパーサの埋め込み
- 機能1 ABNF Parser
- 機能2 ABNF 比較/一致判定とか
- 機能3 実体参照、名前参照(循環参照)対応
- 機能4 rule単位のパーサ埋め込み
- 例 JSON,JSON Pointerなどの実装
- 機能4 rule単位の builder 埋め込み
- 例 JSON parser,JSON Pointerなどの実装

とりあえずサンプル net.siisise.abnf.parser5234.ABNF5234.java がABNF Parserの本体でありサンプルであるかもしれません。

Expand All @@ -42,7 +43,7 @@ RFC 5234 の 4.ABNFのABNFによる定義から
static final ABNF rulelist = REG.rule( "rulelist = 1*( rule / (*c-wsp c-nl) )");
}

とりあえずこれでよいです。未定義のruleなども次の行に続けて定義していけば全体が完成します
とりあえずこれでよいです。未定義のruleやc-wspなども使えるので後の行に定義していけば全体が完成します

static final ABNF rulelist = REG.rule( "rulelist", "1*( rule / (*c-wsp c-nl) )");

Expand All @@ -55,11 +56,11 @@ RFC 5234 の 4.ABNFのABNFによる定義から

その他、ABNFとABNFRegをみれば何とかなるのかも。

## 演算子
## 演算子 Operators

3.演算子のものをJavaで書く手法です。不明であればABNFでも書けます。

### 連接 Rule1 Rule2 #pl(複数)
### 連接 Concatenation: Rule1 Rule2 #pl(複数)

foo = %x61 ; a
bar = %x62 ; b
Expand All @@ -70,36 +71,37 @@ RFC 5234 の 4.ABNFのABNFによる定義から
ABNF mumble = REG.rule("mumble", foo.pl(bar, foo));

パース手法の違いで pl , plm , plu などがある。繰り返しを厳密に判定するなら plm や plu がいいのだが違いはまた別途。
plu : unicode base

### 選択肢 Rule1 / Rule2 #or(複数)
### 選択肢 Alternatives: Rule1 / Rule2 #or(複数)

foo / bar
foo / bar / baz
ora = foo / bar
orb = foo / bar / baz

foo.or( bar )
foo.or( bar. baz )
ABNF ora = REG.rule("ora", foo.or( bar ) );
ABNF orb = REG.rule("orb", foo.or( bar. baz ) );

### 増分選択肢 Rule1 =/ Rule2 #or(複数)
### 増分選択肢 Incremental Alternatives: Rule1 =/ Rule2 #or(複数)

ABNF oldrule = REG.rule( "oldrule", oldrule.or( additionalAlternatives ) ); // 特に定義なし

REG.rule() または #name(String)を通さないと名前はつかない。

### 範囲選択肢 %c##-##
### 範囲選択肢 Value Range Alternatives: %c##-##

DIGIT = %x30-39

ABNF digit = REG.rule("digit", ABNF.range(0x30, 0x39));

### 並びグループ
### 並びグループ Sequence Group:

elem (foo / bar) blat
elem foo / bar blat

elem.pl( foo.or( bar ), blat )
elem.pl(foo).or(bar.pl(blat))

### 可変回数反復 *Rule
### 可変回数反復 Variable Repetition: *Rule

<a>*<b>element

Expand All @@ -108,13 +110,13 @@ REG.rule() または #name(String)を通さないと名前はつかない。
element.x() // a,bの省略 *element
値で省略する場合、a = 0, b = -1 と少々複雑

### 特定回数反復 nRule
### 特定回数反復 Specific Repetition: nRule

<n>element

element.x(n)

### 省略可能並び: [Rule]
### 省略可能並び Optional Sequence: [Rule]

[foo bar]

Expand Down
82 changes: 74 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,87 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.siisise</groupId>
<artifactId>softlib-abnf</artifactId>
<name>SoftLibABNF</name>
<version>1.1.3-SNAPSHOT</version>
<version>1.1.3</version>
<packaging>jar</packaging>
<name>SoftLibABNF</name>
<description>Java ABNF parser CC</description>
<url>https://github.com/okomeki/SoftLib</url>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/license/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>SATO Masatoshi</name>
<email>okome@siisise.net</email>
<organization>Siisise Net</organization>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/okomeki/SoftLibABNF.git</connection>
<developerConnection>scm:git:ssh://github.com/okomeki/SoftLibABNF.git</developerConnection>
<url>https://github.com/okomeki/SoftLibABNF/tree/master</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<showDeprecation>true</showDeprecation>
</configuration>
<version>3.9.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<source>1.9</source>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
Expand All @@ -30,7 +92,7 @@
<dependency>
<groupId>net.siisise</groupId>
<artifactId>softlib</artifactId>
<version>1.1.3-SNAPSHOT</version>
<version>1.1.4</version>
<type>jar</type>
</dependency>
<dependency>
Expand All @@ -53,6 +115,10 @@
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>github</id>
<name>GitHub okomeki Apache Maven SoftLib Packages</name>
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/net/siisise/abnf/ABNF.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ static ABNF list(String chlist) {
/**
* どれかの文字に一致するかな
*
* @param binlist
* @return
* @param binlist バイト列的な文字列
* @return どれかが含まれるABNF構文
*/
static ABNF binlist(String binlist) {
return new ABNFmap(binlist);
}

/**
*
* @param ch 文字
* @return 文字と一致するABNF
*/
static ABNFbin bin(int ch) {
return new ABNFbin(ch);
}
Expand All @@ -68,7 +73,7 @@ static ABNFbin bin(int ch) {
* 文字列/文字との比較
*
* @param str utf-8で一致文字列
* @return
* @return 一致するABNF
*/
static ABNFbin bin(String str) {
return new ABNFbin(str);
Expand Down Expand Up @@ -111,8 +116,9 @@ static ABNFrange range(int min, int max) {
* マイナス演算
* ABNFにはないので仮
*
* @param val
* @return
* @deprecated 未定
* @param val 引かれるABNF
* @return 引き算できるABNF
*/
ABNF mn(ABNF val);

Expand All @@ -130,7 +136,7 @@ static ABNFrange range(int min, int max) {
*
* @param min 指定しない場合は 0
* @param max 指定しない場合は -1
* @return
* @return 繰り返しのABNF
*/
ABNF x(int min, int max);

Expand All @@ -145,7 +151,7 @@ static ABNFrange range(int min, int max) {
* 1回以上ループ
* 1*XXX
*
* @return
* @return 1回以上繰り返しのABNF
*/
ABNF ix();

Expand Down Expand Up @@ -177,7 +183,7 @@ static ABNFrange range(int min, int max) {
* 複製可能な構造を推奨(ループがあると複製は難しい)
*
* @param reg 複製もと
* @return
* @return ABNFの複製
*/
ABNF copy(ABNFReg reg);
}
2 changes: 1 addition & 1 deletion src/main/java/net/siisise/abnf/ABNFbin.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ABNFbin copy(ABNFReg reg) {
*
* @deprecated ABNFmap に移行かな
* @param val 文字の一括登録
* @return
* @return 1文字単位で比較するorっぽいABNF
*/
public static ABNF list(String val) {
FrontPacket src = pac(val);
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/net/siisise/abnf/AbstractABNF.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ public ABNF name(String name) {
}

/**
* Concatenation の単純版
* *(a / b ) a の様なものが解析できないが速そう
* @param val
* @return
* @param val plus する ABNF列
* @return 簡易に比較するABNF
*/
@Override
public ABNF pl(ABNF... val) {
Expand All @@ -29,9 +30,10 @@ public ABNF pl(ABNF... val) {
}

/**
* やや厳密に対応する足し算版
* *( a / b ) a にも対応
* @param val
* @return
* @param val plus する ABNF列
* @return 厳密に比較できるABNF
*/
@Override
public ABNF plm(ABNF... val) {
Expand All @@ -46,8 +48,8 @@ public ABNF plm(ABNF... val) {

/**
* Unicode単位で比較する若干速いのかもしれない版 plm
* @param val
* @return
* @param val plus する ABNF列
* @return unicodeで比較されるABNF処理
*/
@Override
public ABNF plu(ABNF... val) {
Expand All @@ -73,10 +75,10 @@ public ABNF or(ABNF... val) {
}

/**
*
* @param <X>
* @param ret
* @param sub
* 結果2を1に混ぜる
* @param <X> 戻り型
* @param ret 結果1
* @param sub 結果2
*/
static <X> void mix(C<X> ret, C<X> sub) {
ret.ret.write(sub.ret.toByteArray());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/siisise/abnf/FindABNF.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public <X> C<X> find(FrontPacket pac, BNFParser<? extends X>... parsers) {
/**
* 詰め方の工夫をするターン
*
* @param <X>
* @param pac
* @param ns
* @param parsers
* @return
* @param <X> 戻り型
* @param pac 入りデータ
* @param ns name space
* @param parsers サブ要素のパーサー
* @return パース結果
*/
@Override
public <X,N> C<X> find(FrontPacket pac, N ns, BNFParser<? extends X>... parsers) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/siisise/abnf/IsABNF.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public <N> Packet is(FrontPacket pac, N ns) {

/**
* sub要素のない場合の軽い対応
* @param <X>
* @param pac
* @param ns
* @param parsers
* @return
* @param <X> パラメータっぽい型
* @param pac 解析データ
* @param ns name space
* @param parsers サブ要素のparser
* @return 処理結果
*/
@Override
public <X,N> C<X> find(FrontPacket pac, N ns, BNFParser<? extends X>... parsers) {
Expand Down
Loading

0 comments on commit 57ae1fc

Please sign in to comment.