SYNTAX ERROR: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "</source>" to "</syntaxhighlight>")
Tags: Mobile edit Mobile web edit
m (Text replacement - "<source" to "<syntaxhighlight")
 
Line 1: Line 1:
A SYNTAX ERROR is an [[error message]] which indicates that a rule of [[APL syntax]] was violated. A SYNTAX ERROR may indicate an ill-formed expression which violates APL's grammar:
A SYNTAX ERROR is an [[error message]] which indicates that a rule of [[APL syntax]] was violated. A SYNTAX ERROR may indicate an ill-formed expression which violates APL's grammar:
<source lang=apl>
<syntaxhighlight lang=apl>
       (
       (
SYNTAX ERROR
SYNTAX ERROR
Line 12: Line 12:
</syntaxhighlight>
</syntaxhighlight>
However, a SYNTAX ERROR may also indicate a problem not with the sequence of tokens in a statement, but with their meaning. For example, below an error results when a [[function]] is called with invalid [[valence]]: here, a [[monadic function]] with two arguments.
However, a SYNTAX ERROR may also indicate a problem not with the sequence of tokens in a statement, but with their meaning. For example, below an error results when a [[function]] is called with invalid [[valence]]: here, a [[monadic function]] with two arguments.
<source lang=apl>
<syntaxhighlight lang=apl>
       fn ← +
       fn ← +
       2 fn 3
       2 fn 3
Line 22: Line 22:
         ∧
         ∧
</syntaxhighlight>
</syntaxhighlight>
Depending on the value of <source lang=apl inline>fn</syntaxhighlight>, the same statement may or may not be considered invalid syntax. This is to be expected, since APL does not have a [[wikipedia:context-free grammar|context-free grammar]] and needs to know the type of each variable to parse a statement.
Depending on the value of <syntaxhighlight lang=apl inline>fn</syntaxhighlight>, the same statement may or may not be considered invalid syntax. This is to be expected, since APL does not have a [[wikipedia:context-free grammar|context-free grammar]] and needs to know the type of each variable to parse a statement.


{{APL features}}[[Category:Errors]]
{{APL features}}[[Category:Errors]]

Latest revision as of 21:02, 10 September 2022

A SYNTAX ERROR is an error message which indicates that a rule of APL syntax was violated. A SYNTAX ERROR may indicate an ill-formed expression which violates APL's grammar:

      (
SYNTAX ERROR
      (
      ∧

      'Hello world 
SYNTAX ERROR: Invalid token
      'Hello world
      ∧

However, a SYNTAX ERROR may also indicate a problem not with the sequence of tokens in a statement, but with their meaning. For example, below an error results when a function is called with invalid valence: here, a monadic function with two arguments.

      fn ← +
      2 fn 3
5
      fn ← +\  ⍝ A strictly monadic function
      2 fn 3
SYNTAX ERROR: The function does not take a left argument
      2 fn 3
        ∧

Depending on the value of fn, the same statement may or may not be considered invalid syntax. This is to be expected, since APL does not have a context-free grammar and needs to know the type of each variable to parse a statement.


APL features [edit]
Built-ins Primitives (functions, operators) ∙ Quad name
Array model ShapeRankDepthBoundIndex (Indexing) ∙ AxisRavelRavel orderElementScalarVectorMatrixSimple scalarSimple arrayNested arrayCellMajor cellSubarrayEmpty arrayPrototype
Data types Number (Boolean, Complex number) ∙ Character (String) ∙ BoxNamespaceFunction array
Concepts and paradigms Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity elementComplex floorArray ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ GlyphLeading axis theoryMajor cell search
Errors LIMIT ERRORRANK ERRORSYNTAX ERRORDOMAIN ERRORLENGTH ERRORINDEX ERRORVALUE ERROREVOLUTION ERROR