Skip to content

Commit a1fee95

Browse files
committed
Compiler implementation
1 parent e908f3f commit a1fee95

322 files changed

Lines changed: 9365 additions & 1735 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
name: Publish release
2-
32
on:
43
release:
54
types: [published]
6-
75
jobs:
86
build:
97
runs-on: ubuntu-latest
10-
118
steps:
129
- uses: actions/checkout@v3
1310
- name: Set up JDK 21
@@ -25,15 +22,21 @@ jobs:
2522
with:
2623
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
2724
passphrase: ${{ secrets.GPG_PASSPHRASE }}
28-
- name: Release build deploy
25+
- name: Publish runtime to Maven Central
2926
env:
3027
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
3128
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
32-
run:
33-
./gradlew clean publish -Prelease -Psigning.gnupg.keyId=${{ secrets.GPG_KEYID }} -Psigning.gnupg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Psigning.gnupg.keyName=${{ secrets.GPG_KEYID }}
34-
- name: Trigger manual upload to Central Repository
3529
run: |
36-
curl -X POST \
37-
-H "Authorization: Bearer $(echo -n '${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}' | base64)" \
38-
-H "Content-Type: application/json" \
39-
https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.bladecoder
30+
./gradlew :runtime:clean :runtime:publish -Prelease \
31+
-Psigning.gnupg.keyId=${{ secrets.GPG_KEYID }} \
32+
-Psigning.gnupg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
33+
-Psigning.gnupg.keyName=${{ secrets.GPG_KEYID }}
34+
- name: Publish compiler to Maven Central
35+
env:
36+
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
37+
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
38+
run: |
39+
./gradlew :compiler:clean :compiler:publish -Prelease \
40+
-Psigning.gnupg.keyId=${{ secrets.GPG_KEYID }} \
41+
-Psigning.gnupg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
42+
-Psigning.gnupg.keyName=${{ secrets.GPG_KEYID }}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
name: Publish snapshot
2-
32
on:
43
push:
54
branches:
65
- master
76
jobs:
87
build:
9-
108
runs-on: ubuntu-latest
11-
129
steps:
1310
- uses: actions/checkout@v3
1411
- name: Set up JDK 21
@@ -20,8 +17,13 @@ jobs:
2017
run: chmod +x gradlew
2118
- name: Build
2219
run: ./gradlew build
23-
- name: Publish snapshot
20+
- name: Publish runtime snapshot
2421
env:
2522
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
2623
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
27-
run: ./gradlew publish
24+
run: ./gradlew :runtime:publish
25+
- name: Publish compiler snapshot
26+
env:
27+
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
28+
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
29+
run: ./gradlew :compiler:publish

build.gradle

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,103 @@
1-
allprojects {
1+
plugins {
2+
id "com.diffplug.spotless" version "7.2.1" apply false
3+
}
4+
5+
// Configuración común para todos los subproyectos
6+
subprojects {
7+
apply plugin: 'java-library'
8+
apply plugin: 'maven-publish'
9+
apply plugin: 'signing'
10+
apply plugin: 'com.diffplug.spotless'
11+
212
group = 'com.bladecoder.ink'
13+
14+
sourceCompatibility = 1.8
15+
targetCompatibility = 1.8
16+
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
17+
18+
repositories {
19+
mavenCentral()
20+
}
21+
22+
dependencies {
23+
testImplementation 'junit:junit:4.13'
24+
}
25+
26+
if (!hasProperty("release") && !version.endsWith("-SNAPSHOT")) {
27+
version += "-SNAPSHOT"
28+
}
29+
30+
// DISABLES JAVADOC ULTRACHECKS IN JDK8
31+
if (JavaVersion.current().isJava8Compatible()) {
32+
tasks.withType(Javadoc) {
33+
options.addStringOption('Xdoclint:none', '-quiet')
34+
}
35+
}
36+
37+
spotless {
38+
java {
39+
target fileTree('src') {
40+
include '**/*.java'
41+
}
42+
toggleOffOn()
43+
palantirJavaFormat()
44+
removeUnusedImports()
45+
trimTrailingWhitespace()
46+
endWithNewline()
47+
}
48+
}
49+
50+
jar {
51+
manifest.attributes += [
52+
'github' : 'https://github.com/bladecoder/blade-ink/',
53+
'license' : 'Apache-2.0',
54+
'group' : project.group,
55+
'version' : project.version,
56+
'java' : targetCompatibility,
57+
'timestamp': System.currentTimeMillis()
58+
]
59+
}
60+
61+
javadoc {
62+
options {
63+
memberLevel = JavadocMemberLevel.PUBLIC
64+
author true
65+
setUse true
66+
encoding "UTF-8"
67+
}
68+
if (JavaVersion.current().isJava9Compatible()) {
69+
options.addBooleanOption('html5', true)
70+
}
71+
}
72+
73+
task sourcesJar(type: Jar) {
74+
from sourceSets.main.allJava
75+
archiveClassifier = 'sources'
76+
}
77+
78+
task javadocJar(type: Jar) {
79+
from javadoc
80+
archiveClassifier = 'javadoc'
81+
}
82+
83+
publishing {
84+
repositories {
85+
maven {
86+
def releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
87+
def snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/"
88+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
89+
credentials {
90+
username project.hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "$System.env.NEXUS_USERNAME"
91+
password project.hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "$System.env.NEXUS_PASSWORD"
92+
}
93+
}
94+
}
95+
}
96+
97+
signing {
98+
if (!version.endsWith('SNAPSHOT')) {
99+
useGpgCmd()
100+
sign publishing.publications.mavenJava
101+
}
102+
}
3103
}

compiler/build.gradle

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,47 @@
1-
plugins {
2-
id 'java-library'
1+
dependencies {
2+
implementation project(':runtime')
33
}
4-
5-
sourceCompatibility = 1.8
6-
targetCompatibility = 1.8
7-
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
8-
9-
repositories {
10-
mavenCentral()
4+
javadoc {
5+
title = "Blade Ink Compiler"
116
}
12-
13-
// add runtime dependency
14-
dependencies {
15-
implementation project(":runtime")
16-
17-
testImplementation 'junit:junit:4.13.1'
7+
publishing {
8+
publications {
9+
mavenJava(MavenPublication) {
10+
artifactId = 'blade-ink-compiler'
11+
from components.java
12+
artifact sourcesJar
13+
artifact javadocJar
14+
versionMapping {
15+
usage('java-api') {
16+
fromResolutionOf('runtimeClasspath')
17+
}
18+
usage('java-runtime') {
19+
fromResolutionResult()
20+
}
21+
}
22+
pom {
23+
name = 'blade-ink-compiler'
24+
description = "Compiler for inkle's ink scripting language. Converts .ink files to JSON format."
25+
url = 'https://github.com/bladecoder/blade-ink'
26+
licenses {
27+
license {
28+
name = 'The Apache License, Version 2.0'
29+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
30+
}
31+
}
32+
developers {
33+
developer {
34+
id = 'bladecoder'
35+
name = 'Rafael Garcia'
36+
email = 'bladecoder@gmail.com'
37+
}
38+
}
39+
scm {
40+
connection = 'scm:git@github.com:bladecoder/blade-ink-java.git'
41+
developerConnection = 'scm:git@github.com:bladecoder/blade-ink-java.git'
42+
url = 'scm:git@github.com:bladecoder/blade-ink-java.git'
43+
}
44+
}
45+
}
46+
}
1847
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.bladecoder.ink.compiler;
2+
3+
import java.util.Collection;
4+
import java.util.HashSet;
5+
6+
public final class CharacterRange {
7+
public static CharacterRange define(char start, char end) {
8+
return new CharacterRange(start, end, null);
9+
}
10+
11+
public static CharacterRange define(char start, char end, Collection<Character> excludes) {
12+
return new CharacterRange(start, end, excludes);
13+
}
14+
15+
public CharacterSet toCharacterSet() {
16+
if (_correspondingCharSet.isEmpty()) {
17+
for (char c = _start; c <= _end; c++) {
18+
if (!_excludes.contains(c)) {
19+
_correspondingCharSet.add(c);
20+
}
21+
}
22+
}
23+
return _correspondingCharSet;
24+
}
25+
26+
public char getStart() {
27+
return _start;
28+
}
29+
30+
public char getEnd() {
31+
return _end;
32+
}
33+
34+
private CharacterRange(char start, char end, Collection<Character> excludes) {
35+
_start = start;
36+
_end = end;
37+
_excludes = excludes == null ? new HashSet<>() : new HashSet<>(excludes);
38+
}
39+
40+
private final char _start;
41+
private final char _end;
42+
private final Collection<Character> _excludes;
43+
private final CharacterSet _correspondingCharSet = new CharacterSet();
44+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.bladecoder.ink.compiler;
2+
3+
import java.util.Collection;
4+
import java.util.HashSet;
5+
6+
public class CharacterSet extends HashSet<Character> {
7+
public static CharacterSet fromRange(char start, char end) {
8+
return new CharacterSet().addRange(start, end);
9+
}
10+
11+
public CharacterSet() {}
12+
13+
public CharacterSet(String str) {
14+
addCharacters(str);
15+
}
16+
17+
public CharacterSet(CharacterSet charSetToCopy) {
18+
addCharacters(charSetToCopy);
19+
}
20+
21+
public CharacterSet addRange(char start, char end) {
22+
for (char c = start; c <= end; ++c) {
23+
add(c);
24+
}
25+
return this;
26+
}
27+
28+
public CharacterSet addCharacters(Collection<Character> chars) {
29+
for (char c : chars) {
30+
add(c);
31+
}
32+
return this;
33+
}
34+
35+
public CharacterSet addCharacters(String chars) {
36+
for (char c : chars.toCharArray()) {
37+
add(c);
38+
}
39+
return this;
40+
}
41+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.bladecoder.ink.compiler;
2+
3+
public class CommandLineInput {
4+
public boolean isHelp;
5+
public boolean isExit;
6+
public Integer choiceInput;
7+
public Integer debugSource;
8+
public String debugPathLookup;
9+
public Object userImmediateModeStatement;
10+
}

0 commit comments

Comments
 (0)