
!*************************************************************************
!									 *
! © Copyright 2005 Hewlett-Packard Development Company, L.P.		 *
!									 *
! Confidential computer software. Valid license  from  HP  required  for *
! possession, use or copying. Consistent with  FAR  12.211  and  12.212, *
! Commercial Computer Software,  Computer  Software  Documentation,  and *
! Technical  Data  for  Commercial  Items  are  licensed  to  the   U.S. *
! Government under vendor's standard commercial license.		 *
!									 *
!*************************************************************************
 
!++
! Facility:
!   XLSE (eXtended LSE)
! 
! Abstract:
!   This module provides "Kernighan & Ritchie" style (#1) formatting of C
!   language constructs in comformance with the C coding conventions described
!   in the _Digital Software Engineering Manual, 1988_.
!
!   This module must be used in conjunction with the C-SEM-COMMON.LSE file
!   of common definitions.
! 
! Author:
!   Doug Rayner, CASEE Group, MEMEX Project
!   André Pavanello, CASEE Group, MEMEX Project
!   W. Ward Clark, CASEE Group, MEMEX Project
! 
! Creation Date: 15-Oct-87
! 
! Modification History:
!   X2.1    WWC   5-Jul-89  upgrade to VAXC V3.0-006 (LSE V2.3)
!			    extracted from C-SEM.LSE
!   X3.0    WWC   1-Jan-90  upgrade to LSE V3.0
!   X3.0-1  WWC   4-Feb-90  remove some spaces before '('
!--
!
!+
!   Assume /LANGUAGE=C for all following definitions.
!-
SET LANGUAGE C

!+
!   Function-level constructs
!-
DELETE PLACEHOLDER "function_definition"
DEFINE PLACEHOLDER "function_definition" -
    /DESCRIPTION="Defines a function" -
    /TOPIC="Language_topics functions" -
    /TYPE=NONTERMINAL

    ""
    "[@static or extern@] {@data type@} [@*@]{@function name@}({@parameter type list@})"
    "[@function level comments@]"
    "{"
    "	[@block declaration@]..."
    "	{@statement@}..."
    "	return [@expression@];"
    "}"

    END DEFINE

DELETE TOKEN "function"
DEFINE TOKEN "function" /PLACEHOLDER="function_definition"

DELETE TOKEN "function_definition"
DEFINE TOKEN "function_definition" /PLACEHOLDER="function_definition"

DELETE TOKEN "main_function_definition"
DEFINE TOKEN "main_function_definition" -
    /DESCRIPTION="Defines a main function" -
    /TOPIC="Language_topics functions"

    ""
    "{@main() OR main function that accept arguments from the command line@}"
    "[@MAIN_PROGRAM@]"
    "[@function level comments@]"
    "{"
    "	[@block declaration@]..."
    "	{@statement@}..."
    "	return [@expression@];"
    "}"

    END DEFINE

DELETE TOKEN "vararg_function_definition"
DEFINE TOKEN "vararg_function_definition" -
    /DESCRIPTION="Defines a function with a variable-length argument list" -
    /TOPIC="Language_topics Variable_Length_Argument_Lists"

    ""
    "[@static or extern@] {@data type@} [@*@]{@function name@}({@parameter type list@}, va_alist)"
    "va_dcl"
    "[@function level comments@]"
    "{"
    "	va_list {@vararg list ptr@};"
    "	[@block declaration@]..."
    "	{@statement@}..."
    "	return [@expression@];"
    "}"

    END DEFINE
!
!+
!   Statement constructs
!-
DELETE PLACEHOLDER "compound statement"
DEFINE PLACEHOLDER "compound statement" -
    /DESCRIPTION="A group of statements (also called a ""block"")" -
    /TOPIC="Language_topics Block" -
    /TYPE=NONTERMINAL

    "{"
    "	[@block declaration@]..."
    "	{@statement@}..."
    "}"

    END DEFINE

DELETE TOKEN "if"
DEFINE TOKEN "if" -
    /DESCRIPTION="Tests an expression and establishes actions" -
    /TOPIC="Language_topics Statements if"

    "if ({@expression@}) {"
    "	{@statement@}..."
    "}"
    "[@else if (expression) statement@]..."
    "[@else statement@]"

    END DEFINE

DELETE PLACEHOLDER "else if (expression) statement"
DEFINE PLACEHOLDER "else if (expression) statement" -
    /DESCRIPTION="else if {@statement@}" -
    /DUPLICATION=VERTICAL -
    /TOPIC="Language_topics statements if" -
    /TYPE=NONTERMINAL

    "else if ({@expression@}) {"
    "	{@statement@}..."
    "}"

    END DEFINE

DELETE PLACEHOLDER "else statement"
DEFINE PLACEHOLDER "else statement" -
    /DESCRIPTION="else {@statement@}" -
    /DUPLICATION=VERTICAL -
    /TOPIC="Language_topics Statements if" -
    /TYPE=NONTERMINAL

    "else {"
    "	{@statement@}..."
    "}"

    END DEFINE

DELETE TOKEN "for"
DEFINE TOKEN "for" -
    /DESCRIPTION="Executes a statement as long as a particular condition is satisfied" -
    /TOPIC="Language_topics Statements for"

    "for ([@expression@]; [@expression@]; [@expression@]) {"
    "	{@statement@}..."
    "}"

    END DEFINE

DELETE TOKEN "while"
DEFINE TOKEN "while" -
    /DESCRIPTION="Executes a statement as long as a particular condition is satisfied" -
    /TOPIC="Language_topics Statements while"

    "while ({@expression@}) {"
    "	{@statement@}..."
    "}"

    END DEFINE

DELETE TOKEN "do"
DEFINE TOKEN "do" -
    /DESCRIPTION="executes a statement as long as a particular condition is satisfied" -
    /TOPIC="Language_topics Statements do"

    "do {"
    "	{@statement@}..."
    "} while ({@expression@});"

    END DEFINE

DELETE TOKEN "switch"
DEFINE TOKEN "switch" -
    /DESCRIPTION="transfers control to one of a list of cases" -
    /TOPIC="Language_topics Statements switch"

    "switch ({@expression@}) {"
    "	case {@constant expression@}:"
    "	[@case constant_expression:@]..."
    "		{@statement@}..."
    "		break;"
    "	{@another case@}..."
    "	[@default case@]"
    "}"

    END DEFINE
!
!+
!   Structure constructs
!-
DELETE TOKEN "struct"
DEFINE TOKEN "struct" -
    /DESCRIPTION="A struct declaration with tag name and/or member declarations" -
    /TOPIC="Language_topics Data_Types Structure"

    "struct [@tag name@] {"
    "	{@member declaration@}..."
    "} {@declarator and initializer@}...;"

    END DEFINE

DELETE PLACEHOLDER "struct declaration" 
DEFINE PLACEHOLDER "struct declaration" -
    /DESCRIPTION="Structure declaration with optional tag name and member declarations" -
    /DUPLICATION=VERTICAL -
    /TOPIC="Language_topics Data_Types Structure" -
    /TYPE=NONTERMINAL

    "struct [@tag name@] {"
    "	{@member declaration@}..."
    "	};"

    END DEFINE

DELETE PLACEHOLDER "variant_struct"
DEFINE PLACEHOLDER "variant_struct" -
    /DESCRIPTION="Allows structure nesting without need to refer to intermediate aggregate name" -
    /TYPE=NONTERMINAL

    "variant_struct {"
    "	{@member declaration@}..."
    "}"

    END DEFINE

DELETE PLACEHOLDER "variant_union"
DEFINE PLACEHOLDER "variant_union" -
    /DESCRIPTION="Allows union nesting without need to refer to intermediate aggregate name" -
    /TYPE=NONTERMINAL

    "variant_union {"
    "	{@member declaration@}..."
    "}"

    END DEFINE

DELETE PLACEHOLDER "enum declaration"
DEFINE PLACEHOLDER "enum declaration" -
    /DESCRIPTION="enum and/or enum tag declaration" -
    /TOPIC="Language_topics Data_Types enum" -
    /TYPE=NONTERMINAL

    "enum [@tag name@] {"
    "	[@enumerator and value@]..."
    "}"

    END DEFINE

DELETE TOKEN "enum"
DEFINE TOKEN "enum" -
    /DESCRIPTION="An enumeration variable" -
    /TOPIC="Language_topics Data_Types enum"

    "enum [@tag name@] {"
    "	[@enumerator and value@]..."
    "} {@declarator and initializer@}...;"

    END DEFINE
