Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
✨ v1.5.0 (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
JumperBot authored Dec 2, 2022
1 parent c758368 commit e958d8b
Show file tree
Hide file tree
Showing 27 changed files with 464 additions and 95 deletions.
62 changes: 33 additions & 29 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "Java",
"image": "mcr.microsoft.com/devcontainers/java:11-bullseye",
"name": "Debian",
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/java:1": {
"version": "none",
"installMaven": "false",
"installGradle": "false"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "none"
},
"ghcr.io/devcontainers/features/git:1": {}
"version": "11",
"jdkDistro": "open",
"installGradle": false,
"installMaven": false
}
},
"customizations": {
"vscode": {
"extensions": [
"hilalh.hyper-dracula-vscode-theme",
"VisualStudioExptTeam.vscodeintellicode",
"redhat.java",
"bierner.github-markdown-preview",
"bierner.markdown-checkbox",
"bierner.markdown-emoji",
"bierner.markdown-footnotes",
"bierner.markdown-preview-github-styles",
"bierner.markdown-yaml-preamble",
"bierner.markdown-mermaid"
]
}
}

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "java -version",
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [
// {
// "source": "/var/run/docker.sock",
// "target": "/var/run/docker-host.sock",
// "type": "bind"
// }
// ]

// Configure tool-specific properties.
// "customizations": {},
"customizations": {
"vscode": {
"extensions": [
"hilalh.hyper-dracula-vscode-theme",
"VisualStudioExptTeam.vscodeintellicode",
"VisualStudioExptTeam.intellicode-api-usage-examples",
"redhat.java",
"vscjava.vscode-java-dependency"
]
}
},

// Use 'postCreateCommand' to run commands after the container is created.
"postStartCommand": "cd /workspaces/Unsafe-4-Bit/build && sh devConBuild.sh && cd .."

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Expand Down
Binary file modified build/UFB.jar
Binary file not shown.
Binary file modified build/UFB/Command$1.class
Binary file not shown.
Binary file modified build/UFB/Command.class
Binary file not shown.
Binary file modified build/UFB/FlagManager.class
Binary file not shown.
Binary file added build/UFB/RfileCommand.class
Binary file not shown.
Binary file modified build/UFB/Runner$1.class
Binary file not shown.
Binary file added build/UFB/Runner$2.class
Binary file not shown.
Binary file modified build/UFB/Runner.class
Binary file not shown.
Binary file modified build/UFB/UFB.class
Binary file not shown.
Binary file modified build/UFB/UFBC$1.class
Binary file not shown.
Binary file modified build/UFB/UFBC$2.class
Binary file not shown.
Binary file modified build/UFB/UFBC.class
Binary file not shown.
6 changes: 5 additions & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ echo "javac ../../src/UFB/*.java -d . -Xdiags:verbose"
javac ../../src/UFB/*.java -d . -Xdiags:verbose
echo "jar --create --file=../UFB.jar --main-class=UFB *.class"
jar --create --file=../UFB.jar --main-class=UFB *.class
cd ..
cd ../..
# Copy changed to codespace extensions directory
echo "cp -r syntax-highlight/unsafe-4-bit ~/.vscode-remote/extensions/"
cp -r syntax-highlight/unsafe-4-bit ~/.vscode-remote/extensions/
cd build
6 changes: 6 additions & 0 deletions build/devConBuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
cd ..
# Copy changed to codespace extensions directory
echo "cp -r syntax-highlight/ ~/.vscode-remote/extensions/"
cp -r syntax-highlight/ ~/.vscode-remote/extensions/
cd build
31 changes: 16 additions & 15 deletions src/UFB/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@

import java.util.concurrent.ExecutorService;

import java.util.regex.Pattern;

class Command{
final ArrayList<Integer> compiled=new ArrayList<>();
final StringBuilder errors=new StringBuilder();
final ExecutorService executor;
final HashMap<String, Integer> binaryMap;
final Pattern jumps;
final Pattern maths;
final Pattern pwvar;
final String[] line;
final String[] realLine;
boolean cancelOptimization=false;
Expand All @@ -50,16 +45,14 @@ public String getErrors(){
return errors.toString();
}

private Command(final String[] line, final String[] realLine, final ExecutorService executor,
final Pattern jumps, final Pattern maths, final Pattern pwvar,
final HashMap<String, Integer> binaryMap){
private Command(
final String[] line, final String[] realLine,
final ExecutorService executor, final HashMap<String, Integer> binaryMap
){
this.line=line;
this.realLine=realLine;
this.executor=executor;
this.binaryMap=binaryMap;
this.jumps=jumps;
this.maths=maths;
this.pwvar=pwvar;
this.line[0]=this.line[0].toLowerCase();
}
private void compile(){
Expand Down Expand Up @@ -97,6 +90,13 @@ private GenericCommand getCommand(final int comInd){
cancelOptimization=true;
case 1:
return new NeedsOneMemCommand(comInd, line, realLine);
case 17:
cancelOptimization=true;
return new RfileCommand(line, realLine);
case 18:
case 16:
cancelOptimization=true;
return new NeedsArgLengthCommand(comInd, line, realLine);
default:
return null;
}
Expand Down Expand Up @@ -146,10 +146,11 @@ public static String convertUnicode(final String in){
}
return temp;
}
public static Command create(final String[] line, final String[] realLine, final ExecutorService executor,
final Pattern jumps, final Pattern maths, final Pattern pwvar,
final HashMap<String, Integer> binaryMap){
final Command com=new Command(line, realLine, executor, jumps, maths, pwvar, binaryMap);
public static Command create(
final String[] line, final String[] realLine,
final ExecutorService executor, final HashMap<String, Integer> binaryMap
){
final Command com=new Command(line, realLine, executor, binaryMap);
com.compile();
return com;
}
Expand Down
20 changes: 5 additions & 15 deletions src/UFB/FlagManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*
**/

import java.io.File;

import java.util.Arrays;

import java.util.regex.Pattern;
Expand Down Expand Up @@ -53,19 +51,19 @@ else if(arg.startsWith("--")){
isLongActivated[i]=true;
}else
System.out.printf(
"Unrecognized flags found: %s\n%s\n\n",
"\u001B[93mUnrecognized flags found: %s\n%s\n\n",
arg2,
"Continuing anyway..."
"Continuing anyway...\u001B[0m"
);
}else if(arg.startsWith("-")){
final String str=repeats.matcher(arg.replace("-", "")).replaceAll("$1");
final String shouldBeEmpty=flags.matcher(str).replaceAll("");
if(shouldBeEmpty.length()!=0){
final String joined=Arrays.toString(shouldBeEmpty.split("")).substring(1);
System.out.printf(
"Unrecognized flags found: %s\n%s\n\n",
"\u001B[93mUnrecognized flags found: %s\n%s\n\n",
joined.substring(0, joined.length()-1),
"Continuing anyway..."
"Continuing anyway...\u001B[0m"
);
}
if(str.contains("p"))isActivated[0]=true;
Expand All @@ -76,18 +74,10 @@ else if(arg.startsWith("--")){
if(str.contains(flagString.charAt(i+1)+""))
isActivated[i]=true;
}else System.out.printf(
"Unrecognized argument: %s\nContinuing anyway...\n\n", arg
"\u001B[93mUnrecognized argument: %s\nContinuing anyway...\n\n\u001B[0m", arg
);
}
file=fileName;
if(fileName.length()==0){
System.out.println("No file input found, terminating.");
System.exit(1);
}
if(!new File(fileName).exists()){
System.out.println("File Provided Does Not Exist...\nTerminating...");
System.exit(1);
}
}
public boolean isFlagActivated(final char c){
final char[] array=flagString.substring(1).toCharArray();
Expand Down
41 changes: 41 additions & 0 deletions src/UFB/RfileCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
*
* Unsafe Four Bit is a compiled-interpreted, dynamically-typed programming language.
* Copyright (C) 2022 JumperBot_
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
**/

class RfileCommand extends NeedsArgLengthCommand{
public RfileCommand(final String[] line, final String[] realLine){
super(17, line, realLine);
}
@Override
public void checkCases(final String[] line, final String[] realLine){
super.checkCases(line, realLine);
if(Long.parseLong(line[1])<38)
try{
errors.append(Command.formatError(
line, "Memory Index", line[1],
"Endangers A Read-Only Memory Index"
));
}catch(final Exception e){
errors.append(Command.formatError(
line, "Memory Index Expected Instead Of", line[1],
"Should Be Replaced With A Memory Index"
));
}
}
}
Loading

0 comments on commit e958d8b

Please sign in to comment.