Skip to content

Commit

Permalink
Merge branch 'feature/lexer'
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Brigl committed Nov 26, 2024
2 parents 940d367 + 075f5f8 commit 9da1397
Show file tree
Hide file tree
Showing 130 changed files with 1,981 additions and 2,160 deletions.
41 changes: 10 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# <a name="top"></a>HiveVM CC
![Status](https://img.shields.io/github/actions/workflow/status/hivevm/cc/:workflow)
[![License](https://img.shields.io/badge/License-BSD%203%20Clause-green.svg)](https://opensource.org/license/bsd-3-clause)

# HiveVM - Parser Generator

HiveVM Compiler-Compiler (HiveVM CC) is a fork of JavaCC 7.0.13.
The overall goal is to maintain *mostly* compatibility to JavaCC, but:
Expand All @@ -11,19 +14,8 @@ In addition to the parser generator itself, HiveVM CC provides other standard ca

All you need to run a HiveVM CC parser, once generated, is a Java Runtime Environment (JRE).

## Publishing

Gradle allows to define custom plugins that can be published to the Gradle repository. For testing usually we publish only to the local maven repository.

~~~
./gradlew clean publishToMavenLocal
OR
./gradlew clean publishPlugins
~~~



## Configure
## Configure Settings

The plugin implements the HiveVM CC generated.

Expand Down Expand Up @@ -51,18 +43,8 @@ parserProject {
}
~~~

## <a name="toc"></a>Contents

- [Introduction](#introduction)
* [Features](#features)
* [Example](#example)
* [Tutorials](docs/tutorials/index.md)
* [FAQ](docs/faq.md)
- [License](#license)

## <a name="introduction"></a>Introduction

### <a name="features"></a>Features
## Features

* HiveVM CC generates top-down ([recursive descent](https://en.wikipedia.org/wiki/Recursive_descent_parser)) parsers as opposed to bottom-up parsers generated by [YACC](https://en.wikipedia.org/wiki/Yacc)-like tools. This allows the use of more general grammars, although [left-recursion](https://en.wikipedia.org/wiki/Left_recursion) is disallowed. Top-down parsers have a number of other advantages (besides more general grammars) such as being easier to debug, having the ability to parse to any [non-terminal](https://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols) in the grammar, and also having the ability to pass values (attributes) both up and down the parse tree during parsing.

Expand Down Expand Up @@ -95,7 +77,7 @@ parserProject {
* The HiveVM CC release includes a wide range of examples including Java and HTML grammars. The examples, along with their documentation, are a great way to get acquainted with HiveVM CC.


### <a name="example"></a>Example
## Example

This example recognizes matching braces followed by zero or more line terminators and then an end of file.

Expand All @@ -107,7 +89,7 @@ Examples of illegal strings are:

`{}{}`, `}{}}`, `{ }`, `{x}` // ... etc

#### Grammar
### Grammar
```java
PARSER_BEGIN(Example)

Expand Down Expand Up @@ -139,7 +121,7 @@ void MatchedBraces() :
}
```

#### Output
### Output
```java
$ java Example
{{}}<return>
Expand Down Expand Up @@ -171,10 +153,7 @@ Was expecting one of:
at Example.main(Example.java:6)
```

## <a name="license"></a>License
## License

HiveVM CC is an open source project released under the [BSD 3-Clause License](LICENSE). The JavaCC project was originally developed at Sun Microsystems Inc. by [Sreeni Viswanadha](https://github.com/kaikalur) and [Sriram Sankar](https://twitter.com/sankarsearch).

[Top](#top)

<br>
Binary file modified bootstrap/javacc.jar
Binary file not shown.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.gradle.plugin-publish' version '1.3.0'
id "org.hivevm.cc" version "1.0.3"
id "org.hivevm.cc" version "1.0.4"
id 'java-gradle-plugin'
id 'maven-publish'
}
Expand All @@ -18,7 +18,7 @@ repositories {
}


version = '1.0.3'
version = '1.0.4'
group = 'org.hivevm'


Expand Down Expand Up @@ -80,7 +80,6 @@ gradlePlugin {
displayName = 'HiveVM CC'
description = 'HiveVM parser generator for Java/C++/Rust'
implementationClass = 'org.hivevm.gradle.HiveCCPlugin'
description = "Gradle plugin to use the HiveVM parser generator!"
tags.set(["hivevm", "compiler-compiler", "parser generator"])
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
188 changes: 94 additions & 94 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
18 changes: 9 additions & 9 deletions src/main/gradle/org/hivevm/gradle/ParserGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

package org.hivevm.gradle;

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;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.options.Option;
import org.gradle.api.tasks.options.OptionValues;
import org.hivevm.cc.ParserBuilder;
import org.hivevm.cc.Language;

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

import javax.inject.Inject;
import org.hivevm.cc.ParserBuilder;

/**
* The {@link ParserGenerator} class.
Expand Down Expand Up @@ -86,7 +86,7 @@ protected void process(ParserTask task, ParserProject config) {
builder.setTargetDir(getFile(task.output == null ? config.output : task.output));
builder.setParserFile(getFile(task.jjFile == null ? config.jjFile : task.jjFile));
builder.setTreeFile(getFile(task.jjtFile == null ? config.jjtFile : task.jjtFile));
builder.setExcludes(task.treeNodes);
builder.setCustomNodes(task.treeNodes);
builder.build();
}
}
8 changes: 4 additions & 4 deletions src/main/gradle/org/hivevm/gradle/ParserProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

package org.hivevm.gradle;

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 org.hivevm.cc.Language;

import java.util.List;

import javax.inject.Inject;

public abstract class ParserProject {

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

package org.hivevm.gradle;

import org.gradle.api.Project;
import org.hivevm.cc.Language;

import java.util.List;

import javax.inject.Inject;

import org.gradle.api.Project;
import org.hivevm.cc.Language;

public class ParserTask {

private final Project project;
Expand Down
Loading

0 comments on commit 9da1397

Please sign in to comment.