Skip to content

Commit

Permalink
renaming arbitrary args 'splats'
Browse files Browse the repository at this point in the history
  • Loading branch information
jtolio committed Jan 15, 2012
1 parent 7ec8525 commit 9af1f90
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
20 changes: 10 additions & 10 deletions src/ast/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def parse_keyword_out_arg(self):
self.advance()
return ast.KeywordOutArgument(expressions, *self.source_ref(checkpoint))

def parse_arbitrary_out_arg(self):
def parse_splat_out_arg(self):
if self.current_char != ":" or self.char(lookahead=1) != "(": return None
checkpoint = self.checkpoint()
self.advance(distance=2)
Expand All @@ -269,7 +269,7 @@ def parse_arbitrary_out_arg(self):
if not expressions:
self.assert_source("list argument expected")
self.advance()
return ast.ArbitraryOutArgument(expressions, *self.source_ref(checkpoint))
return ast.SplatOutArgument(expressions, *self.source_ref(checkpoint))

def parse_named_out_arg(self):
checkpoint = self.checkpoint()
Expand Down Expand Up @@ -309,7 +309,7 @@ def parse_keyword_in_arg(self):
self.advance()
return ast.KeywordInArgument(identifier, *self.source_ref(checkpoint))

def parse_arbitrary_in_arg(self):
def parse_splat_in_arg(self):
if self.current_char != ":" or self.char(lookahead=1) != "(": return None
checkpoint = self.checkpoint()
self.advance(distance=2)
Expand All @@ -321,7 +321,7 @@ def parse_arbitrary_in_arg(self):
if self.current_char != ")":
self.assert_source("unexpected input for list argument")
self.advance()
return ast.ArbitraryInArgument(identifier, *self.source_ref(checkpoint))
return ast.SplatInArgument(identifier, *self.source_ref(checkpoint))

def parse_default_in_arg(self):
checkpoint = self.checkpoint()
Expand All @@ -348,7 +348,7 @@ def parse_required_in_arg(self):
def parse_out_arg(self):
arg = self.parse_keyword_out_arg()
if arg is not None: return arg
arg = self.parse_arbitrary_out_arg()
arg = self.parse_splat_out_arg()
if arg is not None: return arg
arg = self.parse_named_out_arg()
if arg is not None: return arg
Expand All @@ -357,7 +357,7 @@ def parse_out_arg(self):
def parse_in_arg(self):
arg = self.parse_keyword_in_arg()
if arg is not None: return arg
arg = self.parse_arbitrary_in_arg()
arg = self.parse_splat_in_arg()
if arg is not None: return arg
arg = self.parse_default_in_arg()
if arg is not None: return arg
Expand Down Expand Up @@ -388,13 +388,13 @@ def parse_in_arg_list(self):
def check_left_out_args(self, left_args):
for arg in left_args:
if not isinstance(arg, ast.PositionalOutArgument) and \
not isinstance(arg, ast.ArbitraryOutArgument):
not isinstance(arg, ast.SplatOutArgument):
self.assert_source("unexpected argument type", arg.line, arg.col)

def check_left_in_args(self, left_args):
pos = 0
if pos < len(left_args) and isinstance(left_args[pos],
ast.ArbitraryInArgument):
ast.SplatInArgument):
pos += 1
while pos < len(left_args) and isinstance(left_args[pos],
ast.DefaultInArgument):
Expand All @@ -410,7 +410,7 @@ def check_right_out_args(self, right_args):
pos = 0
while pos < len(right_args) and (isinstance(right_args[pos],
ast.PositionalOutArgument) or isinstance(right_args[pos],
ast.ArbitraryOutArgument)):
ast.SplatOutArgument)):
pos += 1
while pos < len(right_args) and isinstance(right_args[pos],
ast.NamedOutArgument):
Expand All @@ -431,7 +431,7 @@ def check_right_in_args(self, right_args):
ast.DefaultInArgument):
pos += 1
if pos < len(right_args) and isinstance(right_args[pos],
ast.ArbitraryInArgument):
ast.SplatInArgument):
pos += 1
if pos < len(right_args) and isinstance(right_args[pos],
ast.KeywordInArgument):
Expand Down
12 changes: 6 additions & 6 deletions src/ast/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"Assignment", "Application", "Assignee", "FieldAssignee",
"VariableAssignee", "IndexAssignee", "Term", "ValueModifier", "OpenCall",
"Index", "Field", "ClosedCall", "InArgument", "OutArgument",
"KeywordInArgument", "KeywordOutArgument", "ArbitraryInArgument",
"ArbitraryOutArgument", "DefaultInArgument", "NamedOutArgument",
"KeywordInArgument", "KeywordOutArgument", "SplatInArgument",
"SplatOutArgument", "DefaultInArgument", "NamedOutArgument",
"RequiredInArgument", "PositionalOutArgument"]

import itertools
Expand Down Expand Up @@ -431,7 +431,7 @@ def __repr__(self):
return "KeywordInArgument(%r, %d, %d)" % (self.identifier, self.line,
self.col)

class ArbitraryOutArgument(OutArgument):
class SplatOutArgument(OutArgument):
__slots__ = ["expressions", "line", "col"]
def __init__(self, expressions, line, col):
self.expressions = expressions
Expand All @@ -442,10 +442,10 @@ def references(self, identifier):
def format(self, indent):
return ":(%s)" % "; ".join(formats(self.expressions, indent))
def __repr__(self):
return "ArbitraryOutArgument(%r, %d, %d)" % (self.expressions, self.line,
return "SplatOutArgument(%r, %d, %d)" % (self.expressions, self.line,
self.col)

class ArbitraryInArgument(InArgument):
class SplatInArgument(InArgument):
__slots__ = ["identifier", "line", "col"]
def __init__(self, identifier, line, col):
self.identifier = identifier
Expand All @@ -455,7 +455,7 @@ def references(self, identifier): return False
def binds(self, identifier): return identifier == self.identifier
def format(self, indent): return ":(%s)" % self.identifier
def __repr__(self):
return "ArbitraryInArgument(%r, %d, %d)" % (self.identifier, self.line,
return "SplatInArgument(%r, %d, %d)" % (self.identifier, self.line,
self.col)

class NamedOutArgument(OutArgument):
Expand Down
8 changes: 4 additions & 4 deletions src/cps/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
__author_email__ = "hello@jtolds.com"
__all__ = ["Identifier", "Field", "Variable", "Integer", "Float", "String",
"OutArgument", "PositionalOutArgument", "NamedOutArgument",
"ArbitraryOutArgument", "KeywordOutArgument", "InArgument",
"RequiredInArgument", "DefaultInArgument", "ArbitraryInArgument",
"SplatOutArgument", "KeywordOutArgument", "InArgument",
"RequiredInArgument", "DefaultInArgument", "SplatInArgument",
"KeywordInArgument", "Expression", "Call", "Assignment", "ObjectMutation",
"Value", "Callable"]

Expand All @@ -52,13 +52,13 @@
OutArgument = ir.OutArgument
PositionalOutArgument = ir.PositionalOutArgument
NamedOutArgument = ir.NamedOutArgument
ArbitraryOutArgument = ir.ArbitraryOutArgument
SplatOutArgument = ir.SplatOutArgument
KeywordOutArgument = ir.KeywordOutArgument

InArgument = ir.InArgument
RequiredInArgument = ir.RequiredInArgument
DefaultInArgument = ir.DefaultInArgument
ArbitraryInArgument = ir.ArbitraryInArgument
SplatInArgument = ir.SplatInArgument
KeywordInArgument = ir.KeywordInArgument

class Expression(object): pass
Expand Down
8 changes: 4 additions & 4 deletions src/ir/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ def translate_out_arg(self, arg):
arg.col), self.convert_application(arg.value), arg.line, arg.col)
obj = self.convert_subexpression(ast.Subexpression(arg.expressions,
arg.line, arg.col))
if isinstance(arg, ast.ArbitraryOutArgument):
return ir.ArbitraryOutArgument(obj, arg.line, arg.col)
if isinstance(arg, ast.SplatOutArgument):
return ir.SplatOutArgument(obj, arg.line, arg.col)
assert isinstance(arg, ast.KeywordOutArgument)
return ir.KeywordOutArgument(obj, arg.line, arg.col)

Expand Down Expand Up @@ -308,8 +308,8 @@ def translate_in_arg(self, arg):
if isinstance(arg, ast.DefaultInArgument):
return ir.DefaultInArgument(ir.Identifier(arg.name, True, arg.line,
arg.col), self.convert_application(arg.value), arg.line, arg.col)
if isinstance(arg, ast.ArbitraryInArgument):
return ir.ArbitraryInArgument(ir.Identifier(arg.identifier, True,
if isinstance(arg, ast.SplatInArgument):
return ir.SplatInArgument(ir.Identifier(arg.identifier, True,
arg.line, arg.col), arg.line, arg.col)
assert isinstance(arg, ast.KeywordInArgument)
return ir.KeywordInArgument(ir.Identifier(arg.identifier, True,
Expand Down
12 changes: 6 additions & 6 deletions src/ir/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
__all__ = ["Identifier", "Expression", "Assignment", "ObjectMutation",
"ReturnValue", "Value", "Field", "Variable", "Integer", "String", "Float",
"Function", "OutArgument", "PositionalOutArgument", "NamedOutArgument",
"ArbitraryOutArgument", "KeywordOutArgument", "InArgument",
"RequiredInArgument", "DefaultInArgument", "ArbitraryInArgument",
"SplatOutArgument", "KeywordOutArgument", "InArgument",
"RequiredInArgument", "DefaultInArgument", "SplatInArgument",
"KeywordInArgument", "Program", "null_val"]

import functools
Expand Down Expand Up @@ -250,7 +250,7 @@ def __repr__(self):
return "NamedOutArgument(%r, %r, %d, %d)" % (self.name, self.value,
self.line, self.col)

class ArbitraryOutArgument(OutArgument):
class SplatOutArgument(OutArgument):
__slots__ = ["value", "line", "col"]
def __init__(self, value, line, col):
self.value = value
Expand All @@ -259,7 +259,7 @@ def __init__(self, value, line, col):
def references(self, identifier): return self.value.references(identifier)
def format(self, indent): return ":(%s)" % self.value.format(indent)
def __repr__(self):
return "ArbitraryOutArgument(%r, %d, %d)" % (self.value, self.line,
return "SplatOutArgument(%r, %d, %d)" % (self.value, self.line,
self.col)

class KeywordOutArgument(OutArgument):
Expand Down Expand Up @@ -303,7 +303,7 @@ def __repr__(self):
return "DefaultInArgument(%r, %r, %d, %d)" % (self.name, self.value,
self.line, self.col)

class ArbitraryInArgument(InArgument):
class SplatInArgument(InArgument):
__slots__ = ["name", "line", "col"]
def __init__(self, name, line, col):
self.name = name
Expand All @@ -313,7 +313,7 @@ def references(self, identifier): return False
def binds(self, identifier): return self.name.references(identifier)
def format(self, indent): return ":(%s)" % self.name.format(indent)
def __repr__(self):
return "ArbitraryInArgument(%r, %d, %d)" % (self.name, self.line, self.col)
return "SplatInArgument(%r, %d, %d)" % (self.name, self.line, self.col)

class KeywordInArgument(InArgument):
__slots__ = ["name", "line", "col"]
Expand Down
14 changes: 7 additions & 7 deletions src/tests/ast_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def testFunctions(self):
"DefaultInArgument('d', Application(["
"Term(Integer(4, 1, 13), [], 1, 13)"
"], 1, 13), 1, 11), "
"ArbitraryInArgument('opt', 1, 15)"
"SplatInArgument('opt', 1, 15)"
"], 1, 1), [], 1, 1)"
"], 1, 1)"
"], 1, 1)")
Expand Down Expand Up @@ -505,7 +505,7 @@ def testFunctions(self):
"Term(Integer(0, 1, 17), [], 1, 17)"
"], 1, 17)"
"], ["
"ArbitraryInArgument('var', 1, 3), "
"SplatInArgument('var', 1, 3), "
"RequiredInArgument('a', 1, 10), "
"RequiredInArgument('b', 1, 12)"
"], [], 1, 1), [], 1, 1)"
Expand All @@ -519,7 +519,7 @@ def testFunctions(self):
"Term(Integer(0, 1, 34), [], 1, 34)"
"], 1, 34)"
"], ["
"ArbitraryInArgument('var', 1, 3), "
"SplatInArgument('var', 1, 3), "
"RequiredInArgument('a', 1, 10), "
"RequiredInArgument('b', 1, 12), "
"RequiredInArgument('d', 1, 14)"
Expand All @@ -532,7 +532,7 @@ def testFunctions(self):
"DefaultInArgument('h', Application(["
"Term(Integer(7, 1, 26), [], 1, 26)"
"], 1, 26), 1, 24), "
"ArbitraryInArgument('j', 1, 28)"
"SplatInArgument('j', 1, 28)"
"], 1, 1), [], 1, 1)"
"], 1, 1)"
"], 1, 1)")
Expand All @@ -544,9 +544,9 @@ def testFunctions(self):
"Term(Integer(0, 1, 14), [], 1, 14)"
"], 1, 14)"
"], ["
"ArbitraryInArgument('a', 1, 3)"
"SplatInArgument('a', 1, 3)"
"], ["
"ArbitraryInArgument('b', 1, 8)"
"SplatInArgument('b', 1, 8)"
"], 1, 1), [], 1, 1)"
"], 1, 1)"
"], 1, 1)")
Expand All @@ -572,7 +572,7 @@ def testListExpansion(self):
"PositionalOutArgument(Application(["
"Term(Variable('thing', 1, 3), [], 1, 3)"
"], 1, 3), 1, 3), "
"ArbitraryOutArgument(["
"SplatOutArgument(["
"Application(["
"Term(Variable('thing', 1, 12), [], 1, 12)"
"], 1, 12)"
Expand Down

0 comments on commit 9af1f90

Please sign in to comment.