瀏覽代碼

docs: document grammar.js

pull/136/head
Amaan Qureshi 3 年之前
父節點
當前提交
b906e05ba4
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: E67890ADC4227273
共有 1 個文件被更改,包括 50 次插入0 次删除
  1. +50
    -0
      grammar.js

+ 50
- 0
grammar.js 查看文件

@ -1,3 +1,15 @@
/**
* @file C grammar for tree-sitter
* @author Max Brunsfeld
* @license MIT
*/
/* eslint-disable arrow-parens */
/* eslint-disable camelcase */
/* eslint-disable-next-line spaced-comment */
/// <reference types="tree-sitter-cli/dsl" />
// @ts-check
const PREC = {
PAREN_DECLARATOR: -10,
ASSIGNMENT: -1,
@ -1026,6 +1038,21 @@ module.exports.PREC = PREC
function preprocIf (suffix, content) {
function elseBlock ($) {
/**
*
* @param {string} suffix
*
* @param {RuleBuilder<string>} content
*
* @return {RuleBuilders<string, string>}
*/
/**
*
* @param {GrammarSymbols<string>} $
*
* @return {ChoiceRule}
*
*/
return choice(
suffix ? alias($['preproc_else' + suffix], $.preproc_else) : $.preproc_else,
suffix ? alias($['preproc_elif' + suffix], $.preproc_elif) : $.preproc_elif,
@ -1071,12 +1098,35 @@ function preprocessor (command) {
function commaSep (rule) {
return optional(commaSep1(rule))
/**
* Creates a preprocessor regex rule
*
* @param {RegExp|Rule|String} command
*
* @return {AliasRule}
*/
}
function commaSep1 (rule) {
return seq(rule, repeat(seq(',', rule)))
/**
* Creates a rule to optionally match one or more of the rules separated by a comma
*
* @param {Rule} rule
*
* @return {ChoiceRule}
*
*/
}
function commaSepTrailing (recurSymbol, rule) {
return choice(rule, seq(recurSymbol, ',', rule))
/**
* Creates a rule to match one or more of the rules separated by a comma
*
* @param {Rule} rule
*
* @return {SeqRule}
*
*/
}

Loading…
取消
儲存