Skip to content

Commit

Permalink
release 1.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Thome committed Jun 23, 2017
1 parent 379c75a commit cf2dccf
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 26 deletions.
2 changes: 1 addition & 1 deletion inmemantlr-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.github.julianthome</groupId>
<artifactId>inmemantlr</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.3.5</version>
<version>1.3.6</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public void compile() throws CompilationException {
* @return context
* @throws IllegalWorkflowException if compilation did not take place
* @throws FileNotFoundException if input file cannot be found
* @throws ParsingException if an error occurs while parsing
*/
public ParserRuleContext parse(File toParse) throws
IllegalWorkflowException, FileNotFoundException,ParsingException {
Expand All @@ -317,6 +318,7 @@ public ParserRuleContext parse(File toParse) throws
* @param toParse string to parse
* @return context
* @throws IllegalWorkflowException if compilation did not take place
* @throws ParsingException if an error occurs while parsing
*/
public ParserRuleContext parse(String toParse) throws
IllegalWorkflowException, ParsingException {
Expand All @@ -331,6 +333,7 @@ public ParserRuleContext parse(String toParse) throws
* @return context
* @throws IllegalWorkflowException sources are not compiled
* @throws FileNotFoundException file not found
* @throws ParsingException if an error occurs while parsing
*/
public ParserRuleContext parse(File toParse, String production) throws
IllegalWorkflowException, FileNotFoundException, ParsingException {
Expand All @@ -348,6 +351,7 @@ public ParserRuleContext parse(File toParse, String production) throws
* @param production production name to parse
* @return context
* @throws IllegalWorkflowException if compilation did not take place
* @throws ParsingException if an error occurs while parsing
*/
public ParserRuleContext parse(String toParse, String production) throws
IllegalWorkflowException, ParsingException {
Expand Down Expand Up @@ -412,6 +416,7 @@ public ParserRuleContext parse(String toParse, String production) throws
.getValue()).collect(Collectors.toSet());



if(msgs.size() > 0) {
String result = msgs
.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/**
* org.snt.inmemantlr.tool.Inmemantlr - In memory compiler for Antlr 4
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Julian Thome <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**/

package org.snt.inmemantlr.exceptions;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/**
* org.snt.inmemantlr.tool.Inmemantlr - In memory compiler for Antlr 4
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Julian Thome <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**/

package org.snt.inmemantlr.tool;

import org.antlr.v4.runtime.BaseErrorListener;
Expand All @@ -6,6 +32,8 @@
import org.antlr.v4.runtime.Recognizer;
import org.antlr.v4.runtime.atn.ATNConfigSet;
import org.antlr.v4.runtime.dfa.DFA;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.BitSet;
import java.util.HashMap;
Expand All @@ -17,12 +45,13 @@
public class InmemantlrErrorListener extends BaseErrorListener {


private static final Logger LOGGER = LoggerFactory.getLogger(BaseErrorListener.class);

public enum Type {
SYNTAX_ERROR,
AMBIGUITY,
FULL_CTX,
CTX_SSTV

}

Map<Type,String> log = new HashMap<>();
Expand Down
71 changes: 71 additions & 0 deletions inmemantlr-api/src/test/java/TestBroken.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Inmemantlr - In memory compiler for Antlr 4
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Julian Thome <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**/

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.snt.inmemantlr.GenericParser;
import org.snt.inmemantlr.exceptions.CompilationException;
import org.snt.inmemantlr.listener.DefaultTreeListener;
import org.snt.inmemantlr.utils.FileUtils;

import java.io.IOException;
import java.io.InputStream;

import static org.junit.Assert.assertFalse;

public class TestBroken {

private static final Logger LOGGER = LoggerFactory.getLogger(TestBroken.class);

String sgrammarcontent = "";

@Test
public void testBroken() throws IOException {

try (InputStream sgrammar = getClass().getClassLoader()
.getResourceAsStream("inmemantlr/Broken.g4")) {
sgrammarcontent = FileUtils.getStringFromStream(sgrammar);
}

GenericParser gp = new GenericParser(sgrammarcontent);
DefaultTreeListener t = new DefaultTreeListener();

gp.setListener(t);

boolean compile;

try {
gp.compile();
compile = true;
} catch (CompilationException e) {
compile = false;
}

assertFalse(compile);
}

}
11 changes: 11 additions & 0 deletions inmemantlr-api/src/test/java/TestExternalGrammars.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,17 @@ public void testEcmaScript() {
testSubject(s, false);
}

@Test
public void testErlang() {

if (!toCheck("erlang"))
return;

Subject s = subjects.get("erlang");
//s.g4.removeIf(f -> !f.getName().equals("ECMAScript.g4"));
testSubject(s, false);
}

@Test
public void testZ() {

Expand Down
32 changes: 32 additions & 0 deletions inmemantlr-api/src/test/resources/inmemantlr/Broken.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
ANTLR4 grammar taken from TypeScript Documentation:
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#12.1.2
https://www.typescriptlang.org/docs/tutorial.html
https://basarat.gitbooks.io/typescript/content/
https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript
IntelliJ with antlr4 plugin used: http://plugins.jetbrains.com/plugin/7358?pr=
to develop this grammar
*/


grammar Fail;


s : RULE | STRICT;

RULE : '[a-z]';

DIGIT: '[0-9]';

STRICT:
{!strictMode}? '0' DIGIT+
;


//
// Whitespace and comments
//

WS: [ \t\r\n\u000C]+ -> skip
;
2 changes: 1 addition & 1 deletion inmemantlr-graal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>inmemantlr</artifactId>
<groupId>com.github.julianthome</groupId>
<version>1.3.5</version>
<version>1.3.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.snt.inmemantlr.GenericParser;
import org.snt.inmemantlr.exceptions.CompilationException;
import org.snt.inmemantlr.exceptions.IllegalWorkflowException;
import org.snt.inmemantlr.exceptions.ParsingException;
import org.snt.inmemantlr.listener.DefaultTreeListener;
import org.snt.inmemantlr.tool.ToolCustomizer;
import org.snt.inmemantlr.tree.Ast;
Expand Down Expand Up @@ -81,7 +82,7 @@ public enum GraalParser {
public Ast getAstForGrammar(File grammar) throws FileNotFoundException {
try {
gp.parse(grammar);
} catch (IllegalWorkflowException e) {
} catch (IllegalWorkflowException | ParsingException e) {
assert false;
}
return dt.getAst();
Expand Down
4 changes: 2 additions & 2 deletions inmemantlr-tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.github.julianthome</groupId>
<artifactId>inmemantlr</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.3.5</version>
<version>1.3.6</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -77,7 +77,7 @@
<dependency>
<groupId>com.github.julianthome</groupId>
<artifactId>inmemantlr-api</artifactId>
<version>1.3.5</version>
<version>1.3.6</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.snt.inmemantlr.tool; /**
/**
* org.snt.inmemantlr.tool.Inmemantlr - In memory compiler for Antlr 4
*
* The MIT License (MIT)
Expand All @@ -24,24 +24,26 @@
* SOFTWARE.
**/

import org.apache.commons.cli.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.LoggerFactory;
import org.snt.inmemantlr.GenericParser;
import org.snt.inmemantlr.exceptions.CompilationException;
import org.snt.inmemantlr.exceptions.IllegalWorkflowException;
import org.snt.inmemantlr.exceptions.ParsingException;
import org.snt.inmemantlr.listener.DefaultTreeListener;
import org.snt.inmemantlr.tree.Ast;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
package org.snt.inmemantlr.tool;

import org.apache.commons.cli.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.LoggerFactory;
import org.snt.inmemantlr.GenericParser;
import org.snt.inmemantlr.exceptions.CompilationException;
import org.snt.inmemantlr.exceptions.IllegalWorkflowException;
import org.snt.inmemantlr.exceptions.ParsingException;
import org.snt.inmemantlr.listener.DefaultTreeListener;
import org.snt.inmemantlr.tree.Ast;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

/**
* inmemantlr command line tool
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.julianthome</groupId>
<artifactId>inmemantlr</artifactId>
<version>1.3.5</version>
<version>1.3.6</version>
<packaging>pom</packaging>

<modules>
Expand Down

0 comments on commit cf2dccf

Please sign in to comment.