This repository has been archived by the owner on Jun 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 204
/
parser_python.mly
146 lines (113 loc) · 4.17 KB
/
parser_python.mly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
%{
(* Yoann Padioleau
*
* Copyright (C) 2010 Facebook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)
(*
* src: http://inst.eecs.berkeley.edu/~cs164/sp10/python-grammar.html
* src: http://docs.python.org/release/2.5.2/ref/grammar.txt
*)
open Common
open Ast_python
%}
/*(*************************************************************************)*/
/*(* tokens *)*/
/*(*************************************************************************)*/
/*(*-----------------------------------------*)*/
/*(* the comment tokens *)*/
/*(*-----------------------------------------*)*/
/*(* coupling: Token_helpers.is_real_comment *)*/
%token <Ast_python.info> TCommentSpace TCommentNewline TComment
%token <Ast_python.info> TCommentMisc
/*(*-----------------------------------------*)*/
/*(* the normal tokens *)*/
/*(*-----------------------------------------*)*/
/*(* tokens with "values" *)*/
%token <string * Ast_python.info> TInt
%token <string * Ast_python.info> TFloat
%token <string * Ast_python.info> TComplex
%token <string * Ast_python.info> TChar
%token <string * Ast_python.info> TString
%token <string * Ast_python.info> TLongString
%token <string * Ast_python.info> TIdent
/*(* keywords tokens *)*/
%token <Ast_python.info>
Tdef Tlambda Tclass
Tif Telse Telif
Twhile Tfor
Treturn
Tyield Tbreak Tcontinue
Ttry Traise Tfinally
Tor Tand Tnot
Tglobal
Tdel Tfrom Tas Twith Tassert Tpass Texcept Timport Tprint Texec Tin Tis
/*(* syntax *)*/
%token <Ast_python.info> TOParen TCParen
%token <Ast_python.info> TOBracket TCBracket
%token <Ast_python.info> TOBrace TCBrace
%token <Ast_python.info> TOAngle TCAngle
%token <Ast_python.info>
TComma
TColon
TBackQuote
TDot
TEllipsis
TStar TStarStar
TEq
TPlus TMinus
TTilde
TSlash TSlashSlash
TPercent
TAnd TOr TXor
TLess TMore TEqEq TMoreEq TLessEq TDiff TNotEq
TAt
%token <string * Ast_python.info>
TAugOp
/*(* operators *)*/
/*(*-----------------------------------------*)*/
/*(* extra tokens: *)*/
/*(*-----------------------------------------*)*/
/*(* classic *)*/
%token <Ast_python.info> TUnknown
%token <Ast_python.info> EOF
/*(*-----------------------------------------*)*/
/*(* priorities *)*/
/*(*-----------------------------------------*)*/
/*(*************************************************************************)*/
/*(* Rules type declaration *)*/
/*(*************************************************************************)*/
%start main
%type <Ast_python.program> main
%%
/*(*************************************************************************)*/
/*(* TOC *)*/
/*(*************************************************************************)*/
/*(*************************************************************************)*/
/*(* Toplevel, compilation units *)*/
/*(*************************************************************************)*/
main: EOF { () }
/*(*************************************************************************)*/
/*(* Names *)*/
/*(*************************************************************************)*/
/*(*************************************************************************)*/
/*(* Expressions *)*/
/*(*************************************************************************)*/
/*(*************************************************************************)*/
/*(* Classes *)*/
/*(*************************************************************************)*/
/*(*************************************************************************)*/
/*(* Misc *)*/
/*(*************************************************************************)*/
/*(*************************************************************************)*/
/*(* xxx_opt, xxx_list *)*/
/*(*************************************************************************)*/