-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cukexit - the cucumber exit :P in full swing
we have a working antlr parser and even the execution life-cycle working the main thing pending is now reporting everything is very compact and arguably tightly-coupled, no interfaces and de-coupling a test case validates that every gherkin in the karate source tree is parse-able this karate-antlr sub maven-module is temporary and will merge into karate-core when the time is right
- Loading branch information
Showing
20 changed files
with
1,425 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.intuit.karate</groupId> | ||
<artifactId>karate-parent</artifactId> | ||
<version>0.9.0</version> | ||
</parent> | ||
<artifactId>karate-antlr</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<antlr.version>4.7.1</antlr.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.intuit.karate</groupId> | ||
<artifactId>karate-apache</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-runtime</artifactId> | ||
<version>${antlr.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<testResources> | ||
<testResource> | ||
<directory>src/test/java</directory> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
</excludes> | ||
</testResource> | ||
</testResources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-maven-plugin</artifactId> | ||
<version>${antlr.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>antlr4</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.sonatype.plugins</groupId> | ||
<artifactId>nexus-staging-maven-plugin</artifactId> | ||
<version>${nexus.staging.plugin.version}</version> | ||
<configuration> | ||
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
53 changes: 53 additions & 0 deletions
53
karate-antlr/src/main/antlr4/com/intuit/karate/core/KarateLexer.g4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2018 Intuit Inc. | ||
* | ||
* 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. | ||
*/ | ||
lexer grammar KarateLexer; | ||
|
||
FEATURE_COMMENT: WS* '#' ~[\r\n]* BOL+ -> channel(HIDDEN) ; | ||
FEATURE_TAGS: WS* '@' ~[\r\n]+ BOL+ ; | ||
FEATURE: 'Feature:' WS* -> pushMode(MAIN) ; // we never popMode ! | ||
|
||
fragment BOL: [\r\n]+ [ \t]* ; // Beginning Of Line | ||
fragment WS: [ \t] ; // White Space | ||
|
||
mode MAIN; // ================================================================== | ||
|
||
BACKGROUND: BOL+ 'Background:' WS* ; | ||
SCENARIO: BOL+ 'Scenario:' WS* ; | ||
SCENARIO_OUTLINE: BOL+ 'Scenario Outline:' WS* ; | ||
EXAMPLES: BOL+ 'Examples:' WS* ; | ||
|
||
STAR: BOL+ '*' WS+ ; | ||
GIVEN: BOL+ 'Given' WS+ ; | ||
WHEN: BOL+ 'When' WS+ ; | ||
THEN: BOL+ 'Then' WS+ ; | ||
AND: BOL+ 'And' WS+ ; | ||
BUT: BOL+ 'But' WS+ ; | ||
|
||
COMMENT: BOL+ '#' ~[\r\n]* -> channel(HIDDEN) ; | ||
TAGS: BOL+ '@' ~[\r\n]+ ; | ||
TABLE_ROW: BOL+ '|' ~[\r\n]+ ; | ||
DOC_STRING: BOL+ '"""' .*? '"""' ~[\r\n]* ; | ||
|
||
CHAR: ~[\r\n] ; | ||
NEWLINE: BOL+ ; |
54 changes: 54 additions & 0 deletions
54
karate-antlr/src/main/antlr4/com/intuit/karate/core/KarateParser.g4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2018 Intuit Inc. | ||
* | ||
* 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. | ||
*/ | ||
parser grammar KarateParser ; | ||
|
||
options { tokenVocab=KarateLexer; } | ||
|
||
feature: featureSection background? ( scenario | scenarioOutline )* NEWLINE? EOF ; | ||
|
||
featureSection: FEATURE_TAGS? FEATURE featureDescription; | ||
|
||
featureDescription: ~(BACKGROUND | SCENARIO | SCENARIO_OUTLINE)* ; | ||
|
||
background: BACKGROUND step* ; | ||
|
||
scenario: tags? SCENARIO scenarioDescription step* ; | ||
|
||
scenarioDescription: ~(STAR | GIVEN | WHEN | THEN | AND | BUT | SCENARIO | SCENARIO_OUTLINE)* ; | ||
|
||
scenarioOutline: tags? SCENARIO_OUTLINE scenarioDescription step* examples+ ; | ||
|
||
examples: tags? EXAMPLES table ; | ||
|
||
step: prefix line ( docString | table )? ; | ||
|
||
prefix: STAR | GIVEN | WHEN | THEN | AND | BUT ; | ||
|
||
line: CHAR+ ; | ||
|
||
tags: TAGS ; | ||
|
||
docString: DOC_STRING ; | ||
|
||
table: TABLE_ROW+ ; |
49 changes: 49 additions & 0 deletions
49
karate-antlr/src/main/java/com/intuit/karate/core/Background.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2018 Intuit Inc. | ||
* | ||
* 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 com.intuit.karate.core; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author pthomas3 | ||
*/ | ||
public class Background { | ||
|
||
private List<Step> steps; | ||
|
||
public List<Step> getSteps() { | ||
return steps; | ||
} | ||
|
||
public void setSteps(List<Step> steps) { | ||
this.steps = steps; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return steps == null ? null : steps.toString(); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
karate-antlr/src/main/java/com/intuit/karate/core/ExampleTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2018 Intuit Inc. | ||
* | ||
* 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 com.intuit.karate.core; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author pthomas3 | ||
*/ | ||
public class ExampleTable { | ||
|
||
private List<Tag> tags; | ||
private Table table; | ||
|
||
public List<Tag> getTags() { | ||
return tags; | ||
} | ||
|
||
public void setTags(List<Tag> tags) { | ||
this.tags = tags; | ||
} | ||
|
||
public Table getTable() { | ||
return table; | ||
} | ||
|
||
public void setTable(Table table) { | ||
this.table = table; | ||
} | ||
|
||
} |
Oops, something went wrong.