Skip to content

Commit

Permalink
Merge pull request #27 from polystat/develop
Browse files Browse the repository at this point in the history
Version 0.1
  • Loading branch information
IamMaxim committed Oct 25, 2021
2 parents 776acd2 + 448bf32 commit aff2e5f
Show file tree
Hide file tree
Showing 27 changed files with 2,222 additions and 1,659 deletions.
26 changes: 25 additions & 1 deletion .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
strategy:
matrix:
os: [
ubuntu-latest,
macos-latest,
windows-latest
]
Expand All @@ -32,3 +31,28 @@ jobs:
with:
arguments: test

gradle_ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: 16

- run: |
wget http://ftp.gnu.org/gnu/bison/bison-3.8.tar.gz
tar -zxvf bison-3.8.tar.gz
cd bison-3.8
./configure
make
sudo make install
bison -V
- uses: gradle/gradle-build-action@v1
with:
arguments: build

- uses: gradle/gradle-build-action@v1
with:
arguments: test
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ bugs in our code. It is also much easier to work with abstraction layer than wit

---

## Requirements

In order to compile project from source code, you need to have

- Bison 3.7+
- Java 15+

installed. Bison is currently bundled with the project for Windows and macOS. On Linux, you may use package manager to easily install Bison (but check the Bison version; some distos, like Ubuntu, like to ship outdated versions of software).

---

## Usage

To build, run:
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/sh

./gradlew fatJar
./gradlew fatJar test
cp build/libs/* j2eo.jar
2 changes: 1 addition & 1 deletion src/main/java/eotree/EOCopy.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public EOCopy(EOExpr trg, List<EOBnd> args) {
@Override
public String generateEO(int indent) {
return trg.generateEO(indent) + args.stream()
.map(arg -> " " + arg.generateEO(indent + 1))
.map(arg -> "\n" + arg.generateEO(indent + 1))
.collect(Collectors.joining());
}
}
2 changes: 1 addition & 1 deletion src/main/java/eotree/EOObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public String generateEO(int indent) {
.map(attr -> attr.generateEO(indent))
.collect(Collectors.joining(" ")) +
(varargAttr
.map(attr -> " " + attr.generateEO(indent) + "...")
.map(attr -> (freeAttrs.size() > 0 ? " " : "") + attr.generateEO(indent) + "...")
.orElse("")) +
"]\n" +
bndAttrs.stream()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eotree/EOProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public String generateEO(int indent) {
"\n" +
bnds.stream()
.map(bnd -> bnd.generateEO(indent))
.collect(Collectors.joining("\n"));
.collect(Collectors.joining("\n")) + "\n";
}
}
2 changes: 1 addition & 1 deletion src/main/java/eotree/data/EOFloatData.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public EOFloatData(Float f) {

@Override
public String generateEO(int indent) {
return f.toString();
return indent(indent) + f.toString();
}
}
2 changes: 1 addition & 1 deletion src/main/java/eotree/data/EOIntData.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public EOIntData(Integer i) {

@Override
public String generateEO(int indent) {
return i.toString();
return indent(indent) + i.toString();
}
}
2 changes: 1 addition & 1 deletion src/main/java/eotree/data/EOStringData.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public EOStringData(String str) {

@Override
public String generateEO(int indent) {
return "\"" + str + "\"";
return indent(indent) + "\"" + str + "\"";
}
}
30 changes: 15 additions & 15 deletions src/main/java/lexer/Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
public class Scanner implements JavaParser.Lexer
{
private static String sourcePath;
private static char[] sourceText;
private char[] sourceText;

public static boolean read(String path)
public boolean read(String path)
{
sourcePath = path;
try {
Expand All @@ -28,12 +28,12 @@ public static boolean read(String path)

// Machinery for reading bytes from the source ///////////////////////

private static int currentLine = 0;
private static int currentPos = 0;
private static int globalPos = -1;
private static char currentChar = '\0';
private int currentLine = 0;
private int currentPos = 0;
private int globalPos = -1;
private char currentChar = '\0';

private static char getChar()
private char getChar()
{
if ( currentChar == '\0' )
{
Expand All @@ -44,7 +44,7 @@ private static char getChar()
return currentChar;
}

private static void forgetChar()
private void forgetChar()
{
currentChar = '\0';
}
Expand Down Expand Up @@ -77,18 +77,18 @@ public void yyerror(String msg) {

// Detecting the current token //////////////////////////////

private static Token currentToken;
public static Token get()
private Token currentToken;
public Token get()
{
if ( currentToken == null ) currentToken = getToken();
return currentToken;
}
public static void forget()
public void forget()
{
currentToken = null;
}

private static Token getToken()
private Token getToken()
{
char ch;
TokenCode code;
Expand Down Expand Up @@ -330,17 +330,17 @@ else if ( Character.isDigit(ch) )
return token;
}

private static String scanShortComment()
private String scanShortComment()
{
return "";
}

private static String scanLongComment()
private String scanLongComment()
{
return "";
}

private static TokenCode detectKeyword(String identifier)
private TokenCode detectKeyword(String identifier)
{
switch ( identifier ) {
case "abstract" : return TokenCode.Abstract;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public static void main(String[] args) throws FileNotFoundException {


// Read, parse, map and print file
Scanner.read(inputFilepath);
Scanner scanner = new Scanner();
scanner.read(inputFilepath);
JavaParser parser = new JavaParser(scanner);
try {
boolean result = parser.parse();
System.out.println(result ? "SUCCESS" : "FAIL");
if (parser.ast != null) {
parser.ast.report(0);
//parser.ast.report(0);
var eoProgram = Translator.translate(parser.ast);
var targetText = eoProgram.generateEO(0);

Expand Down

1 comment on commit aff2e5f

@0pdd
Copy link
Member

@0pdd 0pdd commented on aff2e5f Oct 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to retrieve PDD puzzles from the code base and submit them to GitHub. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

set -x && set -e && set -o pipefail && cd /tmp/0pdd20210801-12-f1ew7f/polystat/j2eo && pdd -v -f /tmp/20211025-31667-rawuzw [1]: + set -e + set -o pipefail + cd /tmp/0pdd20210801-12-f1ew7f/polystat/j2eo + pdd -v -f /tmp/20211025-31667-rawuzw My version is 0.20.6 Ruby version is 2.6.0 at...

Please, copy and paste this stack trace to GitHub:

UserError
set -x && set -e && set -o pipefail && cd /tmp/0pdd20210801-12-f1ew7f/polystat/j2eo && pdd -v -f /tmp/20211025-31667-rawuzw [1]:
+ set -e
+ set -o pipefail
+ cd /tmp/0pdd20210801-12-f1ew7f/polystat/j2eo
+ pdd -v -f /tmp/20211025-31667-rawuzw

My version is 0.20.6
Ruby version is 2.6.0 at x86_64-linux
Reading /tmp/0pdd20210801-12-f1ew7f/polystat/j2eo
699 file(s) found, 555 excluded
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/Verbosity.png is a binary file (29722 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/FlexProperties.png is a binary file (26767 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/3.png is a binary file (7316 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/6.png is a binary file (15611 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/BisonProperties.png is a binary file (27186 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/2.png is a binary file (11445 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/Flex_debuging.png is a binary file (27219 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/Properties.png is a binary file (31446 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/4.png is a binary file (12213 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/1.png is a binary file (31654 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/custom_build_rules/docs/5.png is a binary file (11534 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/win_bison.exe is a binary file (665600 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/win_flex.exe is a binary file (569344 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/bin/bison_mac is a binary file (487680 bytes)
/tmp/0pdd20210801-12-f1ew7f/polystat/j2eo/gradle/wrapper/gradle-wrapper.jar is a binary file (59203 bytes)
Reading bin/changelog.md...
Reading bin/custom_build_rules/README.md...
Reading bin/custom_build_rules/win_flex_only/win_flex_custom_build.targets...
Reading bin/custom_build_rules/win_flex_only/win_flex_custom_build.props...
Reading bin/custom_build_rules/win_flex_only/win_flex_custom_build.xml...
Reading bin/custom_build_rules/win_bison_only/win_bison_custom_build.xml...
Reading bin/custom_build_rules/win_bison_only/win_bison_custom_build.props...
Reading bin/custom_build_rules/win_bison_only/win_bison_custom_build.targets...
Reading bin/custom_build_rules/win_flex_bison/win_flex_bison_custom_build.props...
Reading bin/custom_build_rules/win_flex_bison/win_flex_bison_custom_build.targets...
Reading bin/custom_build_rules/win_flex_bison/win_flex_bison_custom_build.xml...
Reading bin/data/local.mk...
Reading bin/data/README.md...
Reading bin/data/bison-default.css...
Reading bin/data/m4sugar/m4sugar.m4...
Reading bin/data/m4sugar/foreach.m4...
Reading bin/data/skeletons/java-skel.m4...
Reading bin/data/skeletons/location.cc...
Reading bin/data/skeletons/lalr1.java...
Reading bin/data/skeletons/c++.m4...
Reading bin/data/skeletons/traceon.m4...
Reading bin/data/skeletons/glr.cc...
Reading bin/data/skeletons/glr.c...
Reading bin/data/skeletons/c++-skel.m4...
Reading bin/data/skeletons/d.m4...
ERROR: bin/data/skeletons/d.m4; puzzle at line #298; TODO found, but puzzle can't be parsed, most probably because TODO is not followed by a puzzle marker, as this page explains: https://github.com/yegor256/pdd#how-to-format
If you can't understand the cause of this issue or you don't know how to fix it, please submit a GitHub issue, we will try to help you: https://github.com/yegor256/pdd/issues. This tool is still in its beta version and we will appreciate your feedback. Here is where you can find more documentation: https://github.com/yegor256/pdd/blob/master/README.md.
Exit code is 1

/app/objects/git_repo.rb:66:in `rescue in block in xml'
/app/objects/git_repo.rb:63:in `block in xml'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/tempfile.rb:295:in `open'
/app/objects/git_repo.rb:62:in `xml'
/app/objects/puzzles.rb:36:in `deploy'
/app/objects/job.rb:38:in `proceed'
/app/objects/job_starred.rb:33:in `proceed'
/app/objects/job_recorded.rb:32:in `proceed'
/app/objects/job_emailed.rb:35:in `proceed'
/app/objects/job_commiterrors.rb:36:in `proceed'
/app/objects/job_detached.rb:48:in `exclusive'
/app/objects/job_detached.rb:36:in `block in proceed'
/app/objects/job_detached.rb:36:in `fork'
/app/objects/job_detached.rb:36:in `proceed'
/app/0pdd.rb:357:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `block in compile!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1032:in `route_eval'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1061:in `block in process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1011:in `block in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `each'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1129:in `block in dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1124:in `dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `block in call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:929:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/xss_header.rb:18:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/path_traversal.rb:16:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/json_csrf.rb:26:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/frame_options.rb:31:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/logger.rb:17:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:253:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:246:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:216:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1991:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `block in call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1769:in `synchronize'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'

Please sign in to comment.