forked from OpenUserJS/OpenUserJS.org
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Misc note(s): * `$ git checkout greasemonkey/greasemonkey/master peg.txt` after remote is added temporarily Applies to OpenUserJS#285
- Loading branch information
Martii
committed
Jul 18, 2015
1 parent
ddc5a6a
commit 03f9107
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// PEG grammar for parsing user script metadata | ||
// http://pegjs.majda.cz/online | ||
|
||
/* | ||
Test value: | ||
|
||
// ==UserScript== | ||
// @name Metadata Test | ||
// @name:de Auf deutsch bitte! | ||
// @namespace test | ||
// @description Test value including all metas. | ||
// @version 1.2.3 | ||
// @icon http://example.com/favicon.ico | ||
// @include http://example.com/* | ||
// @match http://example.net/* | ||
// @exclude http://example.com/foo | ||
// @run-at document-start | ||
// @grant none | ||
// @downloadURL http://example.org/foo.user.js | ||
// @updateURL http://example.org/foo.meta.js | ||
// @require http://example.net/library.js | ||
// @resource css http://example.net/library.css | ||
// @noframes | ||
// ==/UserScript== | ||
|
||
*/ | ||
|
||
/* | ||
// Uncomment to parse an entire metadata block. | ||
// I.E for testing/development. | ||
meta = | ||
"// ==UserScript==\n" | ||
lines:line* | ||
"// ==/UserScript==" ("\n"?) | ||
{ return lines; } | ||
*/ | ||
|
||
line = | ||
"// @" | ||
meta:( | ||
keyword0 / | ||
keyword1 / | ||
keyword2 / | ||
keywordLocale) | ||
"\n"? | ||
{ return meta; } | ||
|
||
whitespace = [ \t\n]+ | ||
non_whitespace = $[^ \t\n]+ | ||
non_newline = $[^\n]+ | ||
|
||
keyword0 = | ||
keyword:( | ||
"noframes" | ||
) | ||
{ return {keyword:keyword}; } | ||
|
||
keyword1 = | ||
keyword:( | ||
"downloadURL" / | ||
"exclude" / | ||
"grant" / | ||
"icon" / | ||
"include" / | ||
"installURL" / | ||
"match" / | ||
"namespace" / | ||
"require" / | ||
"run-at" / | ||
"updateURL" / | ||
"version" | ||
) | ||
whitespace | ||
value:non_newline | ||
{ return {keyword:keyword, value:value}; } | ||
|
||
keyword2 = | ||
keyword:("resource") | ||
whitespace | ||
value1:non_whitespace | ||
whitespace | ||
value2:non_newline | ||
{ return {keyword:keyword, value1:value1, value2:value2}; } | ||
|
||
keywordLocale | ||
= keyword:( | ||
"description" / | ||
"name" | ||
) | ||
locale:(":" localeValue:$[a-zA-Z-]+ { return localeValue })? | ||
whitespace | ||
value:non_newline | ||
{ return {keyword:keyword, locale:locale, value:value}; } | ||
|