diff --git a/doc/components.md b/doc/components.md index 157f452..8b4ee0e 100644 --- a/doc/components.md +++ b/doc/components.md @@ -18,35 +18,35 @@ Import the component using: ```cpp -using console; +using console ``` ### Form: `cout` - Character output. ```pawn -console.cout('c'); +console.cout('c') ``` ### Form: `cin` - Character input. Code execution will not be stopped, only a destination variable in which the RCON input will be stored is set. ```pawn -console.cin(destvar); +console.cin(destvar) ``` ### Form: `println` - Text line output. ```pawn -console.println("Hello World!"); +console.println("Hello World!") ``` ### Form: `inputln` - Text line input. Code execution will not be stopped, only a destination variable in which the RCON input will be stored is set. ```pawn -console.inputln(destvar); +console.inputln(destvar) ``` ### Form: `rawout` @@ -54,7 +54,7 @@ console.inputln(destvar); - Raw text output. ```cpp -console.rawout(RandomTextIg??); +console.rawout(RandomTextIg??) ``` --------------------------------------------------------------------------------------------------------- @@ -64,25 +64,25 @@ console.rawout(RandomTextIg??); Import the component using: ```cpp -using system; +using system ``` ### Form: `rem` - Comments. ```pawn -system.rem("SOME TEXT"); +system.rem("SOME TEXT") ``` ### Form: `arginit` - Used to initialize the arguments. ```cpp -int*form.arginit_test?playerid&string; +int arginit_test(num,string) public { - return,1; + return 1 } -system.arginit(arginit_test,1,"Hello!"); +system.arginit(arginit_test,1,"Hello!") ``` --------------------------------------------------------------------------------------------------------- @@ -108,50 +108,50 @@ extern&struct*public.main; Import the component using: ```cpp -using files; +using files ``` ### Form: `open_for_write` - Opens a file with an intention to write data into it. File is created if it does not exist. ```cpp -files.open_for_write("file_name.txt"); +files.open_for_write("file_name.txt") ``` ### Form: `open_for_read` - Opens a file with an intention to read data from it. File is created if it does not exist. ```cpp -files.open_for_read("file_name.txt"); +files.open_for_read("file_name.txt") ``` ### Form: `open_for_append` - Opens a file with an intention to append data into it. File is created if it does not exist. ```cpp -files.open_for_append("file_name.txt"); +files.open_for_append("file_name.txt") ``` ### Form: `read` - Reads data from the opened file and stores it into a variable. ```cpp -new.str,dest_string="something that should change"; -files.read(dest_string); +new.str,dest_string="something that should change" +files.read(dest_string) ``` ### Form: `write` - Writes data into the opened file. ```cpp -files.write("wrote this into file_name.txt"); +files.write("wrote this into file_name.txt") ``` ### Form: `close` - Closes the opened file. ```cpp -files.close; +files.close ``` ### Form: `delete` @@ -159,7 +159,7 @@ files.close; - Deletes a certain file. ```cpp -files.delete("newfile.omg"); +files.delete("newfile.omg") ``` ### Form: `createdir` @@ -167,7 +167,7 @@ files.delete("newfile.omg"); - Creates a directory. ```cpp -files.createdir("mydir"); +files.createdir("mydir") ``` --------------------------------------------------------------------------------------------------------- @@ -178,14 +178,14 @@ files.createdir("mydir"); Import the component using: ```cpp -using misc; +using misc ``` ### Form: `swap` - Swaps two's variable values. ```pawn -misc.swap(var1,var2); +misc.swap(var1,var2) ``` **NOTE**: Now variable `var1` will have the value `var2` had, and `var2` will have the value `var1` had. @@ -198,32 +198,32 @@ misc.swap(var1,var2); Import the component using: ```cpp -using data; +using data ``` ### Form: `sscanf` - Parses and splits a string. ```cpp -using data; +using data -new.str,scanftest1="ok"; -new.str,scanftest2="ok"; -new.str,scanftest3="ok"; -new.str,scanftest4="ok"; -new.int,scanftest5=2453; -new.int,scanftest6=2453; +new.str,scanftest1="ok" +new.str,scanftest2="ok" +new.str,scanftest3="ok" +new.str,scanftest4="ok" +new.int,scanftest5=2453 +new.int,scanftest6=2453 -new.str,scanftest="sscanf-is-so-cool-1-2"; +new.str,scanftest="sscanf-is-so-cool-1-2" -data.sscanf(scanftest,scanftest1,scanftest2,scanftest3,scanftest4,scanftest5,scanftest6); +data.sscanf(scanftest,scanftest1,scanftest2,scanftest3,scanftest4,scanftest5,scanftest6) -console.println.log(scanftest1); -console.println.log(scanftest2); -console.println.log(scanftest3); -console.println.log(scanftest4); -console.cout(scanftest5); -console.cout(scanftest6); +console.println.log(scanftest1) +console.println.log(scanftest2) +console.println.log(scanftest3) +console.println.log(scanftest4) +console.cout(scanftest5) +console.cout(scanftest6) ``` Output: @@ -243,8 +243,8 @@ cool - Returns a distance between 2 strings. ```cpp -data.strdist("hi", "hi") myretref; -console.println.log("myretref is {myretref}"); +data.strdist("hi", "hi") myretref +console.println.log("myretref is {myretref}") ``` Output: @@ -264,14 +264,14 @@ Unlike most of the functions, whose return 0 for failed operation and 1 for succ Import the component using: ```cpp -using pawn; +using pawn ``` ### Form: `callfunction` - Calls a public function declared in the running Pawn code. ```cpp -pawn.callfunction("public_name"); +pawn.callfunction("public_name") ``` --------------------------------------------------------------------------------- @@ -281,7 +281,7 @@ pawn.callfunction("public_name"); Import the component using: ```cpp -using math; +using math ``` ### Form: `vectorsize` @@ -289,7 +289,7 @@ using math; ```cpp math.vectorsize(234.1,4211.3,43.3,-43.33,-0.1,-823) myretref; // Pretty random coordinates. -console.rawout.log(myretref); +console.rawout.log(myretref) ``` Output: diff --git a/doc/const.md b/doc/const.md index caf5ef0..f0e8e9d 100644 --- a/doc/const.md +++ b/doc/const.md @@ -4,16 +4,16 @@ - You also may make constants in PawnScript: ```cpp -const*new.int,MY_FIRST_CONST=1; +const*new.int,MY_FIRST_CONST=1 ``` You also may create boolean and string constants: ```cpp -const*new.bool,MY_FIRST_CONST=true; +const*new.bool,MY_FIRST_CONST=true -const*new.str,MY_FIRST_CONST="string"; +const*new.str,MY_FIRST_CONST="string" ``` ## Data types @@ -23,7 +23,7 @@ const*new.str,MY_FIRST_CONST="string"; - Integers are whole numbers. ```cpp -const*new.int,integer=1; +const*new.int,integer=1 ``` ### `bool` @@ -31,7 +31,7 @@ const*new.int,integer=1; - Booleans are variables that can either be true or false. ```cpp -const*new.bool,boolean=true; +const*new.bool,boolean=true ``` ### `str` @@ -39,7 +39,7 @@ const*new.bool,boolean=true; - Strings are words or sequences of characters. ```cpp -const*new.str,string="test"; +const*new.str,string="test" ``` ### `double` @@ -47,7 +47,7 @@ const*new.str,string="test"; - Doubles are numbers with decimal points. ```cpp -const*new.double,decimal_point=3.14; +const*new.double,decimal_point=3.14 ``` ### `char` @@ -55,5 +55,5 @@ const*new.double,decimal_point=3.14; - Single characters. ```cpp -const*new.char,character='6'; +const*new.char,character='6' ``` \ No newline at end of file diff --git a/doc/constexpr.md b/doc/constexpr.md index 34a75f0..b030685 100644 --- a/doc/constexpr.md +++ b/doc/constexpr.md @@ -5,17 +5,17 @@ ## Namespaces ```cpp -constexpr namespace TestConstNamespace; +constexpr namespace TestConstNamespace { - void MyForm() public; + void MyForm() public { - console.println.log("My namespace function works!"); + console.println.log("My namespace function works!") } } -user.TestConstNamespace::MyForm; +user.TestConstNamespace::MyForm() -using namespace TestConstNamespace; +using namespace TestConstNamespace { // Oops! Fatal error! // Process will be terminated at this point! diff --git a/doc/decorators.md b/doc/decorators.md index 445a4a2..3863b1f 100644 --- a/doc/decorators.md +++ b/doc/decorators.md @@ -7,8 +7,8 @@ - Used to make a hook function. ```cpp -@hook; -void MyTestFunc() public; +@hook +void MyTestFunc() public { } ``` @@ -18,12 +18,12 @@ void MyTestFunc() public; - Used to make a function method. ```cpp -@method; -void MyTestFunc() public; +@method +void MyTestFunc() public { } -console.println.MyTestFunc(...); +console.println.MyTestFunc(...) ``` ## `@task` @@ -31,10 +31,10 @@ console.println.MyTestFunc(...); - Used to make a timer. ```cpp -@task; -void mytask() public; +@task +void mytask() public { - console.println("Task works!"); + console.println("Task works!") } ``` @@ -43,11 +43,11 @@ void mytask() public; - This keyword is used for modifying decorator parameter values, without a specific order. ```cpp -@task; - this->interval=1000; -void mytask() public; +@task + this->interval=1000 +void mytask() public { - console.println("Task works!"); + console.println("Task works!") } ``` @@ -56,10 +56,10 @@ Note that this is NOT possible: ```cpp this->interval=1000; // `this` is modifying the arguments of last used decorator -@task; -void mytask() public; +@task +void mytask() public { - console.println("Task works!"); + console.println("Task works!") } ``` @@ -70,11 +70,11 @@ void mytask() public; - How much does it take till the timer is (re)called. ```cpp -@task; - this->interval=1000; -void mytask() public; +@task + this->interval=1000 +void mytask() public { - console.println("Task works!"); + console.println("Task works!") } ``` @@ -85,12 +85,12 @@ void mytask() public; - Will the timer recall after being called once? ```cpp -@task; - this->interval=1000; - this->repeat=false; -void mytask() public; +@task + this->interval=1000 + this->repeat=false +void mytask() public { - console.println("Task works!"); + console.println("Task works!") } ``` diff --git a/doc/directives.md b/doc/directives.md index fc80a2e..e508b6d 100644 --- a/doc/directives.md +++ b/doc/directives.md @@ -7,27 +7,27 @@ - Used to include a file: ```cpp -#include:file; +#include:file ``` ## `#undef` -- Used to undefine a symbol; that can be an iterator, variable, constant or whatever. +- Used to undefine a symbol that can be an iterator, variable, constant or whatever. ```cpp -#undef:var; +#undef:var ``` Example: ```cpp -new.int,undeftest=1; +new.int,undeftest=1 -if.equ,defined?undeftest,1->console.println.log("undeftest is defined"); +if.equ,defined?undeftest,1->console.println.log("undeftest is defined") -#undef:undeftest; +#undef:undeftest -if.equ,defined?undeftest,1->console.println.log("undeftest is defined *(again!*)"); +if.equ,defined?undeftest,1->console.println.log("undeftest is defined *(again!*)") ``` Output: @@ -47,7 +47,7 @@ Read more about it [here](options.md). ### `addrset` ```cpp -#emit:addrset,addressof?varname; +#emit:addrset,addressof?varname ``` - This sets an address in the memory you will operate with. @@ -57,35 +57,35 @@ Read more about it [here](options.md). - Changes a return value. ```cpp -new.int,ADDRESSOFTEST=0; -#emit:addrset,addressof?ADDRESSOFTEST; -#emit:vlset,23746; +new.int,ADDRESSOFTEST=0 +#emit:addrset,addressof?ADDRESSOFTEST +#emit:vlset,23746 -console.cout.log(ADDRESSOFTEST); +console.cout.log(ADDRESSOFTEST) -new.bool,ADDRESSOFTEST2=false; -#emit:addrset,addressof?ADDRESSOFTEST2; -#emit:vlset,true; +new.bool,ADDRESSOFTEST2=false +#emit:addrset,addressof?ADDRESSOFTEST2 +#emit:vlset,true -console.cout.log(ADDRESSOFTEST2); +console.cout.log(ADDRESSOFTEST2) -new.str,ADDRESSOFTEST3="000"; -#emit:addrset,addressof?ADDRESSOFTEST3; -#emit:vlset,"#emit works!"; +new.str,ADDRESSOFTEST3="000" +#emit:addrset,addressof?ADDRESSOFTEST3 +#emit:vlset,"#emit works!" -console.println.log(ADDRESSOFTEST3); +console.println.log(ADDRESSOFTEST3) -new.double,ADDRESSOFTEST4=0.0; -#emit:addrset,addressof?ADDRESSOFTEST4; -#emit:vlset,23.746; +new.double,ADDRESSOFTEST4=0.0 +#emit:addrset,addressof?ADDRESSOFTEST4 +#emit:vlset,23.746 -console.cout.log(ADDRESSOFTEST4); +console.cout.log(ADDRESSOFTEST4) -new.char,ADDRESSOFTEST5='0'; -#emit:addrset,addressof?ADDRESSOFTEST5; -#emit:vlset,'K'; +new.char,ADDRESSOFTEST5='0' +#emit:addrset,addressof?ADDRESSOFTEST5 +#emit:vlset,'K' -console.cout.log(ADDRESSOFTEST5); +console.cout.log(ADDRESSOFTEST5) ``` Output: @@ -102,8 +102,8 @@ true - Used to change the return type. ```cpp -#emit:addrset,addressof?varname; -#emit:dtyp,4; +#emit:addrset,addressof?varname +#emit:dtyp,4 ``` - `1` = `int` @@ -118,12 +118,12 @@ true - Create an integer variable, change its data type to `char`, set a value, and then print the value. ```cpp -new.int,ADDRESSOFTEST6=1; -#emit:addrset,addressof?ADDRESSOFTEST6; -#emit:dtyp,5; -#emit:vlset,'Z'; +new.int,ADDRESSOFTEST6=1 +#emit:addrset,addressof?ADDRESSOFTEST6 +#emit:dtyp,5 +#emit:vlset,'Z' -console.cout.log(ADDRESSOFTEST6); +console.cout.log(ADDRESSOFTEST6) ``` Output: @@ -137,11 +137,11 @@ Output: - Change the symbol name. ```cpp -new.int,ADDRESSOFTEST7=364; -#emit:addrset,addressof?ADDRESSOFTEST7; -#emit:csnm,__ADDRESSOFTEST7; +new.int,ADDRESSOFTEST7=364 +#emit:addrset,addressof?ADDRESSOFTEST7 +#emit:csnm,__ADDRESSOFTEST7 -console.cout.log(__ADDRESSOFTEST7); +console.cout.log(__ADDRESSOFTEST7) ``` Output: @@ -155,9 +155,9 @@ Output: - Set the value of the primary register to the value stored inside the loaded address. ```cpp -new.int,var=1; -#emit:addrset,addressof?var; -#emit:load.pri; +new.int,var=1 +#emit:addrset,addressof?var +#emit:load.pri ``` `PRI` is now 1. @@ -167,9 +167,9 @@ new.int,var=1; - Set the value of the alternate register to the value stored inside the loaded address. ```cpp -new.int,var=1; -#emit:addrset,addressof?var; -#emit:load.alt; +new.int,var=1 +#emit:addrset,addressof?var +#emit:load.alt ``` `ALT` is now 1. @@ -179,7 +179,7 @@ new.int,var=1; - Set the value of the primary register to a constant value not loaded with `addrset`. ```cpp -#emit:const.pri,1; +#emit:const.pri,1 ``` `PRI` is now 1. @@ -190,7 +190,7 @@ new.int,var=1; - Set the value of the alternate register to a constant value not loaded with `addrset`. ```cpp -#emit:const.alt,1; +#emit:const.alt,1 ``` `ALT` is now 1. @@ -201,10 +201,10 @@ new.int,var=1; - Set the value of the primary register to a constant value not loaded with `addrset`. ```cpp -new.int,var=1; -#emit:addrset,addressof?var; -#emit:const.pri,6; -#emit:stor.pri; +new.int,var=1 +#emit:addrset,addressof?var +#emit:const.pri,6 +#emit:stor.pri ``` `var` is now 6. @@ -216,10 +216,10 @@ new.int,var=1; - Store the value of the alternate register into a loaded address. ```cpp -new.int,var=1; -#emit:addrset,addressof?var; -#emit:const.alt,6; -#emit:stor.alt; +new.int,var=1 +#emit:addrset,addressof?var +#emit:const.alt,6 +#emit:stor.alt ``` `var` is now 6. @@ -230,7 +230,7 @@ new.int,var=1; ```cpp #emit:add; //pri = pri+alt -#emit:sub; //pri = pri-alt<0?pri-alt*(-1):pri-alt; +#emit:sub; //pri = pri-alt<0?pri-alt*(-1):pri-alt #emit:mul; //pri = pri*alt #emit:div; //pri = alt==0?0:pri/alt ``` @@ -250,7 +250,7 @@ new.int,var=1; - Changes the value of the primary register to 0. ```cpp -#emit:zero.pri; //pri=0 +#emit:zero.pri //pri=0 ``` @@ -259,7 +259,7 @@ new.int,var=1; - Changes the value of the alternate register to 0. ```cpp -#emit:zero.alt; //alt=0 +#emit:zero.alt //alt=0 ``` ### `lctrl` @@ -298,20 +298,31 @@ new.int,var=1; - Pop the current address contained within the `CUR` and `SEC` from the stack (delete a symbol). ```cpp -#emit:const.pri,1; // Set the value of PRI to 1 (which is var memory sector id) -#emit:sctrl,2; // Set the sector to 1 -#emit:lctrl,4; // Get the next free cell id -#emit:sctrl,1; // Set that cell id. -#emit:push; // Push that address to the stack. -#emit:csnm,temporaryvar; // Name it that because it's name is not in the stack, so we will pop it later. -#emit:dtyp,1; // Make it an integer. -#emit:vlset,300; // Give it a value of 300. -std::writeln("temporaryvar is {temporaryvar}"); // Print the value -#emit:pop; // Invalidate the current address. +#emit:const.pri,1 +// Set the value of PRI to 1 (which is var memory sector id) +#emit:sctrl,2 +// Set the sector to 1 +#emit:lctrl,4 +// Get the next free cell id +#emit:sctrl,1 +// Set that cell id. +#emit:push +// Push that address to the stack. +#emit:csnm,temporaryvar +// Name it that because it's name is not in the stack, so we will pop it later. +#emit:dtyp,1 +// Make it an integer. +#emit:vlset,300 +// Give it a value of 300. +std::writeln("temporaryvar is {temporaryvar}") +// Print the value +#emit:pop +// Invalidate the current address. // Optional: Reset the registers. -#emit:zero.pri; -#emit:zero.alt; -std::writeln("temporaryvar is {temporaryvar}"); // We will see "temporaryvar is null" +#emit:zero.pri +#emit:zero.alt +std::writeln("temporaryvar is {temporaryvar}") +// We will see "temporaryvar is null" ``` ### `inc.alt` @@ -319,7 +330,8 @@ std::writeln("temporaryvar is {temporaryvar}"); // We will see "temporaryvar is - Increase the value stored inside the alternate register by 1. ```cpp -#emit:inc.alt; //alt++ +#emit:inc.alt +//alt++ ``` ### `inc.pri` @@ -327,7 +339,8 @@ std::writeln("temporaryvar is {temporaryvar}"); // We will see "temporaryvar is - Increase the value stored inside the primary register by 1. ```cpp -#emit:inc.pri; //pri++ +#emit:inc.pri +//pri++ ``` ### `dec.alt` @@ -335,7 +348,8 @@ std::writeln("temporaryvar is {temporaryvar}"); // We will see "temporaryvar is - Decrease the value stored inside the alternate register by 1. ```cpp -#emit:dec.alt; //alt-- +#emit:dec.alt +//alt-- ``` ### `dec.pri` @@ -343,5 +357,6 @@ std::writeln("temporaryvar is {temporaryvar}"); // We will see "temporaryvar is - Decrease the value stored inside the primary register by 1. ```cpp -#emit:dec.pri; //pri-- +#emit:dec.pri +//pri-- ``` \ No newline at end of file diff --git a/doc/do.md b/doc/do.md index e0896f4..f32a620 100644 --- a/doc/do.md +++ b/doc/do.md @@ -6,37 +6,37 @@ ```cpp -if.equ,1,1->do; +if.equ,1,1->do { - if.notequ,1,2->do; + if.notequ,1,2->do { - if.equ,1+1,3->console.println.log("Oh my God!"); + if.equ,1+1,3->console.println.log("Oh my God!") } } -else->if.equ,1,1->do; +else->if.equ,1,1->do { - console.println.log("No way this worked!"); - if.equ,1,1->do; + console.println.log("No way this worked!") + if.equ,1,1->do { - console.println.log("This has also worked..."); - if.equ,3,7->do; + console.println.log("This has also worked...") + if.equ,3,7->do { - console.println("NOO"); + console.println("NOO") } - else->if.equ,1,1->do; + else->if.equ,1,1->do { - console.println.log("Oh yeah!"); + console.println.log("Oh yeah!") } - else->do; + else->do { - console.println.log("So yeah!"); + console.println.log("So yeah!") } } } -else->if.equ,3,4->console.println.log("How does this even work?"); -else->do; +else->if.equ,3,4->console.println.log("How does this even work?") +else->do { - console.println.log("You should always return a value!"); + console.println.log("You should always return a value!") } ``` @@ -54,9 +54,9 @@ You should always return a value! ## Example `#2` ```cpp -do; +do { - console.cout(1+1); + console.cout(1+1) } ``` diff --git a/doc/enum.md b/doc/enum.md index d006df1..4d3c3e0 100644 --- a/doc/enum.md +++ b/doc/enum.md @@ -5,53 +5,53 @@ ## Example `#1` ```cpp -enum WeekDays; +enum WeekDays { - monday; - tuesday; - thursday; - saturday; + monday + tuesday + thursday + saturday } -console.cout.log(WeekDays.monday); -console.cout.log(WeekDays.tuesday); -console.cout.log(WeekDays.thursday); -console.cout.log(WeekDays.saturday); +console.cout.log(WeekDays.monday) +console.cout.log(WeekDays.tuesday) +console.cout.log(WeekDays.thursday) +console.cout.log(WeekDays.saturday) -console.println.log("enum test included"); -console.cout.log(WeekDays.saturday+WeekDays.monday); +console.println.log("enum test included") +console.cout.log(WeekDays.saturday+WeekDays.monday) ``` ## Example `#2` ```cpp -enum WeekDays; +enum WeekDays { - monday=1; - tuesday=2; - thursday=3; - saturday=4; + monday=1 + tuesday=2 + thursday=3 + saturday=4 } -console.cout.log(WeekDays.monday); -console.cout.log(WeekDays.tuesday); -console.cout.log(WeekDays.thursday); -console.cout.log(WeekDays.saturday); +console.cout.log(WeekDays.monday) +console.cout.log(WeekDays.tuesday) +console.cout.log(WeekDays.thursday) +console.cout.log(WeekDays.saturday) -console.println.log("enum test included"); -console.cout.log(WeekDays.saturday+WeekDays.monday); +console.println.log("enum test included") +console.cout.log(WeekDays.saturday+WeekDays.monday) -enum Months; +enum Months { - january=5; - february=6; - december=7; + january=5 + february=6 + december=7 } -console.cout.log(Months.january); -console.cout.log(Months.february-Months.december); -console.cout.log(Months.january%WeekDays.monday); +console.cout.log(Months.january) +console.cout.log(Months.february-Months.december) +console.cout.log(Months.january%WeekDays.monday) -console.println("Test?"); +console.println("Test?") ``` \ No newline at end of file diff --git a/doc/errors.md b/doc/errors.md index c522808..9411f66 100644 --- a/doc/errors.md +++ b/doc/errors.md @@ -9,13 +9,13 @@ - You attempted to modify a code block (code between 2 curly braces), but it is marked with the `constexpr` keyword. ```cpp -constexpr*namespace,test; +constexpr namespace test { // Random code. - templatecout; + templatecout } -using*namespace,test;{ +using namespace test; { // THIS IS AN ERROR! } ``` @@ -25,7 +25,7 @@ using*namespace,test;{ - Every symbol (function, variable, constant, iterator, vector, etc.) must have its unique name within its memory sector, but it needs to be a valid alphabetic name, which means that this is not valid and will result in an error: ```cpp -new.int,$/87656RANDOM NAME LMAO=0; +new.int,$/87656RANDOM NAME LMAO=0 ``` ## `Invalid assembler instruction.` @@ -33,7 +33,7 @@ new.int,$/87656RANDOM NAME LMAO=0; - This is related to `#emit`, if you for example try to use a different instruction which is not mentioned in the documentation, then you will encounter this error. ```cpp -#emit:lmao_clown,XD; +#emit:lmao_clown,XD ``` ## `Invalid memory access.` @@ -41,7 +41,7 @@ new.int,$/87656RANDOM NAME LMAO=0; - This happens when you try to access an invalid address inside PawnScript memory. Often happens with `#emit`. ```cpp -#emit:addrset,LMAO_MY_ADDRESS@WashingTonDC; +#emit:addrset,LMAO_MY_ADDRESS@WashingTonDC ``` **TIP**: Avoid this by using the `addressof` keyword. @@ -52,18 +52,18 @@ new.int,$/87656RANDOM NAME LMAO=0; ```cpp -new.int,hey=43; +new.int,hey=43 new.int,hey=9; // Error. ``` -## `Invalid expression; assumed zero.` +## `Invalid expression assumed zero.` - You probably made a typo in your code or you wrote something non-sense. ```cpp -@hook=j; -constexpr=namespace UUUUU+class+enum; -inT func() publex;{ - retern,0; +@hook=j +constexpr=namespace UUUUU+class+enum +inT func() publex{ + retern,0 } ``` \ No newline at end of file diff --git a/doc/for.md b/doc/for.md index 559f3fb..9360a21 100644 --- a/doc/for.md +++ b/doc/for.md @@ -5,8 +5,8 @@ ## Example ```cpp -new.int,forlooptestvar=0; -if.equ,1,1->for.int,forlooptestvar,10->console.println("For loop id {forlooptestvar}"); +new.int,forlooptestvar=0 +if.equ,1,1->for.int,forlooptestvar,10->console.println("For loop id {forlooptestvar}") ``` Output: @@ -27,14 +27,14 @@ For loop id 10 ## Example *#2* ```cpp -int*form.ForTest2?num; +int ForTest2(num) public { - console.println("'num' is {num@ForTest2}"); - return,1; + console.println("'num' is {num@ForTest2}") + return,1 } -forlooptestvar=0; -for.int,forlooptestvar,5->user.ForTest2(forlooptestvar); +forlooptestvar=0 +for.int,forlooptestvar,5->user.ForTest2(forlooptestvar) ``` Output: diff --git a/doc/foreach.md b/doc/foreach.md index fea9ce2..f96babf 100644 --- a/doc/foreach.md +++ b/doc/foreach.md @@ -8,23 +8,23 @@ ### Example ```cpp -using iter; // Use iter. functions. +using iter // Use iter. functions. -iterator<100>testiter; // Declare a `testiter` with size of 100 which means it can hold up to 100 integers. -new.int,foreachtestvar=0; +iterator<100>testiter // Declare a `testiter` with size of 100 which means it can hold up to 100 integers. +new.int,foreachtestvar=0 // We use functions from the `iter` component to manipulate with them. -iter.add(testiter,1); -iter.add(testiter,10); -iter.remove(testiter,1); +iter.add(testiter,1) +iter.add(testiter,10) +iter.remove(testiter,1) -foreach.int,foreachtestvar,testiter->console.println("foreach test {foreachtestvar}"); +foreach.int,foreachtestvar,testiter->console.println("foreach test {foreachtestvar}") -iter.add(testiter,1); +iter.add(testiter,1) -foreach.int,foreachtestvar,testiter->console.println("foreach test #2 {foreachtestvar}"); +foreach.int,foreachtestvar,testiter->console.println("foreach test #2 {foreachtestvar}") -#undef:testiter; +#undef:testiter ``` Output: @@ -40,13 +40,13 @@ foreach test #2 10 - Iterators inside namespaces. ```cpp -namespace,IterClass; +namespace IterClass { - iterator<10>iter; + iterator<10>iter } -iter.add(IterClass::iter,364); -foreach.int,foreachtestvar,IterClass::iter->console.println("foreach test #3 {foreachtestvar}"); +iter.add(IterClass::iter,364) +foreach.int,foreachtestvar,IterClass::iter->console.println("foreach test #3 {foreachtestvar}") ``` Output: @@ -62,22 +62,24 @@ foreach test #3 364 ```cpp -vector<324>vectorname; // An initial size can be a completely random number, +vector<324>vectorname // An initial size can be a completely random number, // because the size updates dynamically during the runtime. -// `using vector` is already in stdlib.ps -vector.add(vectorname,1); -vector.add(vectorname,312); -vector.add(vectorname,2); -new.int,vectortest=0; +// `using vec` is already in stdlib.ps +using vec -console.rawout(sizeof?vectorname); // Size is changed from 324 to 3. -foreach.int,vectortest,vectorname->std::writeln("vector test #1 {vectortest}"); +vec.add(vectorname,1) +vec.add(vectorname,312) +vec.add(vectorname,2) +new.int,vectortest=0 -vector.remove(vectorname,312); +console.rawout(sizeof?vectorname) // Size is changed from 324 to 3. +foreach.int,vectortest,vectorname->std::writeln("vector test #1 {vectortest}") -console.rawout(sizeof?vectorname); // Size is changed from 3 to 2. -foreach.int,vectortest,vectorname->std::writeln("vector test #2 {vectortest}"); +vec.remove(vectorname,312) + +console.rawout(sizeof?vectorname) // Size is changed from 3 to 2. +foreach.int,vectortest,vectorname->std::writeln("vector test #2 {vectortest}") ``` @@ -99,23 +101,25 @@ vector test #2 2 - Vectors inside namespaces. ```cpp -namespace,vectors; +namespace vectors { - vector<324>myvec; - new.int,vectortest2=0; + vector<324>myvec + new.int,vectortest2=0 } -vector.add(vectors::myvec,24); -vector.add(vectors::myvec,31); -vector.add(vectors::myvec,29); +vec.add(vectors::myvec,24) +vec.add(vectors::myvec,31) +vec.add(vectors::myvec,29) -console.rawout(sizeof?vectors::myvec); // Size is changed from 324 to 3. -foreach.int,vectors::vectortest2,vectors::myvec->std::writeln("vector test #3 {vectors::vectortest2}"); +console.rawout(sizeof?vectors::myvec) + // Size is changed from 324 to 3. +foreach.int,vectors::vectortest2,vectors::myvec->std::writeln("vector test #3 {vectors::vectortest2}") -vector.remove(vectors::myvec,24); +vec.remove(vectors::myvec,24) -console.rawout(sizeof?vectors::myvec); // Size is changed from 3 to 2. -foreach.int,vectors::vectortest2,vectors::myvec->std::writeln("vector test #4 {vectors::vectortest2}"); +console.rawout(sizeof?vectors::myvec) + // Size is changed from 3 to 2. +foreach.int,vectors::vectortest2,vectors::myvec->std::writeln("vector test #4 {vectors::vectortest2}") ``` Output: @@ -136,7 +140,7 @@ vector test #4 29 ```cpp -console.cout(sizeof?testiter); +console.cout(sizeof?testiter) ``` Output: diff --git a/doc/forms.md b/doc/forms.md index c8b7fa6..ccdb550 100644 --- a/doc/forms.md +++ b/doc/forms.md @@ -8,9 +8,9 @@ - Native functions are those whose are defined in an interpreter component and are useable only if the component is imported. You may call native functions by specifying the component name. ```cpp -using console; +using console -console.println("Hello World"); +console.println("Hello World") ``` @@ -21,9 +21,9 @@ console.println("Hello World"); - User functions are functions whose are defined by the person who wrote the code. You may declare an user functions using: ```cpp -void formname() public; +void formname() public { - console.println("my first user functions"); + console.println("my first user functions") } ``` @@ -32,29 +32,29 @@ So now you've made an user functions. Code between the curly braces is called a You also may return values. ```cpp -str funcname() public; +str funcname() public { - console.println("my first user functions"); - return,"this was returned"; + console.println("my first user functions") + return,"this was returned" } ``` Then you can use this user function as an argument in a native function. ```cpp -str funcname() public; +str funcname() public { - console.println("my first user functions"); - return,"this was returned"; + console.println("my first user functions") + return,"this was returned" } -console.println(funcname); +console.println(funcname) ``` To call an user function, use: ```cpp -user.funcname(); +user.funcname() ``` @@ -63,9 +63,9 @@ user.funcname(); - You may also use variables and constants as arguments in native functions. ```cpp -const*new.str,CONST_NAME="constant worked"; +const*new.str,CONST_NAME="constant worked" -console.println(CONST_NAME); +console.println(CONST_NAME) ``` --------------------------------------------------------------------------------------------------------- @@ -74,25 +74,25 @@ console.println(CONST_NAME); - You can hook already existing functions using **hook functions**. ```cpp -int functobehooked() public; +int functobehooked() public { - console.println("HOOKED"); - return,1; + console.println("HOOKED") + return,1 } -@hook; -int functobehooked() public; +@hook +int functobehooked() public { - console.println("HOOKED 1"); - return.int,1; + console.println("HOOKED 1") + return.int,1 } -@hook; -int functobehooked() public; +@hook +int functobehooked() public { - console.println("HOOKED 2"); - return.int,1; + console.println("HOOKED 2") + return.int,1 } -user.functobehooked(); +user.functobehooked() ``` \ No newline at end of file diff --git a/doc/how.md b/doc/how.md index a1db056..10d450d 100644 --- a/doc/how.md +++ b/doc/how.md @@ -14,7 +14,7 @@ `index.ps`: ```cpp -using console; +using console ``` - This line will enable the use of an integrated component called "console". Console component provides forms and functions you can use for character output. If we did not enable the component, we'd run into an error. @@ -23,15 +23,27 @@ using console; `index.ps`: ```cpp -using console; +using console -console.println("Hello World!"); +console.println("Hello World!") ``` - What we did here is basically call the `console` component and provided a function name next to the component call. That function is `println` which literally stands for "print line". Group of words separated by a semicolon (`;`) is called a **statement**. Adding a comma, we started an **argument part** of the statement. Argument part of a statement consists of some kind of resources we have use of when it comes to executing code. - As you can see, our first argument is `"Hello World"` - which is a string, and since we provided this argument to the `console.println` function, contents of that argument will be displayed in the console. +**NOTE**: Semicolons are optional ONLY if you are writing 1 statement per line, which means that this is not possible: + +```cpp +component.func() // comment +``` + +You need to separate the comment with a semicolon: + +```cpp +component.func(); // comment +``` + ### Running code - Now that we got our very first PawnScript program, we can run our server. You firstly need to configure your server by setting the PawnScript build as your server gamemode, you can learn how to do it [here](https://google.com). @@ -62,15 +74,15 @@ Hello World! `index.ps`: ```cpp -using.console; +using.console -console.println("Hello World!"); +console.println("Hello World!") ``` - Interpreter is firstly going to read the first line. Afterwards, the semicolon will be removed and the internal process-function will be called: ```cpp -main() dpp_process("using.console"); +main() dpp_process("using.console") ``` - Of course this is a simplified depiction. The thing that `process` does is that it calls `parseline` which breaks down the line into so-called groups, so internally it will look like this after the break-down. @@ -87,14 +99,14 @@ funcgroup[1] = "console" ```cpp process(line) { - parseline(line,funcgroup,'.'); + parseline(line,funcgroup,'.') if(funcgroup[0] == "using") { if(funcgroup[1] == "console") { - enablesamp(); - return 1; + enablesamp() + return 1 } } } @@ -105,8 +117,8 @@ process(line) ```cpp process(line) { - parseline(line,funcgroup,'.'); - parseline(funcgroup,args,','); + parseline(line,funcgroup,'.') + parseline(funcgroup,args,',') if(funcgroup[0] == "console") { @@ -114,9 +126,9 @@ process(line) { if(isstring(arg[1])) { - processconsole(funcgroup,args); + processconsole(funcgroup,args) } - return 1; + return 1 } } } diff --git a/doc/if.md b/doc/if.md index fe4aea3..c312364 100644 --- a/doc/if.md +++ b/doc/if.md @@ -4,15 +4,15 @@ - If-expressions are also possible in PawnScript: ```cpp -if.equ,1,1->console.println("1 is 1"); +if.equ,1,1->console.println("1 is 1") ``` You also may compare variables, consants and vice-versa. ```cpp -new.str,myvar="myvar worked."; +new.str,myvar="myvar worked." -if.equ,myvar,"myvar worked."->console.println(myvar); +if.equ,myvar,"myvar worked."->console.println(myvar) ``` --------------------------------------------------------------------------------------------------------- @@ -33,19 +33,19 @@ If-method is a new term used to describe the way how are you comparing the 2 ele - A quick example form: ```cpp -int ElseTest() public; +int ElseTest() public { - if.equ,1,2->console.println("1 and 2 are equal"); - else->if.equ,2,3->console.println("2 and 3 are equal"); - else->console.println("Nothing is equal"); + if.equ,1,2->console.println("1 and 2 are equal") + else->if.equ,2,3->console.println("2 and 3 are equal") + else->console.println("Nothing is equal") - if.equ,1,1->console.println("1 and 1 are indeed equal"); - else->console.println("This should not be printed"); + if.equ,1,1->console.println("1 and 1 are indeed equal") + else->console.println("This should not be printed") - return,1; + return 1 } -user.ElseTest(); +user.ElseTest() ``` Output: diff --git a/doc/inline.md b/doc/inline.md index 630fb18..c80140a 100644 --- a/doc/inline.md +++ b/doc/inline.md @@ -5,26 +5,26 @@ ## Example ```cpp -int InlineTestFunc() public; +int InlineTestFunc() public { - new.int,formid=__proccessed_form_id; - console.println("'InlineTestFunc' is {formid}"); + new.int,formid=__proccessed_form_id + console.println("'InlineTestFunc' is {formid}") - void inlineformtest() inline; + void inlineformtest() inline < - console.println("Inline works."); - console.println.log("The inline finally works!"); + console.println("Inline works.") + console.println.log("The inline finally works!") > - user.inlineformtest; - user.inlineformtest; - user.inlineformtest; - user.inlineformtest; - yield&return,1; + user.inlineformtest + user.inlineformtest + user.inlineformtest + user.inlineformtest + yield&return,1 } -user.InlineTestFunc; -user.InlineTestFunc; +user.InlineTestFunc +user.InlineTestFunc ``` Output: diff --git a/doc/methods.md b/doc/methods.md index b8f4e5b..208dec6 100644 --- a/doc/methods.md +++ b/doc/methods.md @@ -6,22 +6,22 @@ ```cpp @method; -int TestMethod() public; +int TestMethod() public { - console.println("Printed: {text@TestMethod}"); - return.int,1; + console.println("Printed: {text@TestMethod}") + return int 1 } -console.println.TestMethod("Method test #1"); +console.println.TestMethod("Method test #1") -namespace,MyNameSpace; +namespace MyNameSpace { - @method; - int TestMethod(text) public; + @method + int TestMethod(text) public { - console.println.log("Printed: {text@MyNameSpace::TestMethod}"); - return.int,1; + console.println.log("Printed: {text@MyNameSpace::TestMethod}") + return int 1 } } diff --git a/doc/namespace.md b/doc/namespace.md index e73a50c..14301a5 100644 --- a/doc/namespace.md +++ b/doc/namespace.md @@ -7,7 +7,7 @@ - A normal class with a normal purpose. ```cpp -namespace customer; +namespace customer { } ``` @@ -15,7 +15,7 @@ namespace customer; Within the class code block, we can create a variable. ```cpp -namespace customer; +namespace customer { new.str,name="Alex"; } @@ -33,7 +33,7 @@ console.println(customer::name); - You can also hook a namespace. To hook a namespace means to extend a namespace and add more elements to an existing namespace instead of creating a new one. For example, this is our code right now: ```cpp -namespace customer; +namespace customer { new.str,name="Alex"; } @@ -45,14 +45,14 @@ console.println(customer::name); We can hook the `customer` namespace: ```cpp -namespace customer; +namespace customer { new.str,name="Alex"; } console.println(customer::name); -using namespace customer; +using namespace customer { new.int,age=12; } diff --git a/st3/syntax.yaml b/st3/syntax.yaml index f1c42ce..1b0cb8a 100644 --- a/st3/syntax.yaml +++ b/st3/syntax.yaml @@ -25,7 +25,7 @@ contexts: # 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(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|user|if|else|tagof|sizeof|addressof|short|unsigned|include|undef|pragma|emit|defined|iterator|vector|export|import|this|interval|repeat)\b' scope: keyword.control.example-c # Numbers @@ -44,6 +44,9 @@ contexts: - match: '->' scope: keyword.control.example-c + - match: '=' + scope: keyword.control.example-c + - match: '<-' scope: keyword.control.example-c