# $Id: SYNTAX,v 1.16 2003/04/02 08:08:02 cons Exp $

Here is Pan's syntax (mainly) by the example. For a more formal and
exhaustive definition, please refer to the Pan Language Specification
document available in the "doc" directory (see pan-spec.p*).

If you're really desperate, you can also look at the Lex and Yacc
sources: parser/pan_l.l and parser/pan_y.y.

For more examples, see the sample files in "doc/eg" and the test files
in the "t" directory.

 declaration template <tplname>;
 object template <tplname>;
 structure template <tplname>;
 template <tplname>;
 include <tplname>;
 delete <path>;
 <path> = <dml>;
 valid <path> = <dml>;
 type <path> = <extended_type_definition>;
 define type <identifier> = <extended_type_definition>;
 define function <identifier> = <dml>;
 define variable <identifier> = <dml>;

Other things that are not fully understood/implemented yet:

 final <path> = <dml>;
 (access control)
 (context as LLD multiplexor)

Where:
 <tplname> is a template name matching \w[\w\-\+\.]*
 <identifier> is an identifier (like in C) matching [_a-zA-Z]\w*
 <path> is an element path _between quotes_ like "/hardware/ram/size"
 <long> is a long integer
 <string> is a string within single or double quotes, or using the
  shell "here-doc" syntax (see also the test file t/strings1.tpl)

Type definitions:
  <identifier>				for builtin types: integer boolean...
  <identifier>(<long>..)		... with minimum value
  <identifier>(..<long>)		... with maximum value
  <identifier>(<long>..<long>)		... with minimum and maximum values
  <identifier>(<long>)			... with identical min and max values
  <type_definition>[]			meaning a list of <type_definition>
  <type_definition>[<long>..]		... with minimum value
  <type_definition>[..<long>]		... with maximum value
  <type_definition>[<long>..<long>]	... with minimum and maximum values
  <type_definition>[<long>]		... with identical min and max values
  <type_definition>{}			meaning a table of <type_definition>
  <type_definition>{<long>..}		... with minimum value
  <type_definition>{..<long>}		... with maximum value
  <type_definition>{<long>..<long>}	... with minimum and maximum values
  <type_definition>{<long>}		... with identical min and max values
  <type_definition>*			meaning a string link to a <type_definition>
  {					for records/structures
    <record_line_definition>
    ...
  }

Record line definitions:
  <path> <sep> <extended_type_definition>
					where <sep> is : for mandatory fields
					or ? for optional ones
  include <identifier>			include the named record type

Extended type definitions:
  <type_definition>			normal type definition
  <type_definition> with <dml>		with additional validation code
  <type_definition> descro <string>	with description string
  <type_definition> with <dml> descro <string>
  <type_definition> descro <string> with <dml>

Data Manipulation Language (DML):
 - literals: 123 0755 0xdead 3.14 1e-10 "foo" "a\tb" true undef
 - variables:
	x = 0;
	x = y = 0;
	x = x + 1;
 - expressions: mostly like in C for +, *, ==, <, &&...
	1 + 2 * 3;
	(1 <= (x * 2)) && !y;
 - flow control: if while {}-block return()
	"/foo" = if (value("/x")) 1 else 2;
 - user defined and builtin functions:
	foo();
	bar(1, 2);
