Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

* lang_python/parsing/parser_python.mly: adding attribute in AST #15

Merged
merged 1 commit into from
Feb 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions lang_python/parsing/parser_python.mly
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* old src:
* - http://inst.eecs.berkeley.edu/~cs164/sp10/python-grammar.html
*)
open Common
open Ast_python

(* intermediate helper type *)
Expand Down Expand Up @@ -489,11 +490,22 @@ compound_stmt:
*)*/
| async_stmt { $1 }

/*(* TODO: add attributes *)*/
decorated:
| decorators classdef { $2 }
| decorators funcdef { $2 }
| decorators async_funcdef { $2 }
| decorators classdef {
match $2 with
| ClassDef (a, b, c, d) -> ClassDef (a, b, c, $1 @ d)
| _ -> raise Impossible
}
| decorators funcdef {
match $2 with
| FunctionDef (a, b, c, d, e) -> FunctionDef (a, b, c, d, $1 @ e)
| _ -> raise Impossible
}
| decorators async_funcdef {
match $2 with
| FunctionDef (a, b, c, d, e) -> FunctionDef (a, b, c, d, $1 @ e)
| _ -> raise Impossible
}

/*(* this is always preceded by a COLON *)*/
suite:
Expand Down