Workflowy selector parser

A parser for a DSL used to select specific items in a Workflowy hierarchy.

Dette scriptet burde ikke installeres direkte. Det er et bibliotek for andre script å inkludere med det nye metadirektivet // @require https://update.greasyfork.org/scripts/22247/141751/Workflowy%20selector%20parser.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Forfatter
fiatjaf
Versjon
0.0.1.20160814232256
Lagd
12.08.2016
Oppdatert
14.08.2016
Size
16,8 kB
Lisens
I/T

Intended to be required by Workflowy userscripts.

pegjs source:

expr
  = s:selector _ ch:(connector? _ selector _)* {
    return [[null, s]].concat(ch.map(s => [s[0], s[2]]))
  }

selector
  = id:('#' [a-z0-9-]i+) { return {type: 'id', val: id[1].join('')} }
  / re:('/' [^/]+ '/') { return {type: 'regex', val: new RegExp(re[1].join(''))} }
  / name:("'" [^']i+ "'") { return {type: 'name', val: name[1].join('')} }
  / any:'*' { return {type: 'any'} }

connector
  = '>' { return 'directchild' }

_ = ' '*