Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:prolog:pllib:parser_pascal [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== Parser pascal ======
 +{{tag>​parser DCG}}
 +===== Description =====
 +Parsing the declarative part of a Pascal block
 +
 +**Source**: ​ The Art of Prolog
 +===== Download =====
 +Program source code: {{parser_pascal.pl}}
 +===== Listing =====
 +<code prolog>
 +/*
 +        The grammar for the declarative part of a Pascal program.
 +*/
 +        declarative_part -->
 +            const_declaration,​ type_declaration,​
 +            var_declaration,​ procedure_declaration.
 +
 +%        Constant declarations
 +
 +        const_declaration --> [ ].
 +        const_declaration -->
 +            [const], const_definition,​ [;], const_definitions.
 +
 +        const_definitions --> [ ].
 +        const_definitions -->
 +            const_definition,​ [;], const_definitions.
 +
 +        const_definition --> identifier, [=], constant.
 +
 +        identifier --> [X], {atom(X)}.
 +
 +        constant --> [X], {constant(X)}.
 +
 +%        Type declarations
 +
 +        type_declaration --> [ ].
 +        type_declaration -->
 +            [type], type_definition,​ [;], type_definitions.
 +
 +        type_definitions --> [ ].
 +        type_definitions --> type_definition,​ [;], type_definitions.
 +
 +        type_definition --> identifier, [=], type.
 +
 +        type --> ['​INTEGER'​].
 +        type --> ['​REAL'​].
 +        type --> ['​BOOLEAN'​].
 +        type --> ['​CHAR'​].
 +
 +%        Variable declarations
 +
 +        var_declaration --> [ ].
 +        var_declaration -->
 +            [var], var_definition,​ [;], var_definitions.
 +
 +        var_definitions --> [ ].
 +        var_definitions --> var_definition,​ [;], var_definitions.
 +        var_definition --> identifiers,​ [:], type.
 +
 +        identifiers --> identifier.
 +        identifiers --> identifier, [,], identifiers.
 +
 +%        Procedure declarations
 +
 +        procedure_declaration --> [ ].
 +        procedure_declaration --> procedure_heading,​ [;], block.
 +
 +        procedure_heading -->
 +            [procedure],​ identifier, formal_parameter_part.
 +
 +        formal_parameter_part --> [ ].
 +        formal_parameter_part --> ['​('​],​ formal_parameter_section,​ ['​)'​].
 +
 +        formal_parameter_section --> formal_parameters.
 +        formal_parameter_section -->
 +            formal_parameters,​ [;], formal_parameter_section.
 +
 +        formal_parameters --> value_parameters.
 +
 +        formal_parameters --> variable_parameters.
 +
 +        value_parameters --> var_definition.
 +
 +        variable_parameters --> [var], var_definition.
 +
 +%     ​Program 19.3:  Parsing the declarative part of a Pascal block
 +</​code>​
 +===== Comments =====
  
pl/prolog/pllib/parser_pascal.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0