IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!

#18 Replace jailconf with a peg grammar

オープン
sadaszewski14年前に作成 · 0件のコメント
sadaszewski14年前 にコメント

Something to think about:

JailConf = conf:(JailBlock / Parameter / Comment)* { return { 'JailConf': conf } }

Comment = comment:(_ "#" CommentText  / _ "//" CommentText) {
  return { 'Comment': comment.join('') } 
}

CommentText = [^\n]+ { return text() }

Parameter = _ name:Name _ op:AssignmentOp _ value:Value _ ";" {
  return { 'Parameter': { 'name': name, 'op': op, 'value': value } }
} / _ name:Name _ ";" {
  return { 'Parameter': { 'name': name, 'value': true } }
}

_ = [ \t\r\n]* { return '' }

Name = [a-zA-Z.][a-zA-Z.0-9]* { return text() }

AssignmentOp = "=" / "+="

Value = ListOfStrings / String

String = UnquotedString / SingleQuotedString / DoubleQuotedString

ListOfStrings = head:String tail:(_ ","  _ String)+ { 
	return [head].concat(tail.map(function(a) { return a[3] }))
}

UnquotedString = [^;"',]+ { return text() }

NotSingleQuote = !("'" / "\\") . { return text() }

EscapedSingleQuote = "\\" "'" { return '\\\'' } / 
  "\\\\" { return '\\\\' }

SingleQuotedString = "'" content:(NotSingleQuote / EscapedSingleQuote)* "'" {
  return content.join('')
}

NotDoubleQuote = !("\"" / "\\") . { return text() }

EscapedDoubleQuote = "\\" "\"" { return '\\"' } /
  "\\\\" { return '\\\\' }

DoubleQuotedString = "\"" content:(NotDoubleQuote / EscapedDoubleQuote)* "\"" { return content.join('') }

JailBlock = _ name:JailName _ "{" _ body:JailBody _ "}" _ {
  return { 'JailBlock': { 'name': name, 'body': body } }
}

JailName = [a-zA-Z0-9][a-zA-Z0-9]* { return text() }

JailBody = (Parameter / Comment)*
Something to think about: ``` JailConf = conf:(JailBlock / Parameter / Comment)* { return { 'JailConf': conf } } Comment = comment:(_ "#" CommentText / _ "//" CommentText) { return { 'Comment': comment.join('') } } CommentText = [^\n]+ { return text() } Parameter = _ name:Name _ op:AssignmentOp _ value:Value _ ";" { return { 'Parameter': { 'name': name, 'op': op, 'value': value } } } / _ name:Name _ ";" { return { 'Parameter': { 'name': name, 'value': true } } } _ = [ \t\r\n]* { return '' } Name = [a-zA-Z.][a-zA-Z.0-9]* { return text() } AssignmentOp = "=" / "+=" Value = ListOfStrings / String String = UnquotedString / SingleQuotedString / DoubleQuotedString ListOfStrings = head:String tail:(_ "," _ String)+ { return [head].concat(tail.map(function(a) { return a[3] })) } UnquotedString = [^;"',]+ { return text() } NotSingleQuote = !("'" / "\\") . { return text() } EscapedSingleQuote = "\\" "'" { return '\\\'' } / "\\\\" { return '\\\\' } SingleQuotedString = "'" content:(NotSingleQuote / EscapedSingleQuote)* "'" { return content.join('') } NotDoubleQuote = !("\"" / "\\") . { return text() } EscapedDoubleQuote = "\\" "\"" { return '\\"' } / "\\\\" { return '\\\\' } DoubleQuotedString = "\"" content:(NotDoubleQuote / EscapedDoubleQuote)* "\"" { return content.join('') } JailBlock = _ name:JailName _ "{" _ body:JailBody _ "}" _ { return { 'JailBlock': { 'name': name, 'body': body } } } JailName = [a-zA-Z0-9][a-zA-Z0-9]* { return text() } JailBody = (Parameter / Comment)* ```
サインインしてこの会話に参加。
ラベルなし
マイルストーンなし
担当者なし
1 人の参加者
期日

期日は未設定です。

依存関係

この課題に依存関係はありません。

読み込み中…
キャンセル
保存
まだ内容がありません