Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ponyatov/metaL
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	.gitmodules
#	Makefile
#	README.md
#	requirements.txt
  • Loading branch information
ponyatov committed Sep 3, 2019
2 parents 33dfbb3 + 1fc1d4b commit b1705cd
Show file tree
Hide file tree
Showing 172 changed files with 2,516 additions and 92 deletions.
1 change: 1 addition & 0 deletions ANTLR/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
antlr-4.7.2-complete.jar
1 change: 1 addition & 0 deletions ANTLR/get.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wget -c https://www.antlr.org/download/antlr-4.7.2-complete.jar
8 changes: 8 additions & 0 deletions ANTLR/sample.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>

// https://www.youtube.com/watch?v=tkDfxdoQw4I

int main() {
std::cout << "Hello World" << std::endl;
return 0;
}
1 change: 1 addition & 0 deletions Android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
/build
/captures
.externalNativeBuild
app/src/main/java/io/github/ponyatov/metal/FORTH.java
1 change: 1 addition & 0 deletions Android/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions Android/.idea/misc.xml

This file was deleted.

35 changes: 35 additions & 0 deletions Android/FORTH.ragel
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.github.ponyatov.metal;

//import java.text.ParseException;

%%{
machine lexer;

comment = ( "#" [^\n]* ) >{ts=p;} @{EMIT(new Comment(new String(data,ts,p)));} ;

main := (
comment
# | any @{EMIT(new Symbol(String.valueOf(data[p])));}
)*;
}%%

public class FORTH {

static void EMIT(Frame c) { MainActivity.tasklist.append(c.dump()); }

////////////////////////////////////////////////////////////////////////////////// .ragel generated

%% write data;

public static void parse(String cmd) /* throws ParseException */ {

char[] data = cmd.toCharArray();// parser requires sequence storage
int cs = lexer_start; // state machine current state
int p = 0; // current parsing position
int pe = data.length; // end of source text marker
int ts = 0; // Token Start pointer

%% write exec;
}

}
4 changes: 4 additions & 0 deletions Android/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SRC = app/src/main/java/
PKG = $(SRC)/io/github/ponyatov/metal
$(PKG)/FORTH.java: FORTH.ragel Makefile
ragel -J -o $@ $<
6 changes: 3 additions & 3 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
44 changes: 44 additions & 0 deletions Android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"project_info": {
"project_number": "890654100792",
"firebase_url": "https://metal-236405.firebaseio.com",
"project_id": "metal-236405",
"storage_bucket": "metal-236405.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:890654100792:android:809e59e342cfe2ed",
"android_client_info": {
"package_name": "io.github.ponyatov.metal"
}
},
"oauth_client": [
{
"client_id": "890654100792-p86jetl5tf1jdqkanbjrhjh5mhg53rnq.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "io.github.ponyatov.metal",
"certificate_hash": "fc19bc25cd480f36c043d309b731c8383989aa15"
}
}
],
"api_key": [
{
"current_key": "AIzaSyBJ5Ylrpn6oRkjM-K8b1yONBckexTYoS00"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "890654100792-ke5729bj7a1om53uf83dnd1rapkvk2l6.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
1 change: 1 addition & 0 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".AboutActivity"></activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.github.ponyatov.metal;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class AboutActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

public class Comment extends Symbol {
final static String type = "comment";
public Comment(String V) { super(V); }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

public class Container extends Frame {
final static String type = "container";
public Container(String V) { super(V); }
}
6 changes: 6 additions & 0 deletions Android/app/src/main/java/io/github/ponyatov/metal/Dict.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

public class Dict extends Container {
final static String type = "dict";
public Dict(String V) { super(V); }
}
6 changes: 6 additions & 0 deletions Android/app/src/main/java/io/github/ponyatov/metal/FDB.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

/// Firebase DB interface class

public class FDB {
}
37 changes: 37 additions & 0 deletions Android/app/src/main/java/io/github/ponyatov/metal/Frame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.github.ponyatov.metal;

public class Frame {

/// type/class tag
final static String type = "frame";

/// object value (primitive implementation language type)
String value;

/// construct new frame/object with given name
public Frame(String V) {
value = V;
}

/// dump in short form: header only
public String head(String prefix) {
return prefix + "<" + type + ":" + value + ">";
}
public String head() { return head(""); }

public String dump(int depth, String prefix) {
String S = pad(depth) + head(prefix);
return S;
}
public String dump(int depth) { return dump(depth,""); }
public String dump() { return dump(0,""); }

String pad(int N) {
final String cr = "\n";
final String tab = "\t";
String S = cr;
for (int i=0;i<N;i++) S += tab;
return S;
}

}
Original file line number Diff line number Diff line change
@@ -1,31 +1,68 @@
package io.github.ponyatov.metal;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

/// task list text panel
public static TextView tasklist;

/// command entry field
public static TextView pad;

/// run command button
Button go;

/// add new task floating button
FloatingActionButton fab;

private void msg(String what) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("msg").setMessage(what);
AlertDialog alert = builder.create();
alert.show();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

FloatingActionButton fab = findViewById(R.id.fab);
tasklist = findViewById(R.id.tasklist);

pad = findViewById(R.id.pad);

go = findViewById(R.id.go);
go.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Task t = new Task(pad.getText().toString());
tasklist.setText(t.head());
}
});

fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
pad.setText("'newTask' Task\n"+pad.getText());
}
});

FORTH.parse("# put your commands here \n"
+" 1 2.3 4e-5 0xDeadBeef 0b1101");
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions Android/app/src/main/java/io/github/ponyatov/metal/Stack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

public class Stack extends Container {
final static String type = "stack";
public Stack(String V) { super(V); }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

public class Symbol extends Frame {
final static String type = "symbol";
public Symbol(String V) { super(V); }
}
6 changes: 6 additions & 0 deletions Android/app/src/main/java/io/github/ponyatov/metal/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

public class Task extends Frame {
final static String type = "task";
public Task(String V) { super(V); }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

public class TaskList extends Vector {
final static String type = "tasklist";
public TaskList(String V) { super(V); }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.ponyatov.metal;

public class Vector extends Container {
final static String type = "vector";
public Vector(String V) { super(V); }
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions Android/app/src/main/res/layout-land/content_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">

<TextView
android:id="@+id/tasklist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="69dp"
android:text="@string/hello"
android:textColor="@color/colorConsole"
android:textSize="@dimen/szConsole"
app:layout_constraintBottom_toTopOf="@+id/cli"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />

<LinearLayout
android:id="@+id/cli"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="0dp">

<EditText
android:id="@+id/pad"
android:layout_width="wrap_content"
android:layout_height="192dp"
android:ems="19"
android:inputType="textMultiLine"
android:textSize="@dimen/szConsole"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="60dp" />

<Button
android:id="@+id/go"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:text="Butt\non"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/cli"
tools:layout_editor_absoluteX="329dp"
tools:layout_editor_absoluteY="486dp" />

</LinearLayout>

</android.support.constraint.ConstraintLayout>
Loading

0 comments on commit b1705cd

Please sign in to comment.