1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 04:51:57 +03:00

Add field declaration mapping

This commit is contained in:
Rick Winfrey 2017-01-11 15:10:12 -08:00
parent f2eacd915c
commit 2bb7ec94ac

View File

@ -43,6 +43,7 @@ termConstructor source sourceSpan name range children _ = case name of
"type_declaration" -> toTypeDecls children
"type_spec" -> toTypeDecl children
"struct_type" -> toStruct children
"field_declaration" -> toFieldDecl children
"expression_switch_statement" ->
case Prologue.break isCaseClause children of
(clauses, cases) -> do
@ -121,7 +122,10 @@ termConstructor source sourceSpan name range children _ = case name of
[ty] -> withCategory Struct (S.Struct (Just ty) [])
[ty, values] -> withCategory Struct (S.Struct (Just ty) (toList $ unwrap values))
rest -> withRanges range Error rest $ S.Error rest
toFieldDecl = \case
[identifier, ty] -> withCategory FieldDecl (S.FieldDecl identifier (Just ty))
[identifier] -> withCategory FieldDecl (S.FieldDecl identifier Nothing)
rest -> withRanges range Error rest $ S.Error rest
toExpression f = \case
[expr] -> f expr