Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Android version #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions android-app/anter4codeformat/.androidide/editor/openedFiles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"allFiles": [
{
"file": "/storage/emulated/0/AndroidIDEProjects/anter4codeformat/app/build.gradle",
"selection": {
"end": {
"column": 45,
"index": 1018,
"line": 47
},
"start": {
"column": 45,
"index": 1018,
"line": 47
}
}
},
{
"file": "/storage/emulated/0/AndroidIDEProjects/anter4codeformat/app/src/main/java/org/antlr/parser/antlr4/LexerAdaptor.java",
"selection": {
"end": {
"column": 0,
"index": 0,
"line": 0
},
"start": {
"column": 0,
"index": 0,
"line": 0
}
}
}
],
"selectedFile": "/storage/emulated/0/AndroidIDEProjects/anter4codeformat/app/src/main/java/org/antlr/parser/antlr4/LexerAdaptor.java"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"allFiles": [
{
"file": "/storage/emulated/0/AndroidIDEProjects/anter4codeformat/app/build.gradle",
"selection": {
"end": {
"column": 47,
"index": 1020,
"line": 47
},
"start": {
"column": 47,
"index": 1020,
"line": 47
}
}
}
],
"selectedFile": "/storage/emulated/0/AndroidIDEProjects/anter4codeformat/app/build.gradle"
}
83 changes: 83 additions & 0 deletions android-app/anter4codeformat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
/bin/
/gen/
/out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# Gradle files
.gradle/
/build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
7 changes: 7 additions & 0 deletions android-app/anter4codeformat/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Android version

I have produced this version for Android. Please note that you must use the version 1.14.1. You can also use Java files that have been rebuilt for Android.

### Developer

Developer account address <a href="https://github.com/appt2"> here </a>
1 change: 1 addition & 0 deletions android-app/anter4codeformat/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
49 changes: 49 additions & 0 deletions android-app/anter4codeformat/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

plugins {
id 'com.android.application'

}

android {
namespace 'com.example.anter4codeformat'
compileSdk 33

defaultConfig {
applicationId "com.example.anter4codeformat"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"

vectorDrawables {
useSupportLibrary true
}
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

buildFeatures {
viewBinding true

}

}

dependencies {


implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("com.google.android.material:material:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("org.antlr:antlr4:4.13.1")
}
21 changes: 21 additions & 0 deletions android-app/anter4codeformat/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
23 changes: 23 additions & 0 deletions android-app/anter4codeformat/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="MainActivity"
android:exported="true">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.example.anter4codeformat;

import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.anter4codeformat.databinding.ActivityMainBinding;
import com.khubla.antlr4formatter.Antlr4Formatter;
import com.khubla.antlr4formatter.Antlr4FormatterException;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private ActivityMainBinding binding;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Inflate and get instance of binding
binding = ActivityMainBinding.inflate(getLayoutInflater());

// set content view to binding's root
setContentView(binding.getRoot());
binding.btnFormat.setOnClickListener(this);
}

@Override
protected void onDestroy() {
super.onDestroy();
this.binding = null;
}

public String g4format(String code) throws Antlr4FormatterException {
return Antlr4Formatter.format(code);
}

@Override
public void onClick(View arg0) {
// TODO: Implement this method
try {
binding.format.setText(g4format(binding.format.getText().toString()));
} catch (Antlr4FormatterException err) {
binding.format.setText(err.getLocalizedMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Antlr4Formatter Copyright 2015, khubla.com
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
package com.khubla.antlr4formatter;

import java.io.*;
import java.nio.charset.*;
import java.nio.file.*;
import java.util.*;

import org.antlr.parser.antlr4.*;
import org.antlr.parser.antlr4.ANTLRv4Parser.*;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.*;

import com.khubla.antlr4formatter.listener.*;

/**
* @author Tom Everett
*/
public class Antlr4Formatter {

public static String format(String string) throws Antlr4FormatterException {
try {
if (null != string) {
final StringWriter writer = new StringWriter();
final CodePointCharStream input = CharStreams.fromString(string);
formatGrammar(input, writer);
return writer.toString();
} else {
return "";
}
} catch (final Exception e) {
throw new Antlr4FormatterException("Exception reading and parsing file", e);
}
}

private static void formatGrammar(CharStream input, Writer output) {
final ANTLRv4Lexer lexer = new ANTLRv4Lexer(input);
final CommonTokenStream commonTokenStream = new CommonTokenStream(lexer);
final ANTLRv4Parser parser = new ANTLRv4Parser(commonTokenStream);
final GrammarSpecContext grammarSpecContext = parser.grammarSpec();
ParseTreeWalker.DEFAULT.walk(
new FormatterParseTreeListenerImpl(
new Antlr4FormatterListenerImpl(output), commonTokenStream),
grammarSpecContext);
}

private Antlr4Formatter() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Antlr4Formatter Copyright 2018, khubla.com
*
* 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 <http://www.gnu.org/licenses/>.
*
*/
package com.khubla.antlr4formatter;

public class Antlr4FormatterException extends Exception {
private static final long serialVersionUID = 1L;

public Antlr4FormatterException(Exception e) {
super(e);
}

public Antlr4FormatterException(String message) {
super(message);
}

public Antlr4FormatterException(String message, Exception e) {
super(message, e);
}
}
Loading
Loading