Skip to content

Commit

Permalink
proj: move more to fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Dec 13, 2023
1 parent 09490b8 commit 73e206d
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 26 deletions.
2 changes: 2 additions & 0 deletions base/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
requires transitive aya.md;
requires transitive aya.pretty;
requires transitive aya.util;
requires transitive aya.util.kala;
requires transitive aya.guest.cubical;
requires transitive kala.base;
requires transitive kala.collection;
Expand All @@ -15,6 +16,7 @@
exports org.aya.concrete.error;
exports org.aya.concrete.remark;
exports org.aya.concrete.stmt.decl;

exports org.aya.concrete.stmt;
exports org.aya.concrete.visitor;
exports org.aya.concrete;
Expand Down
4 changes: 2 additions & 2 deletions base/src/main/java/org/aya/concrete/Expr.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.aya.resolve.visitor.ExprResolver;
import org.aya.resolve.visitor.StmtShallowResolver;
import org.aya.tyck.Result;
import org.aya.util.BinOpElem;
import org.aya.util.ForLSP;
import org.aya.util.binop.BinOpParser;
import org.aya.util.error.SourceNode;
import org.aya.util.error.SourcePos;
import org.aya.util.error.WithPos;
Expand Down Expand Up @@ -158,7 +158,7 @@ record App(
* @author AustinZhu
*/
record NamedArg(@Override boolean explicit, @Nullable String name, @Override @NotNull Expr term)
implements AyaDocile, SourceNode, BinOpParser.Elem<Expr> {
implements AyaDocile, SourceNode, BinOpElem<Expr> {

public NamedArg(boolean explicit, @NotNull Expr expr) {
this(explicit, null, expr);
Expand Down
12 changes: 6 additions & 6 deletions base/src/main/java/org/aya/prettier/BasePrettier.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.aya.ref.DefVar;
import org.aya.ref.LocalVar;
import org.aya.util.Arg;
import org.aya.util.BinOpElem;
import org.aya.util.binop.Assoc;
import org.aya.util.binop.BinOpParser;
import org.aya.util.prettier.PrettierOptions;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -76,7 +76,7 @@ protected BasePrettier(@NotNull PrettierOptions options) {

public @NotNull Doc visitCalls(
@Nullable Assoc assoc, @NotNull Doc fn,
@NotNull SeqView<? extends BinOpParser.@NotNull Elem<Term>> args,
@NotNull SeqView<? extends @NotNull BinOpElem<Term>> args,
@NotNull Outer outer, boolean showImplicits
) {
return visitCalls(assoc, fn, this::term, outer, args, showImplicits);
Expand Down Expand Up @@ -109,9 +109,9 @@ protected BasePrettier(@NotNull PrettierOptions options) {
*/
<T extends AyaDocile> @NotNull Doc visitCalls(
@Nullable Assoc assoc, @NotNull Doc fn, @NotNull Fmt<T> fmt, Outer outer,
@NotNull SeqView<? extends BinOpParser.@NotNull Elem<@NotNull T>> args, boolean showImplicits
@NotNull SeqView<? extends @NotNull BinOpElem<@NotNull T>> args, boolean showImplicits
) {
var visibleArgs = (showImplicits ? args : args.filter(BinOpParser.Elem::explicit)).toImmutableSeq();
var visibleArgs = (showImplicits ? args : args.filter(BinOpElem::explicit)).toImmutableSeq();
if (visibleArgs.isEmpty()) return assoc != null ? Doc.parened(fn) : fn;
if (assoc != null) {
var firstArg = visibleArgs.getFirst();
Expand All @@ -137,14 +137,14 @@ protected BasePrettier(@NotNull PrettierOptions options) {
* @see #visitCalls(Assoc, Doc, Fmt, Outer, SeqView, boolean)
*/
private <T extends AyaDocile> @NotNull Doc
prefix(@NotNull Doc fn, @NotNull Fmt<T> fmt, Outer outer, SeqView<? extends BinOpParser.@NotNull Elem<T>> args) {
prefix(@NotNull Doc fn, @NotNull Fmt<T> fmt, Outer outer, SeqView<? extends @NotNull BinOpElem<T>> args) {
var call = Doc.sep(fn, Doc.sep(args.map(arg ->
arg(fmt, arg, Outer.AppSpine))));
// If we're in a spine, add parentheses
return checkParen(outer, call, Outer.AppSpine);
}

public static <T extends AyaDocile> Doc arg(@NotNull Fmt<T> fmt, @NotNull BinOpParser.Elem<T> arg, @NotNull Outer outer) {
public static <T extends AyaDocile> Doc arg(@NotNull Fmt<T> fmt, @NotNull BinOpElem<T> arg, @NotNull Outer outer) {
if (arg.explicit()) return fmt.apply(outer, arg.term());
return Doc.braced(fmt.apply(Outer.Free, arg.term()));
}
Expand Down
6 changes: 3 additions & 3 deletions pretty/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2020-2021 Yinsen (Tesla) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
dependencies {
api(libs.annotations)
api(libs.kala.common)
api(libs.kala.collection)
testImplementation(libs.junit.jupiter)
testImplementation(libs.hamcrest)
}
2 changes: 2 additions & 0 deletions tools-kala/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module aya.util.kala {
requires aya.pretty;
requires transitive aya.util;

requires static org.jetbrains.annotations;
requires transitive kala.collection.primitive;

exports org.aya.util.binop;
exports org.aya.util.more;
exports org.aya.util.terck;
exports org.aya.util.tyck.pat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util.binop;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import kala.collection.mutable.*;
import kala.tuple.Tuple;
import kala.tuple.Tuple2;
import org.aya.util.BinOpElem;
import org.aya.util.error.SourceNode;
import org.aya.util.error.SourcePos;
import org.jetbrains.annotations.NotNull;
Expand All @@ -18,7 +19,7 @@
public abstract class BinOpParser<
OpSet extends BinOpSet,
Expr extends SourceNode,
Elm extends BinOpParser.Elem<Expr>> {
Elm extends BinOpElem<Expr>> {
protected final @NotNull OpSet opSet;
private final @NotNull SeqView<@NotNull Elm> seq;

Expand Down Expand Up @@ -214,8 +215,4 @@ enum AppliedSide {
return a.term().sourcePos();
}

public interface Elem<Expr> {
@NotNull Expr term();
boolean explicit();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util.binop;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util.binop;

Expand Down
2 changes: 1 addition & 1 deletion tools-md/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
dependencies {
api(project(":tools"))
api(project(":tools-kala"))
api(libs.annotations)
implementation(libs.aya.commonmark)
testImplementation(libs.junit.jupiter)
Expand Down
2 changes: 2 additions & 0 deletions tools-md/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module aya.md {
requires aya.util;
requires aya.util.kala;
requires transitive aya.pretty;

requires org.commonmark;
requires static org.jetbrains.annotations;
requires kala.collection.primitive;

exports org.aya.literate;
exports org.aya.literate.parser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import org.aya.pretty.backend.md.MdStyle;
import org.aya.pretty.doc.Doc;
import org.aya.pretty.doc.Style;
import org.aya.util.StringUtil;
import org.aya.util.error.InternalException;
import org.aya.util.error.SourceFile;
import org.aya.util.error.SourcePos;
import org.aya.util.more.StringUtil;
import org.aya.util.reporter.Reporter;
import org.commonmark.node.*;
import org.commonmark.parser.IncludeSourceSpans;
Expand Down
2 changes: 1 addition & 1 deletion tools-repl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
dependencies {
api(project(":tools-kala"))
api(project(":tools"))
api(libs.jline.reader)
api(libs.jline.terminal.api)
}
3 changes: 1 addition & 2 deletions tools/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
requires aya.pretty;

requires static org.jetbrains.annotations;
requires transitive kala.collection.primitive;
requires transitive kala.collection;

exports org.aya.util.binop;
exports org.aya.util.error;
exports org.aya.util.prettier;
exports org.aya.util.reporter;
Expand Down
3 changes: 1 addition & 2 deletions tools/src/main/java/org/aya/util/Arg.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import kala.collection.SeqView;
import kala.collection.immutable.ImmutableSeq;
import org.aya.util.binop.BinOpParser;
import org.jetbrains.annotations.NotNull;

import java.util.function.Consumer;
Expand All @@ -16,7 +15,7 @@
* In Aya, it is either core term, core pattern, concrete term, or concrete pattern.
* @author ice1000
*/
public record Arg<T>(@Override @NotNull T term, @Override boolean explicit) implements BinOpParser.Elem<T> {
public record Arg<T>(@Override @NotNull T term, @Override boolean explicit) implements BinOpElem<T> {
public static <T> @NotNull Arg<T> ofExplicitly(@NotNull T term) {
return new Arg<>(term, true);
}
Expand Down
10 changes: 10 additions & 0 deletions tools/src/main/java/org/aya/util/BinOpElem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util;

import org.jetbrains.annotations.NotNull;

public interface BinOpElem<Expr> {
@NotNull Expr term();
boolean explicit();
}

0 comments on commit 73e206d

Please sign in to comment.