mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] v0.6 syntax: fun
, import
, var
, types on the right, etc.
Lots of changes, actually. Most noticeable are: - traditional //comments - #include -> import - a rule "import what you use" - ~ found -> !found (for -1/0) - null() -> null - is_null?(v) -> v == null - throw is a keyword - catch with swapped arguments - throw_if, throw_unless -> assert - do until -> do while - elseif -> else if - drop ifnot, elseifnot - drop rarely used operators A testing framework also appears here. All tests existed earlier, but due to significant syntax changes, their history is useless.
This commit is contained in:
parent
5a3e3595d6
commit
e2edadba92
133 changed files with 8196 additions and 2605 deletions
96
tolk-tester/tests/codegen_check_demo.tolk
Normal file
96
tolk-tester/tests/codegen_check_demo.tolk
Normal file
|
@ -0,0 +1,96 @@
|
|||
@method_id(101)
|
||||
fun test1(): int {
|
||||
var x = false;
|
||||
if (x == true) {
|
||||
x= 100500;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
fun main(s: int) {
|
||||
var (z, t) = (17, s);
|
||||
while (z > 0) {
|
||||
t = s;
|
||||
z -= 1;
|
||||
}
|
||||
return ~ t;
|
||||
}
|
||||
|
||||
/**
|
||||
method_id | in | out
|
||||
@testcase | 0 | 1 | -2
|
||||
@testcase | 0 | 5 | -6
|
||||
@testcase | 101 | | 0
|
||||
|
||||
Below, I just give examples of @fif_codegen tag:
|
||||
* a pattern can be single-line (after the tag), or multi-line, surrounded with """
|
||||
* there may be multiple @fif_codegen, they all will be checked
|
||||
* identation (spaces) is not checked intentionally
|
||||
* "..." means any number of any lines
|
||||
* lines not divided with "..." are expected to be consecutive in fif output
|
||||
* //comments can be omitted, but if present, they are also expected to be equal
|
||||
* there is also a tag @fif_codegen_avoid to check a pattern does not occur
|
||||
|
||||
@fif_codegen
|
||||
"""
|
||||
main PROC:<{
|
||||
// s
|
||||
17 PUSHINT // s _3=17
|
||||
OVER // s z=17 t
|
||||
WHILE:<{
|
||||
...
|
||||
}>DO<{ // s z t
|
||||
...
|
||||
s1 s(-1) PUXC // s t z
|
||||
...
|
||||
2 1 BLKDROP2
|
||||
...
|
||||
}>
|
||||
"""
|
||||
|
||||
@fif_codegen
|
||||
"""
|
||||
main PROC:<{
|
||||
...
|
||||
WHILE:<{
|
||||
...
|
||||
}>DO<{
|
||||
...
|
||||
}>
|
||||
}END>c
|
||||
"""
|
||||
|
||||
@fif_codegen
|
||||
"""
|
||||
OVER
|
||||
0 GTINT // s z t _5
|
||||
"""
|
||||
|
||||
@fif_codegen
|
||||
"""
|
||||
"Asm.fif" include
|
||||
...
|
||||
PROGRAM{
|
||||
...
|
||||
}END>c
|
||||
"""
|
||||
|
||||
@fif_codegen
|
||||
"""
|
||||
test1 PROC:<{
|
||||
//
|
||||
FALSE
|
||||
}>
|
||||
"""
|
||||
|
||||
@fif_codegen NOT // _8
|
||||
@fif_codegen main PROC:<{
|
||||
|
||||
@fif_codegen_avoid PROCINLINE
|
||||
@fif_codegen_avoid END c
|
||||
@fif_codegen_avoid
|
||||
"""
|
||||
multiline
|
||||
can also be
|
||||
"""
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue