start = methodPattern /* * expression pattern parsing */ expressionPattern = temps? statements* /* * method pattern parsing */ methodPattern = unaryPattern / binaryPattern / keywordPattern unaryPattern = ws key:identifier ws body:methodBody ws { return smalltalk.methodNode({ selector: [key], children: [body] }); } binaryPattern = ws key:binary separator param:identifier ws body:methodBody ws { return smalltalk.methodNode({ selector: [key], params: [smalltalk.valueNode({value: param})], children: [body] }); } keywordPattern = ws pairs:(keywordPair)+ ws body:methodBody ws { var keywords = []; var params = []; for(var i=0;i] { return smalltalk.jsStatementNode({source: source}) } assignment = ws left:reference ws ":=" ws right:statement ws { return smalltalk.assignmentNode({ left: left, right: right }); } cascade = ws send:(keywordSend / binarySend) messages:(ws ";" ws mess:message ws {return mess})+ { var cascade = []; cascade.push(send); for(var i=0;i<,@%~|&-]+ {return bin.join("")} variable = v:identifier {return smalltalk.variableNode({value: v});} global = first:[A-Z] others:[a-zA-Z0-9]* {return first + others.join("")} classRef = ref:global {return smalltalk.classRefNode({value: ref})} reference = variable / classRef keywordPair = key:keyword ws arg:binarySend ws {return {key:key, arg: arg}}