Parser for tapir file and transformer. Started on generator.
This commit is contained in:
parent
e4b1daf0c2
commit
f0e2523a3d
3 changed files with 186 additions and 0 deletions
57
parser/pom.xml
Executable file
57
parser/pom.xml
Executable file
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>nu.zoom.tapir</groupId>
|
||||
<artifactId>tapir-generator</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>parser</artifactId>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>javacc-maven-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<!--
|
||||
<id>javacc</id>
|
||||
<goals>
|
||||
<goal>javacc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<lookAhead>2</lookAhead>
|
||||
<isStatic>false</isStatic>
|
||||
<forceLaCheck>true</forceLaCheck>
|
||||
</configuration>
|
||||
</execution>
|
||||
-->
|
||||
<execution>
|
||||
<id>jjtree-javacc</id>
|
||||
<goals>
|
||||
<goal>jjtree-javacc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<isStatic>false</isStatic>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.javacc</groupId>
|
||||
<artifactId>javacc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>info.picocli</groupId>
|
||||
<artifactId>picocli</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
93
parser/src/main/jjtree/tapir.jjt
Executable file
93
parser/src/main/jjtree/tapir.jjt
Executable file
|
@ -0,0 +1,93 @@
|
|||
|
||||
PARSER_BEGIN(TapirParser)
|
||||
package nu.zoom.tapir.parser;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class TapirParser
|
||||
{
|
||||
}
|
||||
|
||||
PARSER_END(TapirParser)
|
||||
|
||||
// white space
|
||||
SKIP: {
|
||||
"\n"
|
||||
| "\t"
|
||||
| "\r"
|
||||
| " "
|
||||
}
|
||||
|
||||
TOKEN : {
|
||||
<OPENPARANTHESIS: "(">
|
||||
| <CLOSEPARANTHESIS: ")">
|
||||
| <TRANSITION: "->">
|
||||
| <SLASH: "/">
|
||||
| <COLON: ":">
|
||||
| <COMMA: ",">
|
||||
| <LETTER: [ "A"-"Z", "a"-"z" ]>
|
||||
| <IDENTIFIER: ( <LETTER>)+ >
|
||||
}
|
||||
|
||||
void path() :
|
||||
{Token t;}
|
||||
{
|
||||
t=<IDENTIFIER>{jjtThis.value = t.image;} <SLASH>
|
||||
}
|
||||
|
||||
void paths() :
|
||||
{}
|
||||
{
|
||||
path() (path())*
|
||||
}
|
||||
|
||||
void payloadFieldName() :
|
||||
{Token t;}
|
||||
{
|
||||
t=<IDENTIFIER>{jjtThis.value = t.image;}
|
||||
}
|
||||
|
||||
void payloadFieldType() :
|
||||
{Token t;}
|
||||
{
|
||||
t=<IDENTIFIER>{jjtThis.value = t.image;}
|
||||
}
|
||||
|
||||
void payloadField() :
|
||||
{}
|
||||
{
|
||||
payloadFieldName() <COLON> payloadFieldType()
|
||||
}
|
||||
|
||||
void payloadFields() :
|
||||
{}
|
||||
{
|
||||
payloadField() (<COMMA> payloadField() )*
|
||||
}
|
||||
|
||||
void handlerName() :
|
||||
{Token t;}
|
||||
{
|
||||
t=<IDENTIFIER>{jjtThis.value = t.image;}
|
||||
}
|
||||
|
||||
void handlerSpec() :
|
||||
{}
|
||||
{
|
||||
handlerName() <OPENPARANTHESIS> payloadFields() <CLOSEPARANTHESIS>
|
||||
}
|
||||
|
||||
void endpoint() :
|
||||
{}
|
||||
{
|
||||
paths() <TRANSITION> handlerSpec()
|
||||
}
|
||||
|
||||
SimpleNode endpoints() :
|
||||
{}
|
||||
{
|
||||
(endpoint() )*
|
||||
{ return jjtThis; }
|
||||
}
|
36
pom.xml
Executable file
36
pom.xml
Executable file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
|
||||
<groupId>nu.zoom.tapir</groupId>
|
||||
<artifactId>tapir-generator</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>parser</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>23</maven.compiler.source>
|
||||
<maven.compiler.target>23</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.javacc</groupId>
|
||||
<artifactId>javacc</artifactId>
|
||||
<version>7.0.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>info.picocli</groupId>
|
||||
<artifactId>picocli</artifactId>
|
||||
<version>4.7.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
Loading…
Add table
Reference in a new issue