Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/antlr/grammars-v4 into an…
…tlr-plugin
- Loading branch information
Showing
8 changed files
with
180 additions
and
25 deletions.
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
**/.DS_Store | ||
/**/.project | ||
/**/.classpath | ||
/**/.settings/ | ||
/**/target | ||
|
||
.fetch_time_cache | ||
**/.DS_Store | ||
/**/.project | ||
/**/.classpath | ||
/**/.settings/ | ||
/**/target | ||
|
||
.fetch_time_cache | ||
|
||
#IntelliJ Idea project files | ||
.idea/ | ||
*.iml |
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
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,11 @@ | ||
#ONCRPCv2 and XDR grammars | ||
|
||
External Data Representation (XDR) is a data serialization format defined | ||
by [RFC 4506](https://tools.ietf.org/html/rfc4506) (which obsoletes the | ||
previous definition in [RFC 1832](https://tools.ietf.org/html/rfc1832)). | ||
|
||
Open Network Computing Remote Procedure Call (ONCRPC) aka SunRPC is a | ||
remote procedure call system that uses XDR for serialization. version 2 | ||
is defined by [RFC 5531](https://tools.ietf.org/html/rfc5531) | ||
|
||
ONCRPC is the rpc mechanism that NFS (Network File System) is built on. |
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,12 @@ | ||
struct CalculationResult { | ||
hyper result; | ||
unsigned hyper startMillis; | ||
unsigned hyper finishMillis; | ||
}; | ||
|
||
program CALCULATOR { | ||
version CALCULATORVERS { | ||
CalculationResult add(hyper, hyper) = 1; | ||
hyper addSimple(hyper, hyper) = 2; | ||
} = 1; | ||
} = 117; |
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,16 @@ | ||
grammar oncrpcv2; | ||
import xdr; | ||
|
||
//oncrpcv2 additions on top of xdr (rfc 5531) | ||
programDef: 'program' IDENTIFIER '{' | ||
versionDef | ||
versionDef* | ||
'}' '=' constant ';'; | ||
versionDef: 'version' IDENTIFIER '{' | ||
procedureDef | ||
procedureDef* | ||
'}' '=' constant ';'; | ||
procedureDef: procReturn IDENTIFIER '(' procFirstArg (',' typeSpecifier)* ')' '=' constant ';'; | ||
procReturn: 'void' | typeSpecifier; | ||
procFirstArg: 'void' | typeSpecifier; | ||
oncrpcv2Specification : (xdrSpecification | programDef)*; //this is the top level rule for oncrpcv2 (rfc 5531) |
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 @@ | ||
<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> | ||
<artifactId>oncrpc</artifactId> | ||
<packaging>jar</packaging> | ||
<name>ONCRPC and XDR grammars</name> | ||
<parent> | ||
<groupId>com.antlr.grammarsv4</groupId> | ||
<artifactId>grammarsv4</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-maven-plugin</artifactId> | ||
<version>${antlr.version}</version> | ||
<configuration> | ||
<sourceDirectory>${basedir}</sourceDirectory> | ||
<visitor>true</visitor> | ||
<listener>true</listener> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>antlr4</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4test-maven-plugin</artifactId> | ||
<configuration> | ||
<verbose>false</verbose> | ||
<showTree>false</showTree> | ||
<entryPoint>oncrpcv2Specification</entryPoint> | ||
<grammarName>oncrpcv2</grammarName> | ||
<packageName></packageName> | ||
<exampleFiles>examples/</exampleFiles> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,57 @@ | ||
grammar xdr; | ||
|
||
// parser rules | ||
|
||
declaration: | ||
typeSpecifier IDENTIFIER | ||
| typeSpecifier IDENTIFIER '[' value ']' | ||
| typeSpecifier IDENTIFIER '<' value? '>' | ||
| 'opaque' IDENTIFIER '[' value ']' | ||
| 'opaque' IDENTIFIER '<' value? '>' | ||
| 'string' IDENTIFIER '<' value? '>' | ||
| typeSpecifier '*' IDENTIFIER | ||
| 'void' | ||
; | ||
value: constant | IDENTIFIER; | ||
constant: DECIMAL | HEXADECIMAL | OCTAL; | ||
typeSpecifier: | ||
'unsigned'? 'int' | ||
| 'unsigned'? 'hyper' | ||
| 'float' | ||
| 'double' | ||
| 'quadruple' | ||
| 'bool' | ||
| enumTypeSpec | ||
| structTypeSpec | ||
| unionTypeSpec | ||
| IDENTIFIER | ||
; | ||
enumTypeSpec: 'enum' enumBody; | ||
enumBody: '{' (IDENTIFIER '=' value) (',' IDENTIFIER '=' value)* '}'; | ||
structTypeSpec: 'struct' structBody; | ||
structBody: '{' (declaration ';') (declaration ';')* '}'; | ||
unionTypeSpec: 'union' unionBody; | ||
unionBody: 'switch' '(' declaration ')' '{' | ||
caseSpec | ||
caseSpec* | ||
('default' ':' declaration ';')? | ||
'}'; | ||
caseSpec: ('case' value ':') ('case' value ':')* declaration ';'; | ||
constantDef: 'const' IDENTIFIER '=' constant ';'; | ||
typeDef: | ||
'typedef' declaration ';' | ||
| 'enum' IDENTIFIER enumBody ';' | ||
| 'struct' IDENTIFIER structBody ';' | ||
| 'union' IDENTIFIER unionBody ';' | ||
; | ||
definition: typeDef | constantDef; | ||
xdrSpecification: definition+; //this is the top level rule for xdr (rfc 4506) | ||
|
||
// lexer rules | ||
|
||
COMMENT : '/*' .*? '*/' -> skip; | ||
OCTAL : '0' [1-7] ([0-7])*; | ||
DECIMAL : ('-')? ([0-9])+; | ||
HEXADECIMAL : '0x' ([a-fA-F0-9])+; | ||
IDENTIFIER : [a-zA-Z] ([a-zA-Z0-9_])*; | ||
WS : [ \t\r\n]+ -> skip; |
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