Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
sarah.grebing
ProofScriptParser
Commits
39738b60
Commit
39738b60
authored
Apr 27, 2017
by
Sarah Grebing
Browse files
init ProofScriptLanguage and Maven Project
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
pom.xml
0 → 100644
View file @
39738b60
<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>
edu.kit.formal
</groupId>
<artifactId>
ScriptParser
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<packaging>
jar
</packaging>
<name>
ScriptParser
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.target>
1.8
</maven.compiler.target>
<maven.compiler.source>
1.8
</maven.compiler.source>
</properties>
<build>
<plugins>
<plugin>
<groupId>
org.antlr
</groupId>
<artifactId>
antlr4-maven-plugin
</artifactId>
<version>
4.3
</version>
<executions>
<execution>
<id>
antlr
</id>
<goals>
<goal>
antlr4
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
src/main/antlr4/ScriptLanguage.g4
0 → 100644
View file @
39738b60
/** Optional javadoc style comment */
grammar ScriptLanguage;
start
: (SCRIPT ID '(' argList? ')' INDENT stmtList DEDENT)*
;
argList
: varDecl (',' varDecl)+
;
varDecl
: ID ':' type
;
type
: INT
| BOOL
| TERMTYPE
;
stmtList
: statement+
;
statement
: assignment
| repeatStmt
| casesStmt
| forEachStmt
| theOnlyStmt
| scriptCommand
| callStmt
;
assignment
: ID (':' type)? ':=' expression SEMICOLON
;
expression
: matchPattern
| '-' expression
| 'not' expression
| expression MUL expression
| <assoc=right> expression DIV expression
| expression (PLUS|MINUS) expression
| expression LE expression
| expression GE expression
| expression LEQ expression
| expression GEQ expression
| expression EQ expression
| expression NEQ expression
| expression AND expression
| expression OR expression
| expression IMP expression
| expression EQUIV expression
| scriptVar
| ID
| DIGITS
| '(' expression ')'
| TERM
| STRINGLIT
| TRUE
| FALSE
;
matchPattern
: 'match' TERM 'using' '[' ID COLON type (',' ID COLON type)* ']'
;
scriptVar
: '?' ID
;
repeatStmt
: REPEAT INDENT stmtList DEDENT
;
casesStmt
: 'cases' INDENT casesList+ DEDENT
;
casesList
: 'case' expression COLON INDENT stmtList DEDENT casesList*
| 'default' COLON INDENT stmtList DEDENT
;
forEachStmt
: FOREACH INDENT stmtList DEDENT
;
theOnlyStmt
: THEONLY INDENT stmtList DEDENT
;
scriptCommand
: ID (ID '=' expression)* SEMICOLON
;
callStmt
: CALL scriptCommand SEMICOLON
;
//LEXER Rules
WS : [ \t\n\r]+ -> skip ;
SCRIPT : 'script' ;
TRUE : 'true' ;
FALSE : 'false' ;
CALL : 'call' ;
REPEAT : 'repeat' ;
INT : 'int' ;
BOOL: 'bool' ;
TERMTYPE : 'term' ;
FOREACH : 'foreach' ;
THEONLY : 'theonly' ;
ID : [a-zA-Z] [_a-zA-Z0-9]* ;
DIGITS : DIGIT+ ;
fragment DIGIT : [0-9] ;
INDENT : '{' ;
DEDENT : '}' ;
SEMICOLON : ';' ;
COLON : ':' ;
STRINGLIT : '"' ~["]* '"' ;
TERM : '`' ~[`]* '`' ;
PLUS : '+' ;
MINUS : '-' ;
MUL : '*' ;
DIV : '/' ;
EQ : '=' ;
NEQ : '!=' ;
GEQ : '>=' ;
LEQ : '<=' ;
GE : '>' ;
LE : '<' ;
AND : '&' ;
OR: '|' ;
IMP : '->' ;
EQUIV : '<=>' ;
//options {...}
//import ... ;
//tokens {...}
//channels {...} // lexer only
//@actionName {...}
/*
//Script ::= 'script' ID (ARGLIST)? NEWLINE INDENT Cmd DEDENT | Cmd
Cmd ::= //Cmd ';' Cmd |
VarAssign |
//'repeat' NEWLINE INDENT Cmd+ DEDENT |
'cases' NEWLINE DEDENT Case+ ('default:' NEWLINE INDENT Cmd DEDENT)? DEDENT |
'foreach' NEWLINE INDENT Cmd+ DEDENT |
'theonly'NEWLINE INDENT cmd DEDENT |
// Cmd 'on' (ShemaTerm | ShemaVar)+ ('with' (ShemaVar| ShemaTerm))? |
'call' scriptCommand;
Case ::= 'case' BoolExpr ':' NEWLINE INDENT Cmd+ DEDENT
VarAssign ::= ID ':' TYPE |
ID ':=' (AExpr| BExpr | ///PosExpr) //PosExp evtl. das matchpattern für Sequents?
//MatchPattern ::= 'match' ('Seq'? ShemaSeq) |
// ('matchLabel'| 'matchRule') RegExpr
// 'match' ( `~[`]` | '~[\']' | ID)
*/
/*arithExpr
: ID
| DIGITS
| arithExpr arithOp arithExpr
;
arithOp
: '+' | '-' | '*' | '/'
;
boolExpr
: TRUE
| FALSE
| matchPattern
| 'not' boolExpr
| boolExpr boolOp boolExpr
| arithExpr relOp arithExpr
;
boolOp
: 'and' | 'or'
;
relOp
: '<' | '<=' | '=' | '>' | '>='
;
*/
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment