grammarjs / grammar

Language Grammar Builder. All the grammars (html, css, etc.) are currently works in progress :)
18 stars 2 forks source link

add js/css "dependency" grammars #18

Open lancejpollard opened 10 years ago

lancejpollard commented 10 years ago

grammars for require, and @import and es6 import. maybe this is possible.

lancejpollard commented 10 years ago

var grammar = new Grammar;
grammar.use(semver());
var rule = grammar.rule;

rule('statement')
  .match(
    'require', 
    ':ws',
    '(', 
    ':ws',
    ':statement.path',
    ':ws',
    ')');

rule('statement.path')
  .match(
    ':statement.organization',
    ':punctuation.slash',
    ':statement.repository',
    ':statement.version?');

rule('statement.organization')
  .match(/\w+/);

rule('statement.repository')
  .match(/\w+/);

rule('statement.version')
  .match(
    ':punctuation.at',
    ':semver');