MCPcopy Create free account
hub / github.com/KDE/kdevelop / parse

Function parse

plugins/qmljs/nodejsmodules/idltojs.py:84–152  ·  view source on GitHub ↗
(token)

Source from the content-addressed store, hash-verified

82cl = None
83
84def parse(token):
85 global member_decl, param_decl, params, skip_end_of_line, in_module, in_interface, in_inherit, in_param, cl
86
87 if token in ['in', 'readonly', 'optional', 'attribute', 'getter', 'setter', '{', '}']:
88 pass
89 elif token == 'raises':
90 skip_end_of_line = True
91 elif token == 'module':
92 in_module = True
93 elif token == 'interface':
94 in_module = False
95 in_interface = True
96 elif in_module:
97 # Skip the module declaration
98 pass
99 elif in_interface:
100 # Interface name
101 cl = Class(token)
102 in_interface = False
103
104 if token == 'DOMWindow':
105 # Export window, the only thing that should be exposed to the outside world
106 print('module.exports = DOMWindow;')
107
108 elif token == ';':
109 # End the current declaration
110 if len(member_decl) == 0:
111 # When the end of a class is reached, an empty declaration is produced
112 cl.print()
113 return
114
115 if in_param:
116 # Declare a method
117 cl.member(F(get_type(member_decl), get_name(member_decl), \
118 *[(get_name(p), get_type(p)) for p in params]
119 ))
120 else:
121 # Declare a member variable
122 if get_type(member_decl) is not None and get_name(member_decl)[0].isalpha():
123 cl.member(Var(get_type(member_decl), get_name(member_decl)))
124
125 member_decl.clear()
126 params.clear()
127 skip_end_of_line = False
128 in_param = False
129 elif skip_end_of_line:
130 # Skip everything until the colon
131 pass
132 elif token == ':':
133 in_inherit = True
134 elif in_inherit:
135 cl.prototype(token)
136 in_inherit = False
137 elif token == '(':
138 # Begin the parameter list
139 in_param = True
140 elif token == ')' or token == ',':
141 # End of a parameter

Callers 1

tokenizeFunction · 0.70

Calls 10

printMethod · 0.95
memberMethod · 0.95
prototypeMethod · 0.95
FClass · 0.85
get_typeFunction · 0.85
get_nameFunction · 0.85
VarClass · 0.85
ClassClass · 0.70
clearMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected