label and directive location docs

This commit is contained in:
Irmen de Jong 2021-05-16 12:25:25 +02:00
parent 0416aacbbd
commit 68d7b4649e
3 changed files with 8 additions and 10 deletions

View File

@ -684,20 +684,20 @@ internal class AstChecker(private val program: Program,
}
"%breakpoint" -> {
if(directive.parent !is INameScope || directive.parent is Module)
err("this directive may only occur in a block")
err("this directive can't be used here")
if(directive.args.isNotEmpty())
err("invalid breakpoint directive, expected no arguments")
}
"%asminclude" -> {
if(directive.parent !is INameScope || directive.parent is Module)
err("this directive may only occur in a block")
err("this directive can't be used here")
if(directive.args.size!=1 || directive.args[0].str==null)
err("invalid asminclude directive, expected argument: \"filename\"")
checkFileExists(directive, directive.args[0].str!!)
}
"%asmbinary" -> {
if(directive.parent !is INameScope || directive.parent is Module)
err("this directive may only occur in a block")
err("this directive can't be used here")
val errormsg = "invalid asmbinary directive, expected arguments: \"filename\" [, offset [, length ] ]"
if(directive.args.isEmpty()) err(errormsg)
else if(directive.args.isNotEmpty() && directive.args[0].str==null) err(errormsg)

View File

@ -67,8 +67,6 @@ Label
This is a named position in your code where you can jump to from another place.
You can jump to it with a jump statement elsewhere. It is also possible to use a
subroutine call to a label (but without parameters and return value).
Labels can only be defined in a block or in another subroutine, so you can't define a label
inside a loop statement block for instance.
Scope
Also known as 'namespace', this is a named box around the symbols defined in it.

View File

@ -108,7 +108,7 @@ Directives
.. data:: %import <name>
Level: module, block.
Level: module.
This reads and compiles the named module source file as part of your current program.
Symbols from the imported module become available in your code,
without a module or filename prefix.
@ -136,7 +136,7 @@ Directives
.. data:: %asmbinary "<filename>" [, <offset>[, <length>]]
Level: block.
Level: not at module scope.
This directive can only be used inside a block.
The assembler will include the file as binary bytes at this point, prog8 will not process this at all.
The optional offset and length can be used to select a particular piece of the file.
@ -144,7 +144,7 @@ Directives
.. data:: %asminclude "<filename>"
Level: block.
Level: not at module scope.
This directive can only be used inside a block.
The assembler will include the file as raw assembly source text at this point,
prog8 will not process this at all. Symbols defined in the included assembly can not be referenced
@ -156,12 +156,12 @@ Directives
.. data:: %breakpoint
Level: block, subroutine.
Level: not at module scope.
Defines a debugging breakpoint at this location. See :ref:`debugging`
.. data:: %asm {{ ... }}
Level: block, subroutine.
Level: not at module scope.
Declares that there is *inline assembly code* in the lines enclosed by the curly braces.
This code will be written as-is into the generated output file.
The assembler syntax used should be for the 3rd party cross assembler tool that Prog8 uses.