@c DO NOT EDIT!  Generated automatically by munge-texi.pl.

@c Copyright (C) 1996-2026 The Octave Project Developers
@c
@c This file is part of Octave.
@c
@c Octave is free software: you can redistribute it and/or modify it
@c under the terms of the GNU General Public License as published by
@c the Free Software Foundation, either version 3 of the License, or
@c (at your option) any later version.
@c
@c Octave is distributed in the hope that it will be useful, but
@c WITHOUT ANY WARRANTY; without even the implied warranty of
@c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@c GNU General Public License for more details.
@c
@c You should have received a copy of the GNU General Public License
@c along with Octave; see the file COPYING.  If not, see
@c <https://www.gnu.org/licenses/>.

@node Grammar and Parser
@appendix Grammar and Parser
@cindex grammar rules
@cindex language definition

This appendix will eventually contain a semi-formal description of Octave's
language.

@menu
* Keywords::
* Parser::
@end menu

@node Keywords
@section Keywords
@cindex keywords

The function @code{iskeyword} can be used to check whether an identifier is
reserved by Octave.

@c iskeyword libinterp/parse-tree/lex.ll
@anchor{XREFiskeyword}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {@var{tf} =} iskeyword (@var{name})
@deftypefnx {} {@var{keyword_list} =} iskeyword ()
Return true if @var{name} is an Octave keyword.

If @var{name} is omitted, return a list of keywords.
@xseealso{@ref{XREFisvarname,,isvarname}, @ref{XREFexist,,exist}}
@end deftypefn


@subsubheading Keyword Categories

@ref{XREFkwcategoryVariableDeclaration,,@w{Variable Declaration}}@: |
@ref{XREFkwcategoryFunctionDefinition,,@w{Function Definition}}@: |
@ref{XREFkwcategoryControlStructures,,@w{Control Statements}}@: |
@ref{XREFkwcategoryIteratingStructures,,@w{Iterating Structures}}@: |
@ref{XREFkwcategoryClassdefStructures,,@w{Classdef Structures}}@: |
@ref{XREFkwcategoryExecutionEnvironment,,@w{Execution Environment}}@:

@subsubheading Alphabetical Keyword Listing

The identifiers below are keywords, and may not be used as variable or function
names.

@noindent
@ref{XREF__FILE__,,__FILE__}@: |
@ref{XREF__LINE__,,__LINE__}@: |
@ref{XREFarguments,,arguments}@: |
@ref{XREFbreak,,break}@: |
@ref{XREFcase,,case}@: |
@ref{XREFcatch,,catch}@: |
@ref{XREFclassdef,,classdef}@: |
@ref{XREFcontinue,,continue}@: |
@ref{XREFdo,,do}@: |
@ref{XREFelse,,else}@: |
@ref{XREFelseif,,elseif}@: |
@ref{XREFend,,end}@: |
@ref{XREFend_try_catch,,end_try_catch}@: |
@ref{XREFend_unwind_protect,,end_unwind_protect}@: |
@ref{XREFendarguments,,endarguments}@: |
@ref{XREFendclassdef,,endclassdef}@: |
@ref{XREFendenumeration,,endenumeration}@: |
@ref{XREFendevents,,endevents}@: |
@ref{XREFendfor,,endfor}@: |
@ref{XREFendfunction,,endfunction}@: |
@ref{XREFendif,,endif}@: |
@ref{XREFendmethods,,endmethods}@: |
@ref{XREFendparfor,,endparfor}@: |
@ref{XREFendproperties,,endproperties}@: |
@ref{XREFendswitch,,endswitch}@: |
@ref{XREFendwhile,,endwhile}@: |
@ref{XREFenumeration,,enumeration}@: |
@ref{XREFevents,,events}@: |
@ref{XREFfor,,for}@: |
@ref{XREFfunction,,function}@: |
@ref{XREFglobal,,global}@: |
@ref{XREFif,,if}@: |
@ref{XREFkwpropertymethods,,methods}@: |
@ref{XREFotherwise,,otherwise}@: |
@ref{XREFparfor,,parfor}@: |
@ref{XREFpersistent,,persistent}@: |
@ref{XREFkwpropertyproperties,,properties}@: |
@ref{XREFreturn,,return}@: |
@ref{XREFswitch,,switch}@: |
@ref{XREFtry,,try}@: |
@ref{XREFuntil,,until}@: |
@ref{XREFunwind_protect,,unwind_protect}@: |
@ref{XREFunwind_protect_cleanup,,unwind_protect_cleanup}@: |
@ref{XREFwhile,,while}@:


@anchor{XREFkwcategoryVariableDeclaration}
@subheading Variable Declaration

@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFglobal}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} global @var{var}
Declare variables to have global scope.

@example
@group
global @var{x};
if (isempty (@var{x}))
  x = 1;
endif
@end group
@end example
@xseealso{@ref{XREFpersistent,,persistent}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFpersistent}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} persistent @var{var}
Declare variables as persistent.

A variable that has been declared persistent within a function will retain its
contents in memory between subsequent calls to the same function.  The
difference between persistent variables and global variables is that persistent
variables are local in scope to a particular function and are not visible
elsewhere.
@xseealso{@ref{XREFglobal,,global}}
@end deftypefn
@c ## FIXME: Can't have duplicate DOCSTRING entries.  The function properties()
@c ##        already has a docstring which overrides this keyword definition.
@c ##        If this is fixed, place \x1d char before keyword "properties".
@c ## properties
@c ## @c libinterp/parse-tree/oct-parse.yy
@c ## -*- texinfo -*-
@c ## @deftypefn {} {} properties
@c ## Begin a properties block in a classdef definition.
@c ## @end deftypefn


@anchor{XREFkwcategoryFunctionDefinition}
@subheading Function Definition

@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFfunction}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {} function [@var{output1}, @dots{}] = function_name (@var{input1}, @dots{})
@deftypefnx {} {} function {} function_name (@var{input1}, @dots{})
@deftypefnx {} {} function @var{output} = function_name
Begin a function body with name @code{function_name}, with @var{outputs} as
results, and with @var{inputs} as parameters.

The function can later be invoked in Octave using the syntax

@example
[@var{output1}, @var{output2}, @dots{}] = function_name (@var{input1}, @var{input2}, @dots{})
@end example

@xseealso{@ref{XREFreturn,,return}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendfunction}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endfunction
Terminate a function definition.
@xseealso{@ref{XREFfunction,,function}}
@end deftypefn


@c end libinterp/parse-tree/pt-eval.cc
@anchor{XREFend}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} end
The termination of a code block @emph{or} the last element of an array.

The keyword @code{end} is used to terminate blocks of code begun with
@code{for}, @code{parfor}, @code{if}, @code{do}, @code{while}, @code{function},
@code{switch}, @code{try}, or @code{unwind_protect}.

When using classdef (object-oriented) programming, the keyword terminates blocks
of code begun with @code{classdef}, @code{properties}, @code{methods},
@code{events}, or @code{enumeration}.

As an index of an array, the magic index @qcode{"end"} refers to the last valid
entry in an indexing operation.

Examples:

@example
@group
@var{x} = [ 1 2 3; 4 5 6 ];
@var{x}(1,end)
 @xresult{} 3
@var{x}(end,1)
 @xresult{} 4
@var{x}(end,end)
 @xresult{} 6
@end group
@end example

Programming Notes:
@enumerate
@item
The @code{end} keyword cannot be used within @code{subsref}, @code{subsasgn}, or
@code{substruct} for manual indexing operations.

@item
For custom classes, enabling use of @code{end} in indexing expressions requires
writing an overloaded function such as:

@example
@group
function last_index = end (obj, end_dim, ndim_obj)
  if (end_dim == ndim_obj)
    last_index = prod (size (obj)(end_dim:ndim_obj));
  else
    last_index = size (obj, end_dim);
  endif
endfunction
@end group
@end example

For more information, @pxref{Object Oriented Programming}.
@end enumerate

@xseealso{@ref{XREFfor,,for}, @ref{XREFparfor,,parfor}, @ref{XREFif,,if}, @ref{XREFdo,,do}, @ref{XREFwhile,,while}, @ref{XREFfunction,,function}, @ref{XREFswitch,,switch}, @ref{XREFtry,,try}, @ref{XREFunwind_protect,,unwind_protect}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFreturn}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} return
Return execution control immediately from a function or script to the calling
code.

@code{return} is used to stop executing code and exit an m-file immediately
rather than continuing until the end of the function or script is reached.

If the function or script was invoked directly, rather than from calling code
in an m-file, then Octave returns to the command line.
@xseealso{@ref{XREFfunction,,function}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFarguments}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} arguments
Begin a function arguments block.

@strong{Warning:} Function arguments validation blocks are not yet implemented
in Octave.  Use of the keyword @code{arguments} will cause the parser to emit a
warning, and may throw an error depending on the contents of the code in the
block.
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendarguments}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endarguments
Terminate a function arguments block.

@strong{Warning:} Function arguments validation blocks are not yet implemented
in Octave.  Use of the keyword @code{arguments} will cause the parser to emit a
warning, and may throw an error depending on the contents of the code in the
block.
@xseealso{@ref{XREFarguments,,arguments}}
@end deftypefn


@anchor{XREFkwcategoryControlStructures}
@subheading Control Statements

@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFif}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {} if (@var{cond}) @dots{} endif
@deftypefnx {} {} if (@var{cond}) @dots{} else @dots{} endif
@deftypefnx {} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} endif
@deftypefnx {} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} else @dots{} endif
Begin an if block.

The conditional @var{cond} is true if it is not empty and if @emph{all} values
are nonzero.

@example
@group
x = 1;
if (x == 1)
  disp ("one");
elseif (x == 2)
  disp ("two");
else
  disp ("not one or two");
endif
@end group
@end example
@xseealso{@ref{XREFswitch,,switch}}
@end deftypefn
@c ## FIXME: Can't have duplicate DOCSTRING entries.  The function methods()
@c ##        already has a docstring which overrides this keyword definition.
@c ##        If this is fixed, place \x1d char before keyword "methods".
@c ## methods
@c ## @c libinterp/parse-tree/oct-parse.yy
@c ## -*- texinfo -*-
@c ## @deftypefn {} {} methods
@c ## Begin a methods block in a classdef definition.
@c ## @end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFelse}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} else
Alternate action for an if block.

See @code{if} for an example.
@xseealso{@ref{XREFif,,if}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFelseif}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} elseif (@var{cond})
Alternate conditional test for an if block.

The conditional @var{cond} is true if it is not empty and if @emph{all} values
are nonzero.

See @code{if} for an example.
@xseealso{@ref{XREFif,,if}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendif}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endif
Terminate an if block.

See @code{if} for an example.
@xseealso{@ref{XREFif,,if}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFswitch}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} switch @var{statement}
Begin a switch block.

@example
@group
yesno = "yes";

switch (yesno)
  case @{"Yes" "yes" "YES" "y" "Y"@}
    value = 1;
  case @{"No" "no" "NO" "n" "N"@}
    value = 0;
  otherwise
    error ("invalid value");
endswitch
@end group
@end example
@xseealso{@ref{XREFif,,if}, @ref{XREFcase,,case}, @ref{XREFotherwise,,otherwise}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFcase}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {} case @var{value}
@deftypefnx {} {} case @{@var{value1}, @dots{}@}
A case statement in a switch block.

The code associated with a @code{case} statement is executed if one of the
tests below succeeds given a @code{switch} argument @var{statement} and a
@var{value} of type:

@itemize

@item number : @code{@var{statement} == @var{value}}

@item character array or string : @code{strcmp (@var{statement}, @var{value})}

@item object : @code{eq (@var{statement}, @var{value})}@*
(programmer must write overloaded @code{eq} function which performs @samp{==}) 

@item cell array : One of the @var{values} in the cell array must match
@var{statement} using the criteria above.

@end itemize

Programming Notes: Octave cases are exclusive and do not fall-through as do
@w{C-language} cases.  A @code{switch} statement must have at least one
@code{case}.

See @code{switch} for an example.
@xseealso{@ref{XREFswitch,,switch}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFotherwise}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} otherwise
The default statement in a @code{switch} block which is executed when no other
@code{case} statements match the input.
@xseealso{@ref{XREFswitch,,switch}, @ref{XREFcase,,case}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendswitch}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endswitch
Terminate a switch block.

See @code{switch} for an example.
@xseealso{@ref{XREFswitch,,switch}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFtry}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} try
Begin a try-catch block.

If an error occurs within a @code{try} block, then the code in the @code{catch}
block will be run.  Execution will proceed after the @code{catch} block (though
it is often recommended to use the @code{lasterr} function to re-throw the
error after cleanup is completed).
@xseealso{@ref{XREFcatch,,catch}, @ref{XREFunwind_protect,,unwind_protect}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFcatch}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {} catch
@deftypefnx {} {} catch @var{exception_var}
Begin the cleanup part of a try-catch block.

If @var{exception_var} is specified then a variable of that name will defined
in the scope of the @code{catch} block.  The variable is a scalar struct with
fields @code{identifier}, @code{message}, and @code{stack} which describes
the error that was caught.
@xseealso{@ref{XREFtry,,try}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFend_try_catch}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} end_try_catch
Terminate a try-catch block.
@xseealso{@ref{XREFtry,,try}, @ref{XREFcatch,,catch}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFunwind_protect}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} unwind_protect
Begin an unwind_protect block.

If an error occurs within the first part of an @code{unwind_protect} block the
commands within the @code{unwind_protect_cleanup} block are executed before the
error is thrown.  If an error is not thrown, then the
@code{unwind_protect_cleanup} block is still executed.  In other words, the
@code{unwind_protect_cleanup} code is guaranteed to execute regardless of
success or failure in the @code{unwind_protect} block.
@xseealso{@ref{XREFunwind_protect_cleanup,,unwind_protect_cleanup}, @ref{XREFtry,,try}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFunwind_protect_cleanup}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} unwind_protect_cleanup
Begin the cleanup section of an @code{unwind_protect} block.
@xseealso{@ref{XREFunwind_protect,,unwind_protect}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFend_unwind_protect}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} end_unwind_protect
Terminate an unwind_protect block.
@xseealso{@ref{XREFunwind_protect,,unwind_protect}}
@end deftypefn


@anchor{XREFkwcategoryIteratingStructures}
@subheading Iterating Structures

@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFfor}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} for @var{i} = @var{range}
Begin a for loop.

@example
@group
for i = 1:10
  i
endfor
@end group
@end example
@xseealso{@ref{XREFparfor,,parfor}, @ref{XREFdo,,do}, @ref{XREFwhile,,while}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendfor}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endfor
Terminate a for loop.

See @code{for} for an example.
@xseealso{@ref{XREFfor,,for}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFwhile}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} while (@var{cond})
Begin a while loop.

The conditional @var{cond} is true if it is not empty and if @emph{all} values
are nonzero.

@example
@group
i = 0;
while (i < 10)
  i++
endwhile
@end group
@end example
@xseealso{@ref{XREFdo,,do}, @ref{XREFendwhile,,endwhile}, @ref{XREFfor,,for}, @ref{XREFuntil,,until}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendwhile}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endwhile
Terminate a while loop.

See @code{while} for an example.
@xseealso{@ref{XREFdo,,do}, @ref{XREFwhile,,while}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFdo}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} do
Begin a do-until loop.

This differs from a @code{while} loop in that the body of the loop is executed
at least once.

@example
@group
i = 0;
do
  i++
until (i == 10)
@end group
@end example
@xseealso{@ref{XREFfor,,for}, @ref{XREFuntil,,until}, @ref{XREFwhile,,while}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFuntil}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} until (@var{cond})
End a do-until loop.

The conditional @var{cond} is true if it is not empty and if @emph{all} values
are nonzero.

See @code{do} for an example.
@xseealso{@ref{XREFdo,,do}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFparfor}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {} parfor @var{i} = @var{range}
@deftypefnx {} {} parfor (@var{i} = @var{range}, @var{maxproc})
Begin a for loop that may execute in parallel.

A @code{parfor} loop has the same syntax as a @code{for} loop.  If your Octave
session has a parallel processing pool enabled, the iterations of the
@code{parfor} loop will be executed in parallel across the pool's workers.
Otherwise, @code{parfor} will behave exactly as @code{for}.

When operating in parallel mode, a @code{parfor} loop's iterations are not
guaranteed to occur sequentially, and there are additional restrictions about
the data access operations you can do inside the loop body.

@strong{Warning:} parallel processing pools are currently unimplemented in
Octave; @code{parfor} currently behaves exactly as a normal @code{for} loop.

@example
@group
parfor i = 1:10
  i
endparfor
@end group
@end example
@xseealso{@ref{XREFfor,,for}, @ref{XREFdo,,do}, @ref{XREFwhile,,while}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendparfor}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endparfor
Terminate a parfor loop.

See @code{parfor} for an example.
@xseealso{@ref{XREFparfor,,parfor}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFbreak}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} break
Exit the innermost enclosing @code{do}, @code{while}, or @code{for} loop.
@xseealso{@ref{XREFcontinue,,continue}, @ref{XREFdo,,do}, @ref{XREFwhile,,while}, @ref{XREFfor,,for}, @ref{XREFparfor,,parfor}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFcontinue}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} continue
Jump to the end of the innermost enclosing @code{do}, @code{while}, or
@code{for} loop.
@xseealso{@ref{XREFbreak,,break}, @ref{XREFdo,,do}, @ref{XREFwhile,,while}, @ref{XREFfor,,for}, @ref{XREFparfor,,parfor}}
@end deftypefn


@anchor{XREFkwcategoryClassdefStructures}
@subheading Classdef Structures

@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFclassdef}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} classdef
Begin a classdef block.
@c NOTE: Use Octave @xseealso macro in order to point at the keyword
@c       documentation for "properties" and "methods" rather than the function
@c       documentation.
@xseealso{@ref{XREFkwpropertyproperties,,properties}, @ref{XREFkwpropertymethods,,methods}, @ref{XREFevents,,events}, @ref{XREFenumeration,,enumeration}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendclassdef}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endclassdef
Terminate a classdef definition.
@xseealso{@ref{XREFclassdef,,classdef}}
@end deftypefn


@c properties definition must be manually created to avoid
@c collision with function of the same name.
@anchor{XREFkwpropertyproperties}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html

@deftypefn {} {} properties
Mark the beginning of a block of properties in a classdef definition.

Note that the @ref{XREFproperties,,function @qcode{"properties"}} is not a
keyword, but rather an ordinary function that lists the properties of a classdef
class or object.
@xseealso{@ref{XREFendproperties,,endproperties}}
@end deftypefn

@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendproperties}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endproperties
Terminate a properties block in a classdef definition.
@c NOTE: Use Octave @xseealso macro in order to point at property 'properties',
@c       rather than function.
@xseealso{@ref{XREFkwpropertyproperties,,properties}}
@end deftypefn


@c methods definition must be manually created to avoid
@c collision with function of the same name.
@anchor{XREFkwpropertymethods}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html

@deftypefn {} {} methods
Mark the beginning of a block of methods in a classdef definition.

Note that the @ref{XREFmethods,,function @qcode{"methods"}} is not a keyword,
but rather an ordinary function that lists the methods of a class or object.
@xseealso{@ref{XREFendmethods,,endmethods}}
@end deftypefn

@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendmethods}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endmethods
Terminate a methods block in a classdef definition.
@c NOTE: Use Octave @xseealso macro in order to point at property 'methods',
@c       rather than function.
@xseealso{@ref{XREFkwpropertymethods,,methods}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFevents}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} events
Begin an events block in a classdef definition.
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendevents}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endevents
Terminate an events block in a classdef definition.
@xseealso{@ref{XREFevents,,events}}
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFenumeration}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} enumeration
Begin an enumeration block in a classdef definition.
@end deftypefn


@c libinterp/parse-tree/oct-parse.yy
@anchor{XREFendenumeration}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} endenumeration
Terminate an enumeration block in a classdef definition.
@xseealso{@ref{XREFenumeration,,enumeration}}
@end deftypefn


@anchor{XREFkwcategoryExecutionEnvironment}
@subheading Execution Environment

@c libinterp/parse-tree/lex.ll
@anchor{XREF__FILE__}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} __FILE__
When the lexer recognizes the @qcode{"__FILE__"} keyword it returns a character
array containing the full name and path of the file that is being executed.
@qcode{"__FILE__"} will return @qcode{"stdin"} if called from the command line.
@xseealso{@ref{XREF__LINE__,,__LINE__}}
@end deftypefn


@c libinterp/parse-tree/lex.ll
@anchor{XREF__LINE__}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn {} {} __LINE__
When the lexer recognizes the @qcode{"__LINE__"} keyword it returns a numeric
value containing the current input line number of the function or file being
executed.  @qcode{"__LINE__"} will return @code{1} if called from the command
line.
@xseealso{@ref{XREF__FILE__,,__FILE__}}
@end deftypefn


@node Parser
@section Parser
@cindex parser

The parser has a number of variables that affect its internal operation.
These variables are generally documented in the manual alongside the code that
they affect.

In addition, there are three non-specific parser customization functions.
@w{@code{add_input_event_hook}} can be used to schedule a user function for
periodic evaluation.  @w{@code{remove_input_event_hook}} will stop a user
function from being evaluated periodically.

@c add_input_event_hook libinterp/corefcn/input.cc
@anchor{XREFadd_input_event_hook}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {@var{id} =} add_input_event_hook (@var{fcn})
@deftypefnx {} {@var{id} =} add_input_event_hook (@var{fcn}, @var{data})
Add the named function or function handle @var{fcn} to the list of functions
to call periodically when Octave is waiting for input.

The function should have the form

@example
@var{fcn} (@var{data})
@end example

If @var{data} is omitted, Octave calls the function without any arguments.

The returned identifier may be used to remove the function handle from the
list of input hook functions.
@xseealso{@ref{XREFremove_input_event_hook,,remove_input_event_hook}}
@end deftypefn


@c remove_input_event_hook libinterp/corefcn/input.cc
@anchor{XREFremove_input_event_hook}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {} remove_input_event_hook (@var{name})
@deftypefnx {} {} remove_input_event_hook (@var{fcn_id})
Remove the named function or function handle with the given identifier
from the list of functions to call periodically when Octave is waiting
for input.
@xseealso{@ref{XREFadd_input_event_hook,,add_input_event_hook}}
@end deftypefn


Finally, when the parser cannot identify an input token it calls a particular
function to handle this.  By default, this is the internal function
@qcode{"__unimplemented__"} which makes suggestions about possible Octave
substitutes for @sc{matlab} functions.

@c missing_function_hook libinterp/corefcn/variables.cc
@anchor{XREFmissing_function_hook}
@html
<span style="display:block; margin-top:-4.5ex;">&nbsp;</span>
@end html


@deftypefn  {} {@var{val} =} missing_function_hook ()
@deftypefnx {} {@var{old_val} =} missing_function_hook (@var{new_val})
@deftypefnx {} {@var{old_val} =} missing_function_hook (@var{new_val}, "local")
Query or set the internal variable that specifies the function to call
to provide extra information when an unknown identifier is referenced.

When called from inside a function with the @qcode{"local"} option, the
variable is changed locally for the function and any subroutines it calls.
The original variable value is restored when exiting the function.
@xseealso{@ref{XREFmissing_component_hook,,missing_component_hook}}
@end deftypefn

