8 Parsing and Specifying Syntax

The syntax/parse library provides a framework for writing macros and processing syntax. The library provides a powerful language of syntax patterns, used by the pattern-matching form syntax-parse and the specification form define-syntax-class. Macros that use syntax-parse automatically generate error messages based on descriptions and messages embedded in the macro’s syntax patterns.

    8.1 Introduction

    8.2 Examples

      8.2.1 Modules and Reusable Syntax Classes

      8.2.2 Optional Keyword Arguments

      8.2.3 Variants with Uniform Meanings

      8.2.4 Variants with Varied Meanings

        8.2.4.1 Syntactic Normalization

        8.2.4.2 Non-syntax-valued Attributes

      8.2.5 More Keyword Arguments

      8.2.6 Contracts on Macro Sub-expressions

    8.3 Parsing Syntax

    8.4 Specifying Syntax with Syntax Classes

      8.4.1 Pattern Directives

      8.4.2 Pattern Variables and Attributes

    8.5 Syntax Patterns

      8.5.1 Single-term Patterns

      8.5.2 Head Patterns

      8.5.3 Ellipsis-head Patterns

      8.5.4 Action Patterns

    8.6 Defining Simple Macros

    8.7 Literal Sets and Conventions

    8.8 Library Syntax Classes and Literal Sets

      8.8.1 Syntax Classes

      8.8.2 Literal Sets

    8.9 Debugging and Inspection Tools

    8.10 Experimental

      8.10.1 Contracts for Macro Sub-expressions

      8.10.2 Contracts for Syntax Classes

      8.10.3 Reflection

      8.10.4 Procedural Splicing Syntax Classes

      8.10.5 Ellipsis-head Alternative Sets

      8.10.6 Syntax Class Specialization