This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating Konstruct with more functions
- Loading branch information
1 parent
cfcc43b
commit 8442e19
Showing
4 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/io/github/darkkronicle/advancedchatcore/konstruct/StringMatchObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package io.github.darkkronicle.advancedchatcore.konstruct; | ||
|
||
import io.github.darkkronicle.Konstruct.functions.ObjectFunction; | ||
import io.github.darkkronicle.Konstruct.nodes.Node; | ||
import io.github.darkkronicle.Konstruct.parser.IntRange; | ||
import io.github.darkkronicle.Konstruct.parser.ParseContext; | ||
import io.github.darkkronicle.Konstruct.parser.Result; | ||
import io.github.darkkronicle.Konstruct.type.IntegerObject; | ||
import io.github.darkkronicle.Konstruct.type.KonstructObject; | ||
import io.github.darkkronicle.Konstruct.type.StringObject; | ||
import io.github.darkkronicle.advancedchatcore.util.SearchResult; | ||
import io.github.darkkronicle.advancedchatcore.util.StringMatch; | ||
|
||
import java.util.List; | ||
|
||
public class StringMatchObject extends KonstructObject<StringMatchObject> { | ||
|
||
private final StringMatch result; | ||
|
||
private final static List<ObjectFunction<StringMatchObject>> FUNCTIONS = List.of( | ||
new ObjectFunction<>() { | ||
@Override | ||
public Result parse(ParseContext context, StringMatchObject self, List<Node> input) { | ||
return Result.success(new IntegerObject(self.result.start)); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "getStart"; | ||
} | ||
|
||
@Override | ||
public IntRange getArgumentCount() { | ||
return IntRange.of(0); | ||
} | ||
}, | ||
new ObjectFunction<>() { | ||
@Override | ||
public Result parse(ParseContext context, StringMatchObject self, List<Node> input) { | ||
return Result.success(new IntegerObject(self.result.end)); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "getEnd"; | ||
} | ||
|
||
@Override | ||
public IntRange getArgumentCount() { | ||
return IntRange.of(0); | ||
} | ||
}, | ||
new ObjectFunction<>() { | ||
@Override | ||
public Result parse(ParseContext context, StringMatchObject self, List<Node> input) { | ||
return Result.success(new StringObject(self.result.match)); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "getMessage"; | ||
} | ||
|
||
@Override | ||
public IntRange getArgumentCount() { | ||
return IntRange.of(0); | ||
} | ||
} | ||
); | ||
|
||
public StringMatchObject(StringMatch result) { | ||
this.result = result; | ||
} | ||
|
||
@Override | ||
public String getString() { | ||
return result.toString(); | ||
} | ||
|
||
@Override | ||
public String getTypeName() { | ||
return "string_match"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters