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

Commit

Permalink
Merge pull request #15 from returntocorp/python_attributes
Browse files Browse the repository at this point in the history
* lang_python/parsing/parser_python.mly: adding attribute in AST
  • Loading branch information
Yoann Padioleau authored Feb 3, 2020
2 parents 4d20941 + 62fbeb4 commit 22eea45
Showing 1 changed file with 16 additions and 4 deletions.
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

0 comments on commit 22eea45

Please sign in to comment.