#comments #language #syntax #s-expr #tokenizer #expression-language #earl

earl-lang-syntax

A simple tokenizer and parser for the language Earl

2 releases (1 stable)

1.0.0 Aug 28, 2020
0.1.0 Aug 28, 2020

#13 in #comment

MIT license

69KB
2K SLoC

Earl Syntax

Earl syntax is an s-expression-like language. It supports lists but not pairs like s-expression.

The main difference between S-expressions and Earl syntax are the multi-line strings and nesting comments.

You should be able to comment out any text given sufficently many semicolons on both sides of the text, e.g. ;;;(...);;;, and you should be able to put whatever inside a string given sufficently many double quotation marks, e.g. """".text here."""".

Description

Strings

A string starts with a double quotation mark ".

A string starts with n (one or more) ", followed by the flags which are any number of characters excluding . and maybe ,, then the body of the string, and finally ends with . or , and n ".

Examples,

"Hello world!"

".Hello world!."

".Hello
world."

""""",
This is a multi-line string,
."""
the continues on here.
,"""""

; A raw string could look like this.
"r.C\User\Name\My Documents\script.js"

Comments

A single-line comments starts with ; and spans until the end of the line (or end of file)

A (nesting) multi-line starts with n ;, followed by (, then some text, and then by ) followed by n ;.

Examples,

; This is a single-line comment

;( This is a
  ;( nesting );
  multi-line comment );

;;( this is also a ;( nesting ); multi-line comment );;

No runtime deps