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

오픈
sadaszewski13 년 전을 오픈 · 0개의 코멘트
sadaszewski1 코멘트됨, 3 년 전

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명
마감일

마감일이 설정되지 않았습니다.

의존성

이 이슈는 어떠한 의존성도 가지지 않습니다.

불러오는 중...
취소
저장
아직 콘텐츠가 없습니다.