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

Method func

chapter21/src/main/java/com/seaofnodes/simple/Parser.java:1366–1384  ·  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

1364 * </pre>
1365 */
1366 private Node func() {
1367 Ary<Type> ts = new Ary<>(Type.class);
1368 Ary<String> ids = new Ary<>(String.class);
1369 _lexer.skipWhiteSpace();
1370 Lexer loc = loc(); // First argument location
1371 while( true ) {
1372 Type t = type(); // Arg type
1373 if( t==null ) break;
1374 String id = requireId();
1375 ts .push(t ); // Push type/arg pairs
1376 ids.push(id);
1377 match(",");
1378 }
1379 require("->");
1380 // Make a concrete function type, with a fidx
1381 TypeFunPtr tfp = _code.makeFun(TypeTuple.make(ts.asAry()),Type.BOTTOM);
1382 ReturnNode ret = parseFunctionBody(tfp,loc,ids.asAry());
1383 return con(ret._fun.sig());
1384 }
1385
1386 /**
1387 * 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