view doc/interpreter/grammar.txi @ 19628:fe689210525c gui-release

maint: Periodic merge of stable to gui-release.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 10:05:42 -0500
parents e0775b4f41dd 446c46af4b42
children 0e1f5a750d00
line wrap: on
line source

@c Copyright (C) 1996-2013 John W. Eaton
@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 the
@c Free Software Foundation; either version 3 of the License, or (at
@c your option) any later version.
@c
@c Octave is distributed in the hope that it will be useful, but WITHOUT
@c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@c FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
@c 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 <http://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 following identifiers are keywords, and may not be used as variable
or function names:

@multitable @columnfractions .33 .33 .33
@item @code{__FILE__} @tab @code{__LINE__} @tab @code{break}
@item @code{case} @tab @code{catch} @tab @code{classdef}
@item @code{continue} @tab @code{do} @tab @code{else}
@item @code{elseif} @tab @code{end} @tab @code{end_try_catch}
@item @code{end_unwind_protect} @tab @code{endclassdef} @tab @code{endenumeration}
@item @code{endevents} @tab @code{endfor} @tab @code{endfunction}
@item @code{endif} @tab @code{endmethods} @tab @code{endparfor}
@item @code{endproperties} @tab @code{endswitch} @tab @code{endwhile}
@item @code{enumeration} @tab @code{events} @tab @code{for}
@item @code{function} @tab @code{global} @tab @code{if}
@item @code{methods} @tab @code{otherwise} @tab @code{parfor}
@item @code{persistent} @tab @code{properties} @tab @code{return}
@item @code{static} @tab @code{switch} @tab @code{try}
@item @code{until} @tab @code{unwind_protect} @tab @code{unwind_protect_cleanup}
@item @code{while}
@end multitable

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

@DOCSTRING(iskeyword)

@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.  For example, @code{allow_noninteger_range_as_index} is discussed
in the section on index expressions.

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

@DOCSTRING(add_input_event_hook)

@DOCSTRING(remove_input_event_hook)

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.

@DOCSTRING(missing_function_hook)