From 68d7b4649e0c68194d2f151dd2c55343b0b76477 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 16 May 2021 12:25:25 +0200 Subject: [PATCH] label and directive location docs --- .../src/prog8/compiler/astprocessing/AstChecker.kt | 6 +++--- docs/source/programming.rst | 2 -- docs/source/syntaxreference.rst | 10 +++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index 2353a19fb..ea184b71f 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -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) diff --git a/docs/source/programming.rst b/docs/source/programming.rst index c82ffbe82..cee37e2bf 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -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. diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 930e8a998..80e971b71 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -108,7 +108,7 @@ Directives .. data:: %import - 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 "" [, [, ]] - 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 "" - 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.