function parse(source) {
    const stream = new Stream(source);
    const tokenizer = new Tokenizer(stream);
    const tokens = tokenStream(tokenizer.parse());

    const ctx = new Context({
      stream: tokens,
      token: tokens.tokens[0],
      lines: stream.lines,
      filename: 'unknown.walt'
    });

    const node = ctx.makeNode({
      value: 'ROOT_NODE'
    }, Syntax.Program);

    // No code, no problem, empty ast equals
    // (module) ; the most basic wasm module
    if (!ctx.stream || !ctx.stream.length) {
      return node;
    }

    while (ctx.stream.peek()) {
      const child = statement(ctx);
      if (child) {
        node.params.push(child);
      }
    }

    return node;
  }
Syntax Analysis

The parser below creates the "bare" Abstract Syntax Tree.