From 8e720436eacf3ee2eaf2261bc719e145cc9dad39 Mon Sep 17 00:00:00 2001
From: Anatoli Babenia Vocabulary
following nonterminal matches zero or more cow
s in a row, such as
cowcowcow
:
a -> null | a "cow"
+
+Syntax for matching input if you're not using a tokenizer.
+
+ * `"if"` - match `if` literally
+ * `"if"i` - match `if` case-insensitive
+ * `.` - match any symbol except newline
+ * `[^]` - match anything including newline
+ * `[a-zA-Z]` - match symbols in range
+ * `[^a-zA-Z]` - match symbols not in range
+ * `:+` - match previous construction one or more time
+ * `:*` - match zero times or more
+ * `:?` - zero time or one time
+
+
By default, nearley wraps everything matched by a rule into an array. For
example, when rule -> "tick" "tock"
matches the string "ticktock"
, it
@@ -389,7 +404,7 @@
id
returns the first element of the data
array. This is useful to
extract the content of a single-element array: foo -> bar {% id %}
Comments are marked with ‘#’. Everything from #
to the end of a line is
From c4d3cff55d94aa3641b3f5782739c126b01dd1ef Mon Sep 17 00:00:00 2001
From: Anatoli Babenia nearley.js2
Writing a parser
Vocabulary
following nonterminal matches zero or more cow
s in a row, such as
cowcowcow
:
a -> null | a "cow"
-
Syntax for matching input if you're not using a tokenizer.
-
- * `"if"` - match `if` literally
- * `"if"i` - match `if` case-insensitive
- * `.` - match any symbol except newline
- * `[^]` - match anything including newline
- * `[a-zA-Z]` - match symbols in range
- * `[^a-zA-Z]` - match symbols not in range
- * `:+` - match previous construction one or more time
- * `:*` - match zero times or more
- * `:?` - zero time or one time
-
-
+Syntax for matching input if you’re not using a tokenizer.
+"if"
- match if
literally"if"i
- match if
case-insensitive.
- match any symbol except newline[^]
- match anything including newline[a-zA-Z]
- match symbols in range[^a-zA-Z]
- match symbols not in range:+
- match previous construction one or more time:*
- match zero times or more:?
- zero time or one timeBy default, nearley wraps everything matched by a rule into an array. For
example, when rule -> "tick" "tock"
matches the string "ticktock"
, it
@@ -404,7 +403,7 @@
id
returns the first element of the data
array. This is useful to
extract the content of a single-element array: foo -> bar {% id %}
Comments are marked with ‘#’. Everything from Syntax for matching input if you’re not using a tokenizer. (1) (2) RegExp charsets will not work with tokenizer. By default, nearley wraps everything matched by a rule into an array. For
example, when Comments are marked with ‘#’. Everything from You can use valid RegExp charsets in a rule (unless you’re using a
-tokenizer): The You can create case-insensitive string literals by adding an Note that if you are using a lexer, your lexer should use the nearley supports the #
to the end of a line is
diff --git a/docs/md/grammar.md b/docs/md/grammar.md
index ddaf5784..6f212eb5 100644
--- a/docs/md/grammar.md
+++ b/docs/md/grammar.md
@@ -62,6 +62,20 @@ following nonterminal matches zero or more `cow`s in a row, such as
a -> null | a "cow"
```
+### Matching Rules
+
+Syntax for matching input if you're not using a tokenizer.
+
+ * `"if"` - match `if` literally
+ * `"if"i` - match `if` case-insensitive
+ * `.` - match any symbol except newline
+ * `[^]` - match anything including newline
+ * `[a-zA-Z]` - match symbols in range
+ * `[^a-zA-Z]` - match symbols not in range
+ * `:+` - match previous construction one or more time
+ * `:*` - match zero times or more
+ * `:?` - zero time or one time
+
### Postprocessors
By default, nearley wraps everything matched by a rule into an array. For
diff --git a/docs/package-lock.json b/docs/package-lock.json
index 3445c0af..f743ef24 100644
--- a/docs/package-lock.json
+++ b/docs/package-lock.json
@@ -472,7 +472,6 @@
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
"source-map": "^0.6.1",
- "uglify-js": "^3.1.4",
"wordwrap": "^1.0.0"
},
"bin": {
From 84f7a24df27b2974016849bea910cce92fb95116 Mon Sep 17 00:00:00 2001
From: Anatoli Babenia Matching Rules
+"if"
- match if
literally"if"i
- match if
case-insensitive"if"i
- match if
case-insensitive (1).
- match any symbol except newline[^]
- match anything including newline[a-zA-Z]
- match symbols in range[a-zA-Z]
- match symbols in range (2)[^a-zA-Z]
- match symbols not in range:+
- match previous construction one or more time:*
- match zero times or more:?
- zero time or one timei
suffix will not work with a lexer if you’re using one. Your lexer
+should use the i
flag in its regexes instead.Postprocessors
rule -> "tick" "tock"
matches the string "ticktock"
, it
@@ -409,16 +412,6 @@ Comments
#
to the end of a line is
ignored:
-expression -> number "+" number # sum of two numbers
Charsets
-not_a_letter -> [^a-zA-Z]
.
character can be used to represent any character.Case-insensitive string literals
-i
after the
-string literal:cow -> "cow"i # matches CoW, COW, and so on.
i
flag in its
-regexes instead. That is, if you are using a lexer, you should not use the
-i
suffix in nearley.EBNF
*
, ?
, and +
operators from
EBNF as shown: