Class: OpenUSD::Format::Usda::Parser
- Inherits:
-
Object
- Object
- OpenUSD::Format::Usda::Parser
- Defined in:
- lib/openusd/format/usda/parser.rb
Overview
Recursive-descent parser for USDA layers.
Constant Summary collapse
- SPECIFIERS =
Authored prim specifier keywords.
%w[def over class].freeze
- LIST_OPERATIONS =
Recognized list-edit operation keywords.
%w[prepend append delete reorder add explicit].freeze
- QUALIFIERS =
Recognized property qualifiers.
%w[custom uniform varying].freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
-
.parse(source, file: nil) ⇒ Layer
Parse a USDA string.
Instance Method Summary collapse
-
#initialize(source, file: nil) ⇒ Parser
constructor
A new instance of Parser.
-
#parse ⇒ Layer
Parse the configured source.
Constructor Details
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
23 24 25 |
# File 'lib/openusd/format/usda/parser.rb', line 23 def file @file end |
Class Method Details
.parse(source, file: nil) ⇒ Layer
Parse a USDA string.
18 19 20 |
# File 'lib/openusd/format/usda/parser.rb', line 18 def parse(source, file: nil) new(source, file: file).parse end |
Instance Method Details
#parse ⇒ Layer
Parse the configured source.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/openusd/format/usda/parser.rb', line 33 def parse header = expect(:magic, description: "USDA header") error!("unsupported USDA version #{header.value}") unless header.value == "1.0" layer = Layer.new(file) layer..merge!((layer_comment: true)) if symbol?("(") layer.add_root_prim(parse_prim) until current.type == :eof layer rescue OpenUSD::PathError, OpenUSD::TypeError => e error!(e.) end |