Skip to content

文法定义

许兴逸 edited this page Jul 22, 2022 · 11 revisions

基本

  • 符号
symbol = ('a'..'z' | 'A'..'Z' | '_' | '.') | { 'a'..'z' | 'A'..'Z' | '_' | '.' | '0'..'9' }
  • 字符串
char = (any - '\n' - '"' - '\') | '\' ('n' | 't' | '\' | 'r' | '"' | "'")
string = '"' { char } '"'
  • 整数
integerDec = ['-'] { '0'..'9' }
integerHex = ['-'] '0x' { '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' }
integer = integerHex | integerDec
  • 实数
number = ['-'] integer '.' integer
  • 常量
constant = number | integer | symbol | string

顶级定义

  • 形式参数
stringFormat = '$' string
commandArg = constant | stringFormat
parameter = symbol ['='] commandArg
parameters = parameter {',' parameter}
  • 顶级定义
top_levels_extern = 'extern ' symbol parameters
top_levels = '-' ( top_levels_extern | 'macro ' symbol parameters | 'scene ' string [ ' inherit ' string ])

语句

command_call = symbol { ' ' commandArg } { ' --' symbol [commandArg] }
statement = '@' command_call

文本

text_str = { any - '\n' - '[' - '<' - ']' - '>' - '#' - '\' - '\r' }
char_str = { text_str - ':' }
text_command_call = '[' command_call ']'
text_mark_block = '<' symbol ' ' text '>'
text_slice = text_str | text_command_call | text_mark_block
text = [char_str] [':'] { text_slice }

line_comment = '#' { any - '\n' }
line_end = '\n'
line = [ top_levels | text | statement ] [ line_comment ] line_end

DOM

line_top_levels = top_levels [ line_comment ] line_end
line_text = text [ line_comment ] line_end
line_statement = statement [ line_comment ] line_end

dom = { line_top_levels - ('-' top_levels_extern) { line_statement | line_text } | top_levels_extern } EOF
Clone this wiki locally