Skip to content

Commit 0329871

Browse files
authored
Merge pull request #1 from umjammer/0.0.1
0.0.1
2 parents dccd1e5 + 774b33e commit 0329871

File tree

8 files changed

+64
-104
lines changed

8 files changed

+64
-104
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,11 @@ jobs:
3030

3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v2
34-
with:
35-
# We must fetch at least the immediate parents so that if this is
36-
# a pull request then we can checkout the head.
37-
fetch-depth: 2
38-
39-
# If this run was triggered by a pull request event, then checkout
40-
# the head of the pull request instead of the merge commit.
41-
- run: git checkout HEAD
42-
if: ${{ github.event_name == 'pull_request' }}
33+
uses: actions/checkout@v3
4334

4435
# Initializes the CodeQL tools for scanning.
4536
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
37+
uses: github/codeql-action/init@v2
4738
with:
4839
languages: ${{ matrix.language }}
4940
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -61,9 +52,8 @@ jobs:
6152
# and modify them (or add more) to build your code if your project
6253
# uses a compiled language
6354

64-
- name: Autobuild
65-
run: |
66-
mvn -B install --file pom.xml
55+
- name: Build with Maven
56+
run: mvn -B install --file pom.xml
6757

6858
- name: Perform CodeQL Analysis
69-
uses: github/codeql-action/analyze@v1
59+
uses: github/codeql-action/analyze@v2

.github/workflows/maven.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ jobs:
88
runs-on: macos-latest
99

1010
steps:
11-
- uses: actions/checkout@v1
12-
- name: Set up JDK 1.8
13-
uses: actions/setup-java@v1
14-
with:
15-
java-version: 1.8
16-
- name: Build with Maven
17-
run: |
18-
mvn -B package --file pom.xml
11+
- name: Checkout repository
12+
uses: actions/checkout@v3
13+
14+
- name: Check w/o SNAPSHOT when "bump version"
15+
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
16+
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT
17+
18+
- name: Set up JDK 8
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '8'
22+
distribution: 'temurin'
23+
cache: maven
24+
25+
- name: Build with Maven
26+
run: mvn -B package --file pom.xml

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ basic language collection as jsr223
3737
* https://github.com/mayuropensource/PuffinBASIC
3838
* https://github.com/EgonOlsen71/basicv2
3939
* https://github.com/namazu510/basic-interpreter
40+
* http://www.kiwi-us.com/~ohta/pc88/kanji/
4041

4142
## TODO
4243

pom.xml

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>vavi</groupId>
55
<artifactId>vavi-script-basic</artifactId>
6-
<version>0.0.1-SNAPSHOT</version>
6+
<version>0.0.1</version>
77

88
<build>
99
<plugins>
@@ -18,54 +18,6 @@
1818
</configuration>
1919
</plugin>
2020

21-
<plugin>
22-
<groupId>org.codehaus.mojo</groupId>
23-
<artifactId>native-maven-plugin</artifactId>
24-
<version>1.0-alpha-11</version>
25-
<extensions>true</extensions>
26-
<configuration>
27-
<javahOS>darwin</javahOS>
28-
<compilerProvider>generic-classic</compilerProvider>
29-
<compilerStartOptions>
30-
<compilerStartOption>-g -Wall -O2 -fomit-frame-pointer -fPIC</compilerStartOption>
31-
<!-- unless locating jdk includes, cause error why??? -->
32-
<compilerStartOption>-arch x86_64
33-
-I${java.home}/../include
34-
-I${java.home}/../include/darwin
35-
-I.
36-
</compilerStartOption>
37-
</compilerStartOptions>
38-
<sources>
39-
<source>
40-
<directory>src/test/native</directory>
41-
<fileNames>
42-
<fileName>test.m</fileName>
43-
</fileNames>
44-
</source>
45-
</sources>
46-
<linkerStartOptions>
47-
<linkerStartOption>-arch x86_64
48-
-lobjc -framework Foundation -framework JavaNativeFoundation
49-
-ljvm -L${java.home}/../jre/lib/server
50-
</linkerStartOption>
51-
</linkerStartOptions>
52-
<linkerFinalName/>
53-
<linkerEndOptions>
54-
<linkerEndOption>-o ${project.build.directory}/jvmtest</linkerEndOption>
55-
</linkerEndOptions>
56-
</configuration>
57-
<executions>
58-
<execution>
59-
<id>compile-pvorbis</id>
60-
<phase>compile</phase>
61-
<goals>
62-
<goal>compile</goal>
63-
<goal>link</goal>
64-
</goals>
65-
</execution>
66-
</executions>
67-
</plugin>
68-
6921
<plugin>
7022
<groupId>org.apache.maven.plugins</groupId>
7123
<artifactId>maven-surefire-plugin</artifactId>
@@ -92,7 +44,7 @@
9244
<dependency>
9345
<groupId>org.junit</groupId>
9446
<artifactId>junit-bom</artifactId>
95-
<version>5.8.2</version>
47+
<version>5.9.1</version>
9648
<type>pom</type>
9749
<scope>import</scope>
9850
</dependency>
@@ -103,7 +55,7 @@
10355
<dependency>
10456
<groupId>com.github.umjammer</groupId>
10557
<artifactId>vavi-commons</artifactId>
106-
<version>1.1.6</version>
58+
<version>1.1.8</version>
10759
</dependency>
10860

10961
<dependency>

src/test/java/Main2.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,50 @@
88
import java.nio.file.Files;
99
import java.nio.file.Path;
1010
import java.nio.file.Paths;
11-
import java.util.Arrays;
1211
import java.util.stream.IntStream;
1312

13+
import org.junit.jupiter.api.Disabled;
14+
import org.junit.jupiter.api.DisplayName;
1415
import org.junit.jupiter.api.Test;
1516
import vavi.util.Debug;
1617

1718

1819
/**
19-
* Main1.
20+
* Main2.
2021
*
2122
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (umjammer)
2223
* @version 0.00 2022/03/02 umjammer initial version <br>
2324
*/
2425
public class Main2 {
2526

2627
@Test
28+
@DisplayName("convert n-basic")
2729
void test1() throws Exception {
2830
main(new String[] {});
2931
}
3032

3133
@Test
34+
@Disabled("create properties for n-basic")
3235
void test3() throws Exception {
33-
IntStream.range(0, NBasicBin2Text2.keywordsBase.length).forEach(i ->
34-
System.err.printf("%02X=%s%n", 0x81 + i, NBasicBin2Text2.keywordsBase[i]));
35-
IntStream.range(0, NBasicBin2Text2.keywordsFF.length).forEach(i ->
36-
System.err.printf("FF_%02X=%s%n", 0x81 + i, NBasicBin2Text2.keywordsFF[i]));
36+
IntStream.range(0, NBasicBin2Ascii.keywordsBase.length).forEach(i ->
37+
System.err.printf("%02X=%s%n", 0x81 + i, NBasicBin2Ascii.keywordsBase[i]));
38+
IntStream.range(0, NBasicBin2Ascii.keywordsFF.length).forEach(i ->
39+
System.err.printf("FF_%02X=%s%n", 0x81 + i, NBasicBin2Ascii.keywordsFF[i]));
3740
}
3841

3942
@Test
43+
@DisplayName("convert n88-basic")
4044
void test2() throws Exception {
41-
Test1.main(new String[] {"src/test/resources/grph3d.bas"});
45+
N88BasicBin2Ascii.main(new String[] {"src/test/resources/grph3d.bas"});
4246
}
4347

4448
/**
45-
* @param args
49+
* run n-basic converter
4650
*/
4751
public static void main(String[] args) throws Exception {
4852
Path p = Paths.get(Main2.class.getResource("/grph3d.bas").toURI());
4953

50-
NBasicBin2Text2 covetrer = new NBasicBin2Text2();
54+
NBasicBin2Ascii covetrer = new NBasicBin2Ascii();
5155
try {
5256
covetrer.convert(Files.newInputStream(p), System.out);
5357
} catch (EOFException e) {

src/test/java/Test1.java renamed to src/test/java/N88BasicBin2Ascii.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,31 @@
1616

1717

1818
/**
19-
* N88-BASIC 中間コードファイルをアスキーに変換
19+
* convert N88-BASIC(86) middle code file to ascii file.
2020
* <p>
2121
* TODO space between keyword and keyword
2222
*
2323
* @author @kishi24
2424
* @version 2022/06/10 ver.1.6.1
2525
*/
26-
public class Test1 {
26+
public class N88BasicBin2Ascii {
2727

28+
/** */
2829
static int offset = 0;
2930

31+
/** */
3032
static final Properties data = new Properties();
3133

3234
static {
3335
try {
3436
// TODO we need to change table for n80, n88, n88(86)
35-
data.load(Test1.class.getResourceAsStream("/n98.properties"));
37+
data.load(N88BasicBin2Ascii.class.getResourceAsStream("/n98.properties"));
3638
} catch (IOException e) {
3739
throw new UncheckedIOException(e);
3840
}
3941
}
42+
43+
/** */
4044
static String read_4byte(LittleEndianDataInputStream file) throws IOException {
4145
int one = file.readUnsignedByte();
4246
int two = file.readUnsignedByte();
@@ -47,11 +51,11 @@ static String read_4byte(LittleEndianDataInputStream file) throws IOException {
4751
return "0";
4852
}
4953

50-
// 仮数部の処理
54+
// process mantissa
5155
String kasu = String.format("%02x%02x%02x", three, two, one);
5256
String frac = Integer.toBinaryString(Integer.parseInt(kasu, 16));
5357

54-
// to_s(2) による桁落ちを補正
58+
// adjust precision loss by to_s(2)
5559
if (24 > frac.length()) {
5660
int m = 24 - frac.length();
5761
for (int i = 0; i < m; i++) {
@@ -68,7 +72,7 @@ static String read_4byte(LittleEndianDataInputStream file) throws IOException {
6872
frac = '1' + frac.substring(1);
6973
}
7074

71-
// 0b から実数へ変換
75+
// convert to real number from 0b
7276
double num = 0.0;
7377
for (int i = 0; i <= 22; i++) {
7478
if ('1' == frac.charAt(i)) {
@@ -77,7 +81,7 @@ static String read_4byte(LittleEndianDataInputStream file) throws IOException {
7781
}
7882
num = num * Math.pow(2, e);
7983

80-
// 有効桁 7 におさめて行末の 0 を削除
84+
// round significant 7 digits and trim trailer 0
8185
String[] data2 = String.valueOf(num).split("\\.");
8286
if (data2[1].matches("^0+$")) {
8387
return (sign ? "-" : "") + data2[0] + "!";
@@ -99,6 +103,7 @@ static String read_4byte(LittleEndianDataInputStream file) throws IOException {
99103
return num2;
100104
}
101105

106+
/** */
102107
static String read_8byte(LittleEndianDataInputStream file) throws IOException {
103108
int one = file.readUnsignedByte();
104109
int two = file.readUnsignedByte();
@@ -154,6 +159,9 @@ static String read_8byte(LittleEndianDataInputStream file) throws IOException {
154159
return num2;
155160
}
156161

162+
/**
163+
* @param args 0: basic file
164+
*/
157165
public static void main(String[] args) throws IOException {
158166

159167
String file = args[0];

src/test/java/NBasicBin2Text2.java renamed to src/test/java/NBasicBin2Ascii.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
import java.nio.file.Files;
1212
import java.nio.file.Paths;
1313

14-
15-
public class NBasicBin2Text2 {
14+
/**
15+
* N-Basic.
16+
*
17+
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (nsano)
18+
* @version 0.00 2022/03/03 nsano initial version <br>
19+
*/
20+
public class NBasicBin2Ascii {
1621

1722
static final String[] keywordsBase = {
1823
"END", "FOR", "NEXT", "DATA", "INPUT", "DIM", "READ", "LET", "GOTO", "RUN", "IF", "RESTORE", "GOSUB", "RETURN", "REM",
@@ -56,7 +61,7 @@ private static void usage() {
5661

5762
public static void main(String[] args) throws IOException {
5863

59-
NBasicBin2Text2 app = new NBasicBin2Text2();
64+
NBasicBin2Ascii app = new NBasicBin2Ascii();
6065

6166
String srcFileName = null;
6267
String dstFileName = null;

src/test/resources/logging.properties

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
handlers=java.util.logging.ConsoleHandler
22
.level=INFO
3-
# Limit the message that are printed on the console to INFO and above.
43
java.util.logging.ConsoleHandler.level=ALL
5-
#java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
6-
# %1:date/time %2:className and methodName %3logName %4:level %5:message %6:errormessage
7-
#java.util.logging.SimpleFormatter.format=%1$tY/%1$tm/%1$td %1$tH:%1$tM:%1$tS.%1$tL [%4$s] %5$s %6$s%n
8-
9-
# HttpUrlConnection
10-
#java.util.logging.ConsoleHandler.level=ALL
11-
#sun.net.www.protocol.http.HttpURLConnection.level=ALL
12-
org.rococoa.level=ALL
13-
144
java.util.logging.ConsoleHandler.formatter=vavi.util.logging.VaviFormatter
15-
#java.util.logging.ConsoleHandler.formatter=vavi.util.logging.BetterFormatter
5+
6+
#vavi.util.level=FINE
7+
org.rococoa.level=FINEST

0 commit comments

Comments
 (0)