-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
aGrammarNotationForTreeLanguages.scroll
70 lines (44 loc) · 1.92 KB
/
aGrammarNotationForTreeLanguages.scroll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
date 9/10/2017
tags All Scroll ScrollPapers
title Parsers: a language for making languages
header.scroll
printTitle
printAuthors
printDate
mediumColumns 1
I introduce the core idea of a new language for making languages.
italics
***
# Introduction
Creating a great programming language is a multi-step process. One step in that process is to decide on syntax and formally define a language in a parser notation such as BNF. Unfortunately, like the programming languages they describe, these parser notations are complex, brittle and error-prone.
Below I introduce the core idea of a much simpler parser notation for defining 2D Languages.
***
# Parsers: A language for building languages
A microlang in Parsers consists of a set of Parser Definitions including a catchall Parser Definition.
A Parser Definition consists of a match rule and optionally another Parsers microlang.
Everything is encoded in the same sytnax (Particles), hence Parsers is written in Parsers.
# Example
A Parsers file for an imagined microlang called Tally, with 2 Parsers `{+, -}` might look like this:
code
TallyParser
catchAllParser errorParser
parsers
errorParser
expressionParser extends TallyParser
words int+
+Parser extends expressionParser
-Parser extends expressionParser
A valid program in the Tally microlang defined by the file above:
code
+ 4 5
- 1 1
***
# Conclusion and Future Work
The introduction above is minimal but shows the core idea: a new notation (Particles) can be used to define new languages in a language (Parsers) that itself is defined in Parsers on top of Particles.
We have developed and open-sourced Parsers a compiler-compiler implementing these ideas.
https://github.com/breck7/scrollsdk/tree/main/langs/parsers Parsers
Future publications and/or open source releases will delve into the additional features found in the compiler-compiler.
****
# Related Posts
printRelated ScrollPapers
footer.scroll