MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / func

Method func

chapter19/src/main/java/com/seaofnodes/simple/Parser.java:1346–1364  ·  view source on GitHub ↗

Parse a function body; the caller will parse the surrounding "{}" { [type arg,] -> expr } { expr } // The no-argument function

()

Source from the content-addressed store, hash-verified

1344 * </pre>
1345 */
1346 private Node func() {
1347 Ary<Type> ts = new Ary<>(Type.class);
1348 Ary<String> ids = new Ary<>(String.class);
1349 _lexer.skipWhiteSpace();
1350 Lexer loc = loc(); // First argument location
1351 while( true ) {
1352 Type t = type(); // Arg type
1353 if( t==null ) break;
1354 String id = requireId();
1355 ts .push(t ); // Push type/arg pairs
1356 ids.push(id);
1357 match(",");
1358 }
1359 require("->");
1360 // Make a concrete function type, with a fidx
1361 TypeFunPtr tfp = _code.makeFun(TypeTuple.make(ts.asAry()),Type.BOTTOM);
1362 ReturnNode ret = parseFunctionBody(tfp,loc,ids.asAry());
1363 return con(ret._fun.sig());
1364 }
1365
1366 /**
1367 * Parse function call arguments; caller will parse the surrounding "()"

Callers 1

parsePrimaryMethod · 0.95

Calls 13

locMethod · 0.95
typeMethod · 0.95
requireIdMethod · 0.95
pushMethod · 0.95
matchMethod · 0.95
requireMethod · 0.95
makeMethod · 0.95
asAryMethod · 0.95
parseFunctionBodyMethod · 0.95
conMethod · 0.95
skipWhiteSpaceMethod · 0.45
makeFunMethod · 0.45

Tested by

no test coverage detected