質問

I'm trying to pass a nuke script (foundry .nk file) with the following EBNF, but I appear to be catching too much in my 'content' literal. Also I'm pretty sure I'm making some major noob mistakes in my formatting. Anyone able to give me a hand?

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 ""}
 }
}

The current EBNF chokes on the 'views' knobvalue. By removing it from the node, my code works as expected. My complete code is here: http://pastebin.com/z01RWpqW

Thanks

役に立ちましたか?

解決

this is the fixed declaration:

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]*
"""
  1. node may end with \n so this is why you need to append '\n'* to node definition
  2. multiknobgroup definition is not allowed to end with }\n as \n is appended by nodecontent definition (key value \n) and would result in multiknobgroup not to match together with nodecontent
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top