我正在尝试使用以下EBNF传递一个nuke脚本(代工厂.nk文件),但我的'content'字面值似乎过多。另外我很确定我在格式化方面犯了一些重大的菜鸟错误。有人能帮我一把吗?
EBNF:
file := header, content
header := shebang, version
shebang := '#!', ts, word, ('-',[a-zA-Z0-9]+)?,'\n'
version := 'version', ts, [0-9], '.', [0-9], ts, 'v', [0-9], '\n'
content := node*
node := word, ts, '{\n', nodecontent*, '}\n'
nodecontent := ts, knobname, ts, knobvalue, '\n'
knobname := word
knobvalue := word / string / multiknobgroup / knobgroup
knobgroup := '{', (word / string, ts)*, '}'
multiknobgroup := '{\n', (ts, knobgroup, '\n')*, ts, '}\n'
string := '"', word*, '"'
word := ([a-zA-Z0-9-_()/\~.<>?;:])+,ts
ts := [ \t]*
Nukescript:
#! /opt/foundry/Nuke/6.3v7-x64/Nuke6.3 -nx
version 6.3 v7
Root {
inputs 0
name /path/to/file_name.nk
first_frame 0
last_frame 100
lock_range true
format "2048 1556 0 0 2048 1556 1 2K_Super_35(full-ap)"
proxy_type scale
proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)"
addUserKnob {20 custom l Custom}
addUserKnob {1 scene l Scene}
views {
{left ""}
{right ""}
}
}
当前的EBNF在'views'knobvalue上窒息。通过从节点中删除它,我的代码按预期工作。我的完整代码在这里:http://pastebin.com/z01RWpqW
由于
答案 0 :(得分:3)
这是固定的声明:
declaration = """
file := header, content
header := shebang, version
shebang := '#!', ts, word, ('-',[a-zA-Z0-9]+)?,'\n'
version := 'version', ts, [0-9], '.', [0-9], ts, 'v', [0-9], '\n'
content := node*
node := word, ts, '{\n', nodecontent*, ts, '}', '\n'*
nodecontent := ts, knobname, ts, knobvalue, '\n'
knobname := word
knobvalue := word / string / multiknobgroup / knobgroup
knobgroup := '{', (word / string)*, ts, '}'
multiknobgroup := '{\n', (ts, knobgroup, '\n')*, ts, '}'
string := '"', word*, '"'
word := ([a-zA-Z0-9-_()/\~.<>?;:])+,ts
ts := [ \t]*
"""