Skip to content

Commit

Permalink
function parameters, recursive functions,returning
Browse files Browse the repository at this point in the history
  • Loading branch information
JVerbruggen committed Dec 15, 2021
1 parent 0bfcf04 commit 124e075
Show file tree
Hide file tree
Showing 113 changed files with 5,506 additions and 1,581 deletions.
24 changes: 15 additions & 9 deletions JurjenLang.g4
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ globalscope : (func | stat)*
;

func : func_def scope ;
func_def : FUNC_KW IDENTIFIER ;
func_return : FUNC_RET retstat ;
func_call : IDENTIFIER PAR_OPEN PAR_CLOSE ;
func_def : FUNC_KW IDENTIFIER func_params ;
func_return : FUNC_RET retstat? ;
func_call : IDENTIFIER PAR_OPEN func_call_params PAR_CLOSE ;
func_params : IDENTIFIER* ;
func_call_params : assignable? # func_call_params_single
| assignable (SYMB_COMMA assignable)* # func_call_params_multiple
;

scope : BRACK_OPEN stats func_return? BRACK_CLOSE ;
scope : BRACK_OPEN stats BRACK_CLOSE ;

stats : stat* ;
stat : assignment
| debugtools
| ifchain
| assertion
| whileloop
| func_call
| func_return
;

debugtools : printstat
Expand Down Expand Up @@ -54,6 +58,7 @@ e : PAR_OPEN expr=e PAR_CLOSE # e_parentheses
| left=e operator=SYMB_MINUS right=e # e_subtraction
| SYMB_MINUS expr=e # e_negation
| name=variable # e_variable
| e_func=func_call # e_func
| value=any_value # e_any_value
;

Expand All @@ -63,13 +68,13 @@ bool_e : PAR_OPEN bool_expr=bool_e PAR_CLOSE # bool_parenthes
| NOT_KW bool_expr=bool_e # bool_e_not
| left=e oper=comparison right=e # bool_e_expressions
| left=bool_e oper=bool_comparison right=bool_e # bool_e_expressions_bools
| value=boolean # bool_e_boolean
| value=boolean_type # bool_e_boolean
| name=variable # bool_e_variable
;

boolean : TRUE_KW # boolean_true
| FALSE_KW # boolean_false
;
boolean_type : TRUE_KW # boolean_true
| FALSE_KW # boolean_false
;

comparison : EQUALS
| ISNOT
Expand Down Expand Up @@ -134,6 +139,7 @@ SYMB_MINUS : '-' ;
SYMB_QUOTE : '\'' ;
SYMB_DQUOTE : '"' ;
SYMB_DOT : '.' ;
SYMB_COMMA : ',' ;
FLOAT_IDENT : 'f' ;
ASSIGN : '=' ;
PAR_OPEN : '(' ;
Expand Down
8 changes: 6 additions & 2 deletions antlr_python/JurjenLang.interp

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions antlr_python/JurjenLang.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ SYMB_MINUS=27
SYMB_QUOTE=28
SYMB_DQUOTE=29
SYMB_DOT=30
FLOAT_IDENT=31
ASSIGN=32
PAR_OPEN=33
PAR_CLOSE=34
BRACK_OPEN=35
BRACK_CLOSE=36
IDENTIFIER=37
STR_CONTENT=38
WS=39
SYMB_COMMA=31
FLOAT_IDENT=32
ASSIGN=33
PAR_OPEN=34
PAR_CLOSE=35
BRACK_OPEN=36
BRACK_CLOSE=37
IDENTIFIER=38
STR_CONTENT=39
WS=40
'func'=2
'return'=3
'printscope'=4
Expand Down Expand Up @@ -66,9 +67,10 @@ WS=39
'\''=28
'"'=29
'.'=30
'f'=31
'='=32
'('=33
')'=34
'{'=35
'}'=36
','=31
'f'=32
'='=33
'('=34
')'=35
'{'=36
'}'=37
5 changes: 4 additions & 1 deletion antlr_python/JurjenLangLexer.interp

Large diffs are not rendered by default.

229 changes: 116 additions & 113 deletions antlr_python/JurjenLangLexer.py

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions antlr_python/JurjenLangLexer.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ SYMB_MINUS=27
SYMB_QUOTE=28
SYMB_DQUOTE=29
SYMB_DOT=30
FLOAT_IDENT=31
ASSIGN=32
PAR_OPEN=33
PAR_CLOSE=34
BRACK_OPEN=35
BRACK_CLOSE=36
IDENTIFIER=37
STR_CONTENT=38
WS=39
SYMB_COMMA=31
FLOAT_IDENT=32
ASSIGN=33
PAR_OPEN=34
PAR_CLOSE=35
BRACK_OPEN=36
BRACK_CLOSE=37
IDENTIFIER=38
STR_CONTENT=39
WS=40
'func'=2
'return'=3
'printscope'=4
Expand Down Expand Up @@ -66,9 +67,10 @@ WS=39
'\''=28
'"'=29
'.'=30
'f'=31
'='=32
'('=33
')'=34
'{'=35
'}'=36
','=31
'f'=32
'='=33
'('=34
')'=35
'{'=36
'}'=37
36 changes: 36 additions & 0 deletions antlr_python/JurjenLangListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@ def exitFunc_call(self, ctx:JurjenLangParser.Func_callContext):
pass


# Enter a parse tree produced by JurjenLangParser#func_params.
def enterFunc_params(self, ctx:JurjenLangParser.Func_paramsContext):
pass

# Exit a parse tree produced by JurjenLangParser#func_params.
def exitFunc_params(self, ctx:JurjenLangParser.Func_paramsContext):
pass


# Enter a parse tree produced by JurjenLangParser#func_call_params_single.
def enterFunc_call_params_single(self, ctx:JurjenLangParser.Func_call_params_singleContext):
pass

# Exit a parse tree produced by JurjenLangParser#func_call_params_single.
def exitFunc_call_params_single(self, ctx:JurjenLangParser.Func_call_params_singleContext):
pass


# Enter a parse tree produced by JurjenLangParser#func_call_params_multiple.
def enterFunc_call_params_multiple(self, ctx:JurjenLangParser.Func_call_params_multipleContext):
pass

# Exit a parse tree produced by JurjenLangParser#func_call_params_multiple.
def exitFunc_call_params_multiple(self, ctx:JurjenLangParser.Func_call_params_multipleContext):
pass


# Enter a parse tree produced by JurjenLangParser#scope.
def enterScope(self, ctx:JurjenLangParser.ScopeContext):
pass
Expand Down Expand Up @@ -305,6 +332,15 @@ def exitE_negation(self, ctx:JurjenLangParser.E_negationContext):
pass


# Enter a parse tree produced by JurjenLangParser#e_func.
def enterE_func(self, ctx:JurjenLangParser.E_funcContext):
pass

# Exit a parse tree produced by JurjenLangParser#e_func.
def exitE_func(self, ctx:JurjenLangParser.E_funcContext):
pass


# Enter a parse tree produced by JurjenLangParser#e_division.
def enterE_division(self, ctx:JurjenLangParser.E_divisionContext):
pass
Expand Down
Loading

0 comments on commit 124e075

Please sign in to comment.