Customizable Parsing Test Repository

Module

BuiltInConcepts

This module exports precisely one identifier, builtInConcepts, which contains the JSON definition of all the built-in mathematical concepts in this repository. These concepts are chosen because they commonly appear in introduction-to-proof courses, which is the inteded use of the Lurch application for which this parsing tool was designed.

Source

Members

staticconstant

builtInConcepts

The JSON definition of all the built-in concepts for this repository. See the top of this module for what this means, and view the source code at the link below for the full definition of all of the concepts.

This JSON data structure is used whenever anyone adds built-in concepts to a Converter instance. In particular, this happens when constructing any instance of the example converter, but it can be used in other converter instances as well.

We expect that anyone defining a new language will probably begin by constructing a Converter instance and then a Language instance using Language.fromJSON(), which automatically adds just the subset of built-in concepts that the user wants. This is the strategy employed by the example converter.

This data structure is an array of objects with the following properties:

  • name: the name of the concept, which can be used in the putdown notation for other concepts when their structure depends upon this one (e.g., if this concept is for integers, and you name it "Integer", then later when you define addition of integers, you may write its putdown representation as "(+ Integer Integer)" to refer to this concept by name).
  • parentType: the name of the parent type of this concept, which should be a syntactic type, as defined in the syntactic types module.
  • regularExpression: this field is included only if the concept is atomic, and we must define how to recognize an instance of that concept as a token before parsing. For instance, if the concept is "Integer", then we need to somehow specify the regular expression for integers. Rather than include the code for it directly here, there are a set of predefined regular expressions for standard mathematical notations that appear in a static member of the Language class. The value of this field should be the name of one of these predefined regular expressions.
  • putdown: this field is included only if the concept is non-atomic, and defines both how to write it in putdown notation and also what arguments are needed to construct it. If we return to the example of addition of integers, written in putdown as "(+ Integer Integer)", then that notation tells us that addition requires two integers as arguments, and that the way it should be represented in putdown is using the template "(+ A B)", where A and B should be replaced with the putdown representations of the summands.
  • options: this field is optional and, if included, will be passed as the final argument in a call to addConcept(). See the documentation of that function for the possible options you can include in this options object, and the meaning of each.

Source