Skip to content

Commit 56325b9

Browse files
committed
📝 fix(docs): fix specifications
Signed-off-by: FurryR <awathefox@gmail.com>
1 parent 9b59ff1 commit 56325b9

3 files changed

Lines changed: 30 additions & 23 deletions

File tree

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ event.start {
1919
- **Supports variables, lists, and custom blocks**
2020
- **Event-driven programming** with Scratch hat blocks
2121
- **Type annotations** for better code clarity
22-
- **Decorators** for external block integration
22+
- **Decorators** for exporting blocks and variables
2323
- Can be used as **Intermediate Representation (IR)** for other languages, or as a component for Scratch Addons
2424

2525
## Examples
@@ -113,15 +113,14 @@ event.keyPressed("space") {
113113
}
114114
```
115115

116-
### Using External Blocks with Decorators
116+
### Export Blocks with Decorators
117117

118118
```fuse
119-
// Define external Scratch blocks using @extern decorator
120-
@extern("wait 1 frame") fn yield() once -> void {
121-
// External block implementation
119+
// Export Scratch blocks using @export decorator
120+
@export("wait 1 frame") fn yield() once -> void {
122121
}
123122
124-
@extern("current timestamp") fn currentTimestamp() once -> any {
123+
@export("current timestamp") fn currentTimestamp() once -> any {
125124
return sensing.daysSince2000() * 86400 * 1000
126125
}
127126
@@ -140,13 +139,21 @@ event.start {
140139
### FPS Counter Example
141140

142141
```fuse
143-
@extern("last timestamp") let lastTimestamp = 0
142+
@export("// [value]") fn description(value: any) once -> void {
143+
// This function is a no-op, used for adding comments in the generated Scratch blocks
144+
}
145+
@export("drop [value]") fn drop(value: any) once -> void {
146+
description(value)
147+
}
148+
@export("last timestamp") let lastTimestamp = 0
144149
145-
@extern("current timestamp") fn currentTimestamp() once -> any {
150+
@export("current timestamp") fn currentTimestamp() once -> any {
146151
return sensing.daysSince2000() * 86400 * 1000
147152
}
148153
149-
@extern("wait 1 frame") fn yield() once -> void {}
154+
@export("wait 1 frame") fn yield() once -> void {
155+
drop(translate.getTranslate(1, ""))
156+
}
150157
151158
fn calculateFps() once -> any {
152159
lastTimestamp = currentTimestamp()

specification.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Target = FunctionDeclaration | VariableDeclaration ;
155155
ArgumentList = Literal ("," Literal)* ;
156156
```
157157

158-
**Note**: Currently, only the `@extern` decorator is supported.
158+
**Note**: Currently, only the `@export` decorator is supported.
159159

160160
### Hat Blocks (Event Handlers)
161161

@@ -323,20 +323,20 @@ The FUSE program structure allows only the following at the top level:
323323
FUSE uses a simple type system:
324324
- `void`: No return value
325325
- `any`: Any Scratch value (string, number, boolean)
326-
- Custom types can be defined through identifiers
326+
- `bool`: Boolean values (`true` or `false`)
327327

328328
### Decorators
329329

330-
#### `@extern` Decorator
330+
#### `@export` Decorator
331331

332-
The `@extern` decorator is used to define external Scratch blocks or mark code that should use specific Scratch block implementations.
332+
The `@export` decorator is used to export Scratch blocks.
333333

334334
```fuse
335-
@extern("block description") fn functionName(params) once -> returnType {
336-
// implementation
335+
@export("test [params]") fn functionName(params: any) once -> returnType {
336+
// The function will appear as a Scratch block with the given name and parameters
337337
}
338338
339-
@extern("variable description") let variableName = initialValue ;
339+
@export("variable description") let variableName = initialValue ;
340340
```
341341

342342
### Operators
@@ -502,10 +502,10 @@ fn processArray() once -> void {
502502
}
503503
```
504504

505-
### External Blocks
505+
### exportal Blocks
506506

507507
```fuse
508-
@extern("custom block [arg1] and [arg2]")
508+
@export("custom block [arg1] and [arg2]")
509509
fn customBlock(arg1: any, arg2: any) once -> any {
510510
return arg1 + arg2
511511
}

src/compiler/compiler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ export class Compiler {
15841584
case 'DecoratorStatement': {
15851585
// Perform simple check
15861586
const decorator = stmt as DecoratorStatement
1587-
if (decorator.name.name !== 'extern') {
1587+
if (decorator.name.name !== 'export') {
15881588
throw new CompilerError(
15891589
`Unknown decorator @${decorator.name.name}`,
15901590
decorator.line,
@@ -2622,14 +2622,14 @@ export class Compiler {
26222622
let exportName: string | null = null
26232623
if (decl.type === 'DecoratorStatement') {
26242624
const decorator = decl as DecoratorStatement
2625-
if (decorator.name.name !== 'extern') {
2625+
if (decorator.name.name !== 'export') {
26262626
throw new CompilerError(
26272627
`Unknown decorator @${decorator.name.name}`,
26282628
decorator.line,
26292629
decorator.column
26302630
)
26312631
}
2632-
// @export("external name") fn ...
2632+
// @export("exportal name") fn ...
26332633
if (decorator.target.type !== 'FunctionDeclaration') {
26342634
continue
26352635
}
@@ -2696,14 +2696,14 @@ export function getProgramInfo(program: Program): ProgramInfo {
26962696
let exportName: string | null = null
26972697
if (decl.type === 'DecoratorStatement') {
26982698
const decorator = decl as DecoratorStatement
2699-
if (decorator.name.name !== 'extern') {
2699+
if (decorator.name.name !== 'export') {
27002700
throw new CompilerError(
27012701
`Unknown decorator @${decorator.name.name}`,
27022702
decorator.line,
27032703
decorator.column
27042704
)
27052705
}
2706-
// @export("external name") global id = 1
2706+
// @export("exportal name") global id = 1
27072707
if (decorator.target.type !== 'VariableDeclaration') {
27082708
continue
27092709
}

0 commit comments

Comments
 (0)