1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 13:51:44 +03:00

Children without a symbol rule is usually a bug.

This commit is contained in:
Patrick Thomson 2019-09-17 14:19:13 -04:00
parent 02f3f375c3
commit b329d81e12

View File

@ -22,6 +22,7 @@ import qualified Data.Syntax.Expression as Expression
import qualified Data.Syntax.Literal as Literal
import qualified Data.Syntax.Statement as Statement
import qualified Data.Syntax.Type as Type
import Debug.Trace (traceM)
import qualified Data.Term as Term
import Language.Go.Syntax as Go.Syntax hiding (runeLiteral, labelName)
import Language.Go.Type as Go.Type
@ -140,7 +141,9 @@ assignment :: Assignment Term
assignment = handleError program <|> parseError
program :: Assignment Term
program = makeTerm <$> symbol SourceFile <*> children (Statement.Statements <$> manyTerm expression)
program = do
traceM "program"
makeTerm <$> symbol SourceFile <*> children (Statement.Statements <$> manyTerm expression)
expression :: Assignment Term
expression = term (handleError (choice expressionChoices))
@ -404,7 +407,7 @@ expressionCase :: Assignment Term
expressionCase = makeTerm <$> symbol ExpressionCase <*> (Statement.Pattern <$> children expressions <*> expressions)
expressionCaseClause :: Assignment Term
expressionCaseClause = children (expressionCase <|> defaultExpressionCase)
expressionCaseClause = expressionCase <|> defaultExpressionCase
expressionList :: Assignment Term
expressionList = symbol ExpressionList *> children expressions
@ -416,7 +419,9 @@ fallThroughStatement :: Assignment Term
fallThroughStatement = makeTerm <$> symbol FallthroughStatement <*> (Statement.Pattern <$> (makeTerm <$> location <*> (Syntax.Identifier . name <$> source)) <*> emptyTerm)
functionDeclaration :: Assignment Term
functionDeclaration = makeTerm <$> (symbol FunctionDeclaration <|> symbol FuncLiteral) <*> children (mkFunctionDeclaration <$> (term identifier <|> emptyTerm) <*> params <*> returnTypes <*> (term block <|> emptyTerm))
functionDeclaration = do
traceM "function declaration"
makeTerm <$> (symbol FunctionDeclaration <|> symbol FuncLiteral) <*> children (mkFunctionDeclaration <$> (term identifier <|> emptyTerm) <*> params <*> returnTypes <*> (term block <|> emptyTerm))
where
returnTypes = pure <$> (term types <|> term identifier <|> term returnParameters)
<|> pure []