Skip to content

Commit

Permalink
syntax file updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DEntisT committed Aug 30, 2023
1 parent 9dff0f9 commit 1119af5
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 22 deletions.
30 changes: 15 additions & 15 deletions doc/return.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
- In PawnScript, to return a value it means to execute the code and give the result output, after returning a value, code block execution will stop.

```cpp
int MyForm() public;
int MyForm() public
{
console.println("Hello World");
return,1;
console.println("This code won't be executed");
console.println("Hello World")
return 1
console.println("This code won't be executed")
}

console.cout(MyForm);
system.rem("Thing above will print 1");
console.cout(MyForm)
system.rem("Thing above will print 1")
```


Expand All @@ -24,15 +24,15 @@ system.rem("Thing above will print 1");
- `yield` return will do the same thing as a normal return, the difference is that the code block won't stop being executed until `};` or `return..,..;`.

```cpp
int MyForm() public;
int MyForm() public
{
console.println("Hello World");
yield&return,1;
console.println("This code will be executed too");
console.println("Hello World")
yield&return,1
console.println("This code will be executed too")
}

console.cout(MyForm);
system.rem("Thing above will print 1");
system.rem("Thing above will print 1")
```


Expand All @@ -43,16 +43,16 @@ system.rem("Thing above will print 1");
Little example:

```cpp
int TestFunction() public;
int TestFunction() public
{
return.bool,false;
return bool false
}
```

- Return type assigned to a function `TestFunction` is integer, but we returned a boolean. If we do not want to return any value, we just assign the `void` return type:

```cpp
void TestFunction() public;
void TestFunction() public
{
system.rem("Now we can't use a return keyword in this function block.");
system.rem("Now we can't use a return keyword in this function block.")
}
Binary file modified scriptfiles/index.ps
Binary file not shown.
Binary file modified scriptfiles/modules/args.ps
Binary file not shown.
Binary file modified scriptfiles/modules/data.ps
Binary file not shown.
Binary file modified scriptfiles/modules/emit.ps
Binary file not shown.
Binary file modified scriptfiles/modules/enum.ps
Binary file not shown.
Binary file modified scriptfiles/modules/inline.ps
Binary file not shown.
Binary file modified scriptfiles/modules/iter.ps
Binary file not shown.
Binary file modified scriptfiles/modules/math.ps
Binary file not shown.
2 changes: 1 addition & 1 deletion src/modules/header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ DO NOT CHANGE THEM!
#define @PAWNSCRIPT_INTERNAL__@Float:return>%1(%2) dpp_vardata[dpp_retvar__][floatvalue]=%2;return 1
#define @PAWNSCRIPT_INTERNAL__@bool:return>%1(%2) dpp_vardata[dpp_retvar__][boolvalue]=%2;return 1
#define @PAWNSCRIPT_INTERNAL__@string:return>%1(%2<%3>) strmid(dpp_vardata[dpp_retvar__][stringvalue],%2,0,%3,%3);return 1
#define @PAWNSCRIPT_INTERNAL__@char%0return>%1(%2<%3>) dpp_vardata[dpp_retvar__][charvalue]=%2;return 1
#define @PAWNSCRIPT_INTERNAL__@char%0return>%1(%2) dpp_vardata[dpp_retvar__][charvalue]=%2;return 1

#define @PAWNSCRIPT_INTERNAL__@pri> dpp_pri__
#define @PAWNSCRIPT_INTERNAL__@alt> dpp_alt__
Expand Down
30 changes: 25 additions & 5 deletions src/modules/interpreter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3746,14 +3746,35 @@ public dpp_processuser(funcgroup[][],args[][],args_const[][])
dpp_clearformstack(dpp_processfunc);
dpp_deletestaticvars();
dpp_processfunc = DPP_INVALID_FORM_ID;
return 1;

if(dpp_returntype[i] == dpp_rtn_type_int)
{
dpp_internal<return>(dpp_funcreturn_int[i]);
}
if(dpp_returntype[i] == dpp_rtn_type_bool)
{
dpp_internal<bool:return>(dpp_funcreturn_bool[i]);
}
if(dpp_returntype[i] == dpp_rtn_type_str)
{
dpp_internal<string:return>(dpp_funcreturn_str[i]<dpp_buffersize/2>);
}
if(dpp_returntype[i] == dpp_rtn_type_double)
{
dpp_internal<Float:return>(dpp_funcreturn_double[i]);
}
if(dpp_returntype[i] == dpp_rtn_type_char)
{
dpp_internal<char return>(dpp_funcreturn_char[i]);
}
dpp_internal<return>(1);
}
}
}
if(dpp_processfunc == DPP_INVALID_FORM_ID)
{
dpp_error("Inline forms are meant to be used inside forms.",);
return 1;
dpp_internal<return>(0);
}
for(new i; i < dpp_maxinline; i++)
{
Expand All @@ -3763,13 +3784,12 @@ public dpp_processuser(funcgroup[][],args[][],args_const[][])
{
//dpp_warning("#1 Inline: '%s' | Code: '%s'",funcgroup[1],dpp_inlinecodeblock[i]);
dpp_subexecute(dpp_inlinecodeblock[i]);
//dpp_warning("#2 Inline: '%s' | Code: '%s'",funcgroup[1],dpp_inlinecodeblock[i]);
return 1;
dpp_internal<return>(1);
}
}
}
dpp_error("Form \"%s\" isn't registered.", funcgroup[1]);
return 0;
dpp_internal<return>(0);
}
return 0;
}
Expand Down
15 changes: 14 additions & 1 deletion st3/syntax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ contexts:
- match: '//'
scope: punctuation.definition.comment.example-c
push: line_comment

# Keywords are if, else for and while.
# Note that blackslashes don't need to be escaped within single quoted
# strings in YAML. When using single quoted strings, only single quotes
# need to be escaped: this is done by using two single quotes next to each
# other.
- match: '\b(yield|enum|class|public|inline|namespace|constexpr|const|static|new|int|bool|str|double|char|void|using|return|hook|method|task|for|foreach|while|do|try|object|tag|break|continue|template|typedef|exit|user|if|else|tagof|sizeof|addressof|short|unsigned|include|undef|pragma|emit|defined|iterator|vector|export|import|this|interval|repeat)\b'
- match: '\b(yield|enum|class|public|inline|namespace|constexpr|const|static|new|int|bool|str|double|char|void|using|return|hook|method|task|for|foreach|while|do|try|object|tag|break|continue|template|typedef|exit|if|else|tagof|sizeof|addressof|short|unsigned|include|undef|pragma|emit|defined|iterator|vector|export|import|interval|repeat)\b'
scope: keyword.control.example-c

# Numbers
Expand All @@ -47,6 +48,12 @@ contexts:
- match: '='
scope: keyword.control.example-c

- match: '>'
scope: keyword.control.example-c

- match: '<'
scope: keyword.control.example-c

- match: '<-'
scope: keyword.control.example-c

Expand All @@ -56,6 +63,12 @@ contexts:
- match: '\b(console|system|pawn|data|vec|iter|files|math|misc)\b'
scope: constant.numeric.example-c

- match: '\b(equ|notequ)\b'
scope: variable.annotation.example-c

- match: '\b(this|user)\b'
scope: variable.annotation.example-c

- match: '[\w]+\('
scope: entity.name.impl.example-c
- match: '\)'
Expand Down

0 comments on commit 1119af5

Please sign in to comment.