Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
ProofScriptParser
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sarah.grebing
ProofScriptParser
Commits
51bc8891
Commit
51bc8891
authored
Apr 28, 2017
by
Alexander Weigl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes to the grammar
in preparation for an visitor
parent
588a76d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
39 deletions
+57
-39
src/main/antlr4/edu/kit/formal/proofscriptparser/ScriptLanguage.g4
...antlr4/edu/kit/formal/proofscriptparser/ScriptLanguage.g4
+57
-39
No files found.
src/main/antlr4/ScriptLanguage.g4
→
src/main/antlr4/
edu/kit/formal/proofscriptparser/
ScriptLanguage.g4
View file @
51bc8891
/** Optional javadoc style comment */
grammar ScriptLanguage;
start
: (SCRIPT
ID '(' argList? ')' INDENT
stmtList DEDENT)*
: (SCRIPT
name=ID '(' paramters=argList? ')' INDENT body=
stmtList DEDENT)*
;
argList
...
...
@@ -21,7 +19,7 @@ type
;
stmtList
: statement
+
: statement
*
;
statement
...
...
@@ -35,38 +33,44 @@ statement
;
assignment
:
ID (':' type)? ':='
expression SEMICOLON
:
variable=ID (COLON type)? ASSIGN
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
;
:
MINUS expression #exprMinus
| NEGATE expression #exprNegate
| expression MUL expression #exprMultiplication
| <assoc=right> expression DIV expression #exprDivision
| expression op=(PLUS|MINUS) expression #exprLineOperators
| expression op=(LE|GE|LEQ|GEQ) expression #exprComparison
| expression op=(NEQ|EQ) expression #exprEquality
| expression AND expression #exprAnd
| expression OR expression #exprOr
| expression IMP expression #exprIMP
//| expression EQUIV expression already covered by EQ/NEQ
| '(' expression ')' #exprParen
| literals #exprLiterals
| matchPattern #exprMatch
;
literals :
ID #literalID
| DIGITS #literalDigits
| TERM_LITERAL #literalTerm
| STRING_LITERAL #literalString
| TRUE #literalTrue
| FALSE #literalFalse
;
/**
* Example: <pre>
match `f(x) ==>` using [x:term]
</pre>*/
matchPattern
: 'match' TERM 'using' '[' ID COLON type (',' ID COLON type)* ']'
: MATCH ( TERM_LITERAL | ID)
(USING LBRACKET argList RBRACKET)?
;
scriptVar
...
...
@@ -78,12 +82,12 @@ repeatStmt
;
casesStmt
:
'cases'
INDENT casesList+ DEDENT
:
CASES
INDENT casesList+ DEDENT
;
casesList
:
'case'
expression COLON INDENT stmtList DEDENT casesList*
|
'default'
COLON INDENT stmtList DEDENT
:
CASE
expression COLON INDENT stmtList DEDENT casesList*
|
DEFAULT
COLON INDENT stmtList DEDENT
;
forEachStmt
...
...
@@ -105,6 +109,14 @@ callStmt
//LEXER Rules
WS : [ \t\n\r]+ -> skip ;
CASES: 'cases';
CASE: 'case';
DEFAULT: 'default';
ASSIGN : ':=';
LBRACKET: '[';
RBRACKET:']';
USING : 'using';
MATCH : 'match';
SCRIPT : 'script' ;
TRUE : 'true' ;
FALSE : 'false' ;
...
...
@@ -122,8 +134,15 @@ INDENT : '{' ;
DEDENT : '}' ;
SEMICOLON : ';' ;
COLON : ':' ;
STRINGLIT : '"' ~["]* '"' ;
TERM : '`' ~[`]* '`' ;
STRING_LITERAL
: '\'' ('\'\'' | ~ ('\''))* '\''
;
TERM_LITERAL
: '`' ~('`')* '`'
;
PLUS : '+' ;
MINUS : '-' ;
MUL : '*' ;
...
...
@@ -138,8 +157,7 @@ AND : '&' ;
OR: '|' ;
IMP : '->' ;
EQUIV : '<=>' ;
NEGATE: 'not';
//options {...}
//import ... ;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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