Skip to content

Commit

Permalink
Merge branch 'feature/hivevm'
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Brigl committed Nov 12, 2024
2 parents 75c85bf + 543329d commit 3df1591
Show file tree
Hide file tree
Showing 73 changed files with 868 additions and 820 deletions.
20 changes: 0 additions & 20 deletions .gitattributes

This file was deleted.

10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: HiveVM CC
on: [push]

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -9,4 +15,4 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew generateParser build
45 changes: 2 additions & 43 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,51 +1,10 @@
.gradle
.groovy
.classpath
.project
.checkstyle
.settings
.idea
*.iml
/target/
/build/
/buildSrc/build/
/buildSrc/subprojects/*/build/
/examples/build/
/examples/*/build/
/test/build/
/out/
/buildSrc/out/
/buildSrc/subprojects/*/out/
/examples/out/
/examples/*/out/
/test/out/
/bin/
/buildSrc/bin/
/buildSrc/subprojects/*/bin/
/examples/bin/
/examples/*/bin/
/test/bin/
build-eclipse
!subprojects/plugin/src/test/resources/compiledJavaccFile/target

.svn/

/build/
/classes/
.settings/
/target/
/src/main/generated/
test.tmp/
tmp/
.gradle/
TEST-*
**/out-dir/
*.*~
*.asc
examples/JJTreeExamples/cpp/eg*/
**/gen/

javacc-*.tar.gz
javacc-*.zip
dist/
ant.log
mvn.log
cobertura.ser
Binary file modified bootstrap/javacc.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ hiveCC {
step {
name = 'tree'
jjtFile = 'src/main/resources/JJTree.jjt'
directory = 'src/main/generated2/org/hivevm/cc/jjtree'
directory = 'src/main/generated/org/hivevm/cc/jjtree'
excludes = [ 'BNF', 'BNFAction', 'BNFDeclaration', 'BNFNodeScope',
'ExpansionNodeScope', 'NodeDescriptor', 'OptionBinding' ]
}

step {
name = 'parser'
jjFile = 'src/main/resources/JavaCC.jj'
directory = 'src/main/generated2/org/hivevm/cc/parser'
directory = 'src/main/generated/org/hivevm/cc/parser'
}

// step {
Expand Down
8 changes: 4 additions & 4 deletions src/main/gradle/org/hivevm/cc/GeneratorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

package org.hivevm.cc;

import java.util.List;

import javax.inject.Inject;

import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.Nested;

import java.util.List;

import javax.inject.Inject;

public abstract class GeneratorConfig {

private final Project project;
Expand Down
4 changes: 2 additions & 2 deletions src/main/gradle/org/hivevm/cc/GeneratorStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

package org.hivevm.cc;

import org.gradle.api.Project;

import java.util.List;

import javax.inject.Inject;

import org.gradle.api.Project;

public class GeneratorStep {

private final Project project;
Expand Down
22 changes: 12 additions & 10 deletions src/main/gradle/org/hivevm/cc/GeneratorTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

package org.hivevm.cc;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.inject.Inject;

import org.gradle.api.DefaultTask;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
Expand All @@ -11,13 +18,6 @@
import org.gradle.api.tasks.options.Option;
import org.gradle.api.tasks.options.OptionValues;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.inject.Inject;

/**
* The {@link GeneratorTask} class.
*/
Expand All @@ -36,7 +36,7 @@ public GeneratorTask() {

@OptionValues("target")
public List<Language> getAvailableOutputTypes() {
return new ArrayList<Language>(Arrays.asList(Language.values()));
return new ArrayList<>(Arrays.asList(Language.values()));
}

@TaskAction
Expand All @@ -54,12 +54,14 @@ public void process() {
}

protected File getFile(String pathname) {
if (pathname == null)
if (pathname == null) {
return null;
}

File targetDir = new File(pathname);
if (targetDir.isAbsolute())
if (targetDir.isAbsolute()) {
return targetDir;
}

File projectDir = getProject().getProjectDir();
return new File(projectDir, pathname);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/hivevm/cc/HiveCC.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

package org.hivevm.cc;

import org.hivevm.cc.utils.Version;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.hivevm.cc.utils.Version;

/**
* This package contains data created as a result of parsing and semanticizing a JavaCC input file.
* This data is what is used by the back-ends of JavaCC as well as any other back-end of JavaCC
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/hivevm/cc/HiveCCBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
package org.hivevm.cc;


import org.hivevm.cc.parser.Options;

import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;

import org.hivevm.cc.parser.Options;

/**
* The {@link HiveCCBuilder} class.
*/
Expand Down Expand Up @@ -88,8 +88,8 @@ public final void build() {
arguments.add("-CODE_GENERATOR=" + this.language.name());
arguments.add("-OUTPUT_DIRECTORY=" + this.targetDir.getAbsolutePath());
if (this.jj == null) {
if (excludes != null && !excludes.isEmpty()) {
arguments.add("-NODE_EXCLUDES=" + String.join(",", excludes));
if ((this.excludes != null) && !this.excludes.isEmpty()) {
arguments.add("-NODE_EXCLUDES=" + String.join(",", this.excludes));
}
arguments.add(this.jjt.getAbsolutePath());

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/hivevm/cc/HiveCCInterpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

package org.hivevm.cc;

import java.text.ParseException;
import java.util.HashSet;
import java.util.Set;

import org.hivevm.cc.generator.LexerBuilder;
import org.hivevm.cc.generator.LexerData;
import org.hivevm.cc.parser.JavaCCData;
Expand All @@ -13,10 +17,6 @@
import org.hivevm.cc.parser.StringProvider;
import org.hivevm.cc.semantic.Semanticize;

import java.text.ParseException;
import java.util.HashSet;
import java.util.Set;

public class HiveCCInterpreter {

private final Options options;
Expand All @@ -32,17 +32,17 @@ public HiveCCInterpreter(Options options) {
public void runTokenizer(String grammar, String input) {
JavaCCErrors.reInit();
try {
JavaCCData request = new JavaCCData(false, options);
JavaCCData request = new JavaCCData(false, this.options);

JavaCCParser parser = new JavaCCParserDefault(new StringProvider(grammar), options);
JavaCCParser parser = new JavaCCParserDefault(new StringProvider(grammar), this.options);
parser.initialize(request);
parser.javacc_input();

Semanticize.semanticize(request, options);
Semanticize.semanticize(request, this.options);

if (JavaCCErrors.get_error_count() == 0) {
LexerData data = new LexerBuilder().build(request);
tokenize(data, input, options);
HiveCCInterpreter.tokenize(data, input, this.options);
}
} catch (ParseException e) {
System.out.println("Detected " + JavaCCErrors.get_error_count() + " errors and "
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/hivevm/cc/JJMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

package org.hivevm.cc;

import org.hivevm.cc.parser.JavaCCErrors;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand All @@ -17,6 +15,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.hivevm.cc.parser.JavaCCErrors;

/**
* The {@link JJMain} class.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/hivevm/cc/JJParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

package org.hivevm.cc;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.text.ParseException;

import org.hivevm.cc.generator.ParserEngine;
import org.hivevm.cc.parser.JavaCCData;
import org.hivevm.cc.parser.JavaCCErrors;
Expand All @@ -12,12 +18,6 @@
import org.hivevm.cc.parser.StreamProvider;
import org.hivevm.cc.semantic.Semanticize;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.text.ParseException;

/**
* Entry point.
*/
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/hivevm/cc/JJTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

package org.hivevm.cc;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.text.ParseException;

import org.hivevm.cc.generator.ParserEngine;
import org.hivevm.cc.jjtree.ASTGrammar;
import org.hivevm.cc.jjtree.ASTWriter;
Expand All @@ -12,13 +19,6 @@
import org.hivevm.cc.parser.JavaCCErrors;
import org.hivevm.cc.parser.Options;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.text.ParseException;

public class JJTree {

private static void help_message() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/hivevm/cc/doc/BNFGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

package org.hivevm.cc.doc;

import java.io.PrintWriter;

import org.hivevm.cc.parser.Expansion;
import org.hivevm.cc.parser.NonTerminal;
import org.hivevm.cc.parser.NormalProduction;
Expand All @@ -11,8 +13,6 @@
import org.hivevm.cc.parser.RegularExpression;
import org.hivevm.cc.parser.TokenProduction;

import java.io.PrintWriter;

class BNFGenerator implements Generator {

private PrintWriter ostr;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/hivevm/cc/doc/HTMLGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

package org.hivevm.cc.doc;

import java.util.Hashtable;

import org.hivevm.cc.parser.Expansion;
import org.hivevm.cc.parser.NonTerminal;
import org.hivevm.cc.parser.NormalProduction;
import org.hivevm.cc.parser.RegularExpression;
import org.hivevm.cc.parser.TokenProduction;

import java.util.Hashtable;

/**
* Output BNF in HTML 3.2 format.
*/
Expand Down
Loading

0 comments on commit 3df1591

Please sign in to comment.