[fix] Cleaning the commented code after CAML grammar

This commit is contained in:
Kirill Andreev 2020-08-19 14:29:44 +04:00
parent 41a49da1e0
commit 5e0cf40ea7
No known key found for this signature in database
GPG Key ID: CF7DA79DE4785A47
2 changed files with 26 additions and 79 deletions

View File

@ -101,6 +101,7 @@ recognise = descent (\_ -> error . show . pp) $ map usingScope
"fun_decl" -> Function <$> flag "recursive" <*> field "name" <*> fields "arg" <*> fieldOpt "type" <*> field "body" "fun_decl" -> Function <$> flag "recursive" <*> field "name" <*> fields "arg" <*> fieldOpt "type" <*> field "body"
"let_decl" -> Const <$> field "name" <*> fieldOpt "type" <*> field "body" "let_decl" -> Const <$> field "name" <*> fieldOpt "type" <*> field "body"
"include" -> Include <$> field "filename" "include" -> Include <$> field "filename"
"type_decl" -> TypeDecl <$> field "name" <*> field "type"
_ -> fallthrough _ -> fallthrough
, Descent do , Descent do
@ -108,13 +109,6 @@ recognise = descent (\_ -> error . show . pp) $ map usingScope
"let_expr1" -> Let <$> field "decl" <*> field "body" "let_expr1" -> Let <$> field "decl" <*> field "body"
_ -> fallthrough _ -> fallthrough
-- -- ReasonExpr
-- , Descent do
-- boilerplate $ \case
-- "bracket_block" -> Block <$> fields "statement" <*> fieldOpt "return"
-- _ -> fallthrough
-- -- Expr -- -- Expr
, Descent do , Descent do
boilerplate $ \case boilerplate $ \case
@ -132,13 +126,6 @@ recognise = descent (\_ -> error . show . pp) $ map usingScope
"annot_expr" -> Annot <$> field "expr" <*> field "type" "annot_expr" -> Annot <$> field "expr" <*> field "type"
"binary_op_app" -> BinOp <$> field "left" <*> field "op" <*> field "right" "binary_op_app" -> BinOp <$> field "left" <*> field "op" <*> field "right"
"unary_op_app" -> UnOp <$> field "negate" <*> field "arg" "unary_op_app" -> UnOp <$> field "negate" <*> field "arg"
-- "lambda_call" -> Apply <$> field "lambda" <*> field "arguments" -- TODO: maybe a separate apply?
-- "arguments" -> Tuple <$> fields "argument"
-- "constructor_call" -> Apply <$> field "constructor" <*> field "parameters"
-- "list_access" -> ListAccess <$> field "name" <*> fields "indexes"
-- "conditional" -> If <$> field "selector" <*> field "then" <*> field "else"
-- "switch_instr" -> Case <$> field "subject" <*> fields "case"
_ -> fallthrough _ -> fallthrough
-- Pattern -- Pattern
@ -165,12 +152,6 @@ recognise = descent (\_ -> error . show . pp) $ map usingScope
"rec_assignment" -> FieldAssignment <$> field "field" <*> field "value" "rec_assignment" -> FieldAssignment <$> field "field" <*> field "value"
_ -> fallthrough _ -> fallthrough
-- -- MapBinding
-- , Descent do
-- boilerplate $ \case
-- "binding" -> MapBinding <$> field "key" <*> field "value"
-- _ -> fallthrough
, Descent do , Descent do
boilerplate' $ \case boilerplate' $ \case
("+", _) -> return $ Op "+" ("+", _) -> return $ Op "+"
@ -192,12 +173,6 @@ recognise = descent (\_ -> error . show . pp) $ map usingScope
("negate", n) -> return $ Op n ("negate", n) -> return $ Op n
_ -> fallthrough _ -> fallthrough
-- , Descent do
-- boilerplate $ \case
-- "module_qualified" -> QualifiedName <$> field "module" <*> fields "method"
-- "struct_qualified" -> QualifiedName <$> field "struct" <*> fields "method"
-- _ -> fallthrough
-- Literal -- Literal
, Descent do , Descent do
boilerplate' $ \case boilerplate' $ \case
@ -208,33 +183,10 @@ recognise = descent (\_ -> error . show . pp) $ map usingScope
("Tez", i) -> return $ Tez i ("Tez", i) -> return $ Tez i
_ -> fallthrough _ -> fallthrough
-- Declaration
, Descent do
boilerplate $ \case
-- TODO: Current `Let` in ast is untyped
-- "let_declaration" -> Var <$> field "binding" <*> fieldOpt "let_type" <*> field "let_value"
"type_decl" -> TypeDecl <$> field "name" <*> field "type"
-- "attr_decl" -> Attribute <$> field "name"
_ -> fallthrough
-- -- Parameters
-- , Descent do
-- boilerplate $ \case
-- "parameters" -> Parameters <$> fields "parameter"
-- _ -> fallthrough
-- -- VarDecl
-- , Descent do
-- boilerplate $ \case
-- "param_decl" -> Decl <$> field "access" <*> field "name" <*> field "type"
-- _ -> fallthrough
-- Name -- Name
, Descent do , Descent do
boilerplate' $ \case boilerplate' $ \case
("Name", n) -> return $ Name n ("Name", n) -> return $ Name n
-- ("and", _) -> return $ Name "and"
-- ("or", _) -> return $ Name "or"
_ -> fallthrough _ -> fallthrough
-- FieldName -- FieldName
@ -277,13 +229,9 @@ recognise = descent (\_ -> error . show . pp) $ map usingScope
boilerplate' $ \case boilerplate' $ \case
("Name_Capital", name) -> return $ Ctor name ("Name_Capital", name) -> return $ Ctor name
("data_con", name) -> return $ Ctor name ("data_con", name) -> return $ Ctor name
-- ("Some", _) -> return $ Ctor "Some"
-- ("None", _) -> return $ Ctor "None"
-- ("Bool", b) -> return $ Ctor b
("False", _) -> return $ Ctor "False" ("False", _) -> return $ Ctor "False"
("True", _) -> return $ Ctor "True" ("True", _) -> return $ Ctor "True"
("Unit", _) -> return $ Ctor "Unit" ("Unit", _) -> return $ Ctor "Unit"
-- ("Nil", _) -> return $ Ctor "Nil"
_ -> fallthrough _ -> fallthrough
-- Err -- Err

View File

@ -174,7 +174,6 @@ recognise = descent (\_ -> error . show . pp) $ map usingScope
, Descent do , Descent do
boilerplate $ \case boilerplate $ \case
"fun_type" -> TArrow <$> field "domain" <*> field "codomain" "fun_type" -> TArrow <$> field "domain" <*> field "codomain"
-- TODO: maybe only one argument of parameter list is considered
"type_application" -> TApply <$> field "functor" <*> fields "parameter" "type_application" -> TApply <$> field "functor" <*> fields "parameter"
"type_tuple" -> TTuple <$> fields "element" "type_tuple" -> TTuple <$> fields "element"
"record_type" -> TRecord <$> fields "field" "record_type" -> TRecord <$> fields "field"