diasbruno / language-js

Parser for es6 and es7.
BSD 3-Clause "New" or "Revised" License
9 stars 1 forks source link

Async arrow functions are not parsed as expected #21

Open ronyhe opened 4 years ago

ronyhe commented 4 years ago

I have a small program that accepts strings from the command line and prints out the js parser's results:

module Main where
import           System.Environment             ( getArgs )
import           Language.JS.Parser             ( parse )
import           Lib

main :: IO ()
main = do
    args <- getArgs
    let text      = unwords args
    let eitherAst = parse "no-file" text
    print eitherAst

When given an arrow function it seems to work correctly:

stack run "() => 4"
Stack has not been tested with GHC versions above 8.6, and using 8.8.2, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
Right [SExp (Arrow (Right []) (SExp (LN "4")))]

However, when adding the async keyword I get an empty list:

stack run "async () => 4"
Stack has not been tested with GHC versions above 8.6, and using 8.8.2, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
Right []
diasbruno commented 4 years ago

@ronyhe This is the implemented edition, ECMAScript® 2015 Language Specification.

Can you please find which edition it implements async?

ronyhe commented 4 years ago

@diasbruno Is the what you mean? https://www.ecma-international.org/ecma-262/10.0/index.html#prod-AsyncArrowFunction

diasbruno commented 4 years ago

Yep. I'm still figuring out what is the best way to write the parser (per edition or something like babel does).