Skip to content

Commit

Permalink
Update of my thesis
Browse files Browse the repository at this point in the history
  • Loading branch information
szabototo89 committed May 2, 2014
1 parent e2ebfc9 commit e944cd1
Show file tree
Hide file tree
Showing 35 changed files with 995 additions and 410 deletions.
Binary file modified docs/Diplomamunka_Szabo_Tamas.docx
Binary file not shown.
Binary file modified docs/graphics/szintaxisfa.vsdx
Binary file not shown.
Binary file removed docs/graphics/~$$szintaxisfa.~vsdx
Binary file not shown.
Binary file removed docs/~$akdolgozat_kovetelmenyek.docx
Binary file not shown.
44 changes: 32 additions & 12 deletions grammar-imperative/Imperative.g4
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
grammar Imperative;

init: (statement)+;
//| functionDefinition
//| macroDefinition)*;

statement : skip
| assignment
| functionCall
| ifStatement
| loopStatement
;
init: sequence
| functionDefinition
| procedureDefinition
;
//| macroDefinition;

functionDefinition : 'function' ID '(' formalParameters? ')' 'returns' ID 'begin'
sequence
'endfunction'
;

procedureDefinition : 'procedure' ID '(' formalParameters? ')' 'begin'
sequence
'endfunction'
;

formalParameters : (ID ':' ID) (',' (ID ':' ID))*
;

statement : skip
| assignment
| returnStatement
| functionCall
| ifStatement
| loopStatement
;

returnStatement : 'return' expression;

sequence : statement+;

skip : 'skip'
;

assignment : ID ':=' expression
;

ifStatement : 'if' '(' expression ')' 'then' statement+ 'endif'
ifStatement : 'if' '(' expression ')' 'then' sequence 'endif'
;

loopStatement : 'loop' '(' expression ')' 'do' statement+ 'end' 'loop'
loopStatement : 'loop' '(' expression ')' 'do' sequence 'endloop'
;

functionCall : ID '(' actualParameters ')'
Expand Down
10 changes: 9 additions & 1 deletion grammar-imperative/example.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
function max(a: Integer, b: Integer) returns Integer
begin
if (a > b) then
return a
endif
return b
endfunction

print("Program futásának kezdete ...")
i := 0
loop (i < 10) do
print(toString(i) + " sor: ")
i := i + 1
end loop
endloop
print("Program futásának vége.")
122 changes: 68 additions & 54 deletions grammar-imperative/src/Imperative.tokens
Original file line number Diff line number Diff line change
@@ -1,54 +1,68 @@
T__23=1
T__22=2
T__21=3
T__20=4
NUMBER=27
WHITESPACE=29
ID=28
T__9=15
T__8=16
T__7=17
T__6=18
T__5=19
T__4=20
T__19=5
BOOLEAN=25
T__16=8
T__15=9
T__18=6
T__17=7
T__12=12
T__11=13
T__14=10
T__13=11
T__1=23
T__0=24
T__10=14
T__3=21
T__2=22
NEW_LINE=30
STRING=26
'end'=24
'>='=23
'skip'=22
'=='=21
'/'=20
'then'=19
':='=18
'and'=17
'>'=16
'<='=15
'!='=14
'<'=13
'if'=12
'not'=10
'('=11
'-'=7
'*'=8
'or'=9
'+'=6
','=5
'endif'=3
')'=4
'loop'=2
'do'=1
T__29=2
T__28=3
T__27=4
T__26=5
T__25=6
T__24=7
T__23=8
T__22=9
T__21=10
T__20=11
NUMBER=34
WHITESPACE=36
ID=35
T__9=22
T__8=23
T__7=24
T__6=25
T__5=26
T__4=27
T__19=12
T__30=1
BOOLEAN=32
T__16=15
T__15=16
T__18=13
T__17=14
T__12=19
T__11=20
T__14=17
T__13=18
T__1=30
T__0=31
T__3=28
T__10=21
T__2=29
NEW_LINE=37
STRING=33
'>='=31
'=='=30
'returns'=29
'/'=28
'begin'=27
'then'=26
':='=25
'>'=24
'return'=23
'+'=22
'procedure'=21
'function'=19
')'=20
'loop'=18
'do'=17
'endloop'=16
'skip'=15
'and'=14
'<='=13
'!='=12
'<'=11
'if'=10
':'=9
'('=8
'not'=7
'or'=6
'endfunction'=5
'-'=4
'*'=3
','=2
'endif'=1
Binary file modified grammar-imperative/src/ImperativeBaseListener.class
Binary file not shown.
97 changes: 81 additions & 16 deletions grammar-imperative/src/ImperativeBaseListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,91 @@ public class ImperativeBaseListener implements ImperativeListener {
* <p/>
* The default implementation does nothing.
*/
@Override public void enterStatement(@NotNull ImperativeParser.StatementContext ctx) { }
@Override public void enterConstant(@NotNull ImperativeParser.ConstantContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitStatement(@NotNull ImperativeParser.StatementContext ctx) { }
@Override public void exitConstant(@NotNull ImperativeParser.ConstantContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterFunctionCall(@NotNull ImperativeParser.FunctionCallContext ctx) { }
@Override public void enterLoopStatement(@NotNull ImperativeParser.LoopStatementContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitFunctionCall(@NotNull ImperativeParser.FunctionCallContext ctx) { }
@Override public void exitLoopStatement(@NotNull ImperativeParser.LoopStatementContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterReturnStatement(@NotNull ImperativeParser.ReturnStatementContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitReturnStatement(@NotNull ImperativeParser.ReturnStatementContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterInit(@NotNull ImperativeParser.InitContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitInit(@NotNull ImperativeParser.InitContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterSkip(@NotNull ImperativeParser.SkipContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitSkip(@NotNull ImperativeParser.SkipContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterIfStatement(@NotNull ImperativeParser.IfStatementContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitIfStatement(@NotNull ImperativeParser.IfStatementContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterStatement(@NotNull ImperativeParser.StatementContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitStatement(@NotNull ImperativeParser.StatementContext ctx) { }

/**
* {@inheritDoc}
Expand All @@ -68,78 +133,78 @@ public class ImperativeBaseListener implements ImperativeListener {
* <p/>
* The default implementation does nothing.
*/
@Override public void enterConstant(@NotNull ImperativeParser.ConstantContext ctx) { }
@Override public void enterFunctionCall(@NotNull ImperativeParser.FunctionCallContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitConstant(@NotNull ImperativeParser.ConstantContext ctx) { }
@Override public void exitFunctionCall(@NotNull ImperativeParser.FunctionCallContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterLoopStatement(@NotNull ImperativeParser.LoopStatementContext ctx) { }
@Override public void enterFunctionDefinition(@NotNull ImperativeParser.FunctionDefinitionContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitLoopStatement(@NotNull ImperativeParser.LoopStatementContext ctx) { }
@Override public void exitFunctionDefinition(@NotNull ImperativeParser.FunctionDefinitionContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterInit(@NotNull ImperativeParser.InitContext ctx) { }
@Override public void enterFormalParameters(@NotNull ImperativeParser.FormalParametersContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitInit(@NotNull ImperativeParser.InitContext ctx) { }
@Override public void exitFormalParameters(@NotNull ImperativeParser.FormalParametersContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterSkip(@NotNull ImperativeParser.SkipContext ctx) { }
@Override public void enterSequence(@NotNull ImperativeParser.SequenceContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitSkip(@NotNull ImperativeParser.SkipContext ctx) { }
@Override public void exitSequence(@NotNull ImperativeParser.SequenceContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterActualParameters(@NotNull ImperativeParser.ActualParametersContext ctx) { }
@Override public void enterProcedureDefinition(@NotNull ImperativeParser.ProcedureDefinitionContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitActualParameters(@NotNull ImperativeParser.ActualParametersContext ctx) { }
@Override public void exitProcedureDefinition(@NotNull ImperativeParser.ProcedureDefinitionContext ctx) { }

/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void enterIfStatement(@NotNull ImperativeParser.IfStatementContext ctx) { }
@Override public void enterActualParameters(@NotNull ImperativeParser.ActualParametersContext ctx) { }
/**
* {@inheritDoc}
* <p/>
* The default implementation does nothing.
*/
@Override public void exitIfStatement(@NotNull ImperativeParser.IfStatementContext ctx) { }
@Override public void exitActualParameters(@NotNull ImperativeParser.ActualParametersContext ctx) { }

/**
* {@inheritDoc}
Expand Down
Binary file modified grammar-imperative/src/ImperativeBaseVisitor.class
Binary file not shown.
Loading

0 comments on commit e944cd1

Please sign in to comment.