src/SfpLang.g in sfp-0.3.14 vs src/SfpLang.g in sfp-0.3.15
- old
+ new
@@ -114,10 +114,15 @@
}
('final' { @is_final = true })? attribute_stmt
{
@now['_finals'] << $attribute_stmt.id if @is_final and !$attribute_stmt.id.nil?
}
+ | {
+ @is_final = false
+ @now['_finals'] = [] if !@now.has_key? '_finals'
+ }
+ ('final' { @is_final = true })? object_def NL+
;
attribute_stmt returns [id]
: ID equals_op value NL+
{
@@ -167,12 +172,10 @@
else
raise Exception, "Use isa/isref for any non-primitive type (#{$path.text})."
end
$id = $ID.text
}
- | object_def NL+
- { $id = nil }
;
object_schema
: path('[' NUMBER { @now['_is_array'] = true } ']')?
{
@@ -189,11 +192,14 @@
: 'abstract' object_def
{ @root[$object_def.id]['_context'] = 'abstract' }
;
object_def returns [id]
- : { @use_template = false }
- ID { $id = $ID.text }
+ : ID { $id = $ID.text }
+ {
+ @use_template = false
+ @now['_finals'] << $ID.text if @is_final
+ }
('extends' path
{
template = @root.at?($path.text)
raise Exception, "Object template #{$path.text} is not found!" if
template.is_a?(Sfp::Unknown) or template.is_a?(Sfp::Undefined)