You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: courses/RascalAmendmentProposals/RAP2/RAP2.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,24 +12,24 @@ sidebar_position: 2
12
12
13
13
## Abstract
14
14
15
-
The goal is to remove a number of features for calling parsers of different types and unify them in a single concept. **This concept is that any Rascal type represents a parser and we should be able to \`call\` this parser using a unified syntax.** We propose to not introduce new syntax at all, but to reuse the function call syntax. To parse using a Rascal type, the function name is represented by a reified type, like so:
15
+
The goal is to remove a number of features for calling parsers of different types and unify them in a single concept. **This concept is that any Rascal type represents a parser and we should be able to `call` this parser using a unified syntax.** We propose to not introduce new syntax at all, but to reuse the function call syntax. To parse using a Rascal type, the function name is represented by a reified type, like so:
16
16
17
-
*\#int(“123”)
18
-
* parses the string “123” to the integer \`123\`.
17
+
*`#int(“123”)`
18
+
* parses the string “123” to the integer `123`.
19
19
* based on rascal expression parser or rascal-value parser
* uses the parser generated for C compilation units to parse a given C program in the given file.
22
22
* Based on (data-dependent) Rascal-generated parser
23
23
24
-
Library functions like \`parse\` and \`readTextValueString\` will become deprecated after this feature has been added. Also the “as type” expression notation is redundant after this addition.
24
+
Library functions like `parse` and `readTextValueString` will become deprecated after this feature has been added. Also the “as type” expression notation is redundant after this addition.
25
25
26
26
We will have fewer library functions and fewer expression syntaxes after this, without loss of functionality.
27
27
28
-
Parsing functions, as generated by types here, have parameters. The first and only positional parameter is what they will parse. The other parameters will be keyword parameters to provide options to the parse, such as \`allowAmbiguity\` and \`src\` and to provide contextual data to data-dependent parsers (when they are added).
28
+
Parsing functions, as generated by types here, have parameters. The first and only positional parameter is what they will parse. The other parameters will be keyword parameters to provide options to the parse, such as `allowAmbiguity` and `src` and to provide contextual data to data-dependent parsers (when they are added).
29
29
30
30
## Motivation
31
31
32
-
* There are several ways of calling a parser right now in Rascal, none of them unique in terms of features, just different in syntax. It’s unnecessary. E.g. parse functions, read functions like readTextValueString, the \[AsType\] syntax, pattern matching. Is there more?
32
+
* There are several ways of calling a parser right now in Rascal, none of them unique in terms of features, just different in syntax. It’s unnecessary. E.g. parse functions, read functions like readTextValueString, the [AsType] syntax, pattern matching. Is there more?
33
33
* Each has its own syntax
34
34
* Each has its own way of dealing with exceptions
35
35
* Each has its own configurability
@@ -40,25 +40,25 @@ Parsing functions, as generated by types here, have parameters. The first and on
* Both expressions return a value of type \`\&T\` (as instantiated) when successful, or they throw a syntaxError or a validationError exception value (see below)
* Both expressions return a value of type `&T` (as instantiated) when successful, or they throw a syntaxError or a validationError exception value (see below)
51
51
52
52
Semantically, the parser which will be called switches on the kind of type and the kind of input:
53
53
54
-
*\[builtin, text\] For builtin types such as list, int, applied to a text file or string, the Rascal text value parser will be called;
55
-
*\[builtin, bin\] For builtin types applied to a binary serialized file, the Rascal binary value parser will be called
56
-
*\[data, text\] the Rascal text value parser will be called, and the value will be validated against the abstract syntax definition defined by the given reified type. Note that this gives rise to programmatically constructed abstract grammars which are used as parsers.
57
-
*\[data, bin\] the Rascal binary value parser will be called and the result will be checked against the expected top-level type
58
-
*\[syntax, text\]
54
+
*[builtin, text] For builtin types such as list, int, applied to a text file or string, the Rascal text value parser will be called;
55
+
*[builtin, bin] For builtin types applied to a binary serialized file, the Rascal binary value parser will be called
56
+
*[data, text] the Rascal text value parser will be called, and the value will be validated against the abstract syntax definition defined by the given reified type. Note that this gives rise to programmatically constructed abstract grammars which are used as parsers.
57
+
*[data, bin] the Rascal binary value parser will be called and the result will be checked against the expected top-level type
58
+
*[syntax, text]
59
59
* if the input does not start with “appl(” then a generated parser will be called to parse the text using the given non-terminal/grammar in the reified type
60
60
* If the input is an already serialized parse tree, the code will use the values reader and validate if the top-type is indeed the expected non-terminal or throw a validation exception
61
-
*\[syntax, bin\] the input is an already serialized parse tree in binary input, the code will use the values reader and validate if the top-type is indeed the expected non-terminal or throw a validation exception
61
+
*[syntax, bin] the input is an already serialized parse tree in binary input, the code will use the values reader and validate if the top-type is indeed the expected non-terminal or throw a validation exception
0 commit comments