Skip to content

Commit

Permalink
feat(compiler): Allow a newline character after 'as' when aliasing (g…
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer authored Jan 30, 2023
1 parent 752da69 commit 2719034
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
67 changes: 67 additions & 0 deletions compiler/src/parsing/parser.messages
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,73 @@ program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON UIDENT AS YIELD
## The known suffix of the stack is as follows:
## AS
##
program: MODULE UIDENT EOL PROVIDE LBRACE UIDENT AS EOL YIELD
##
## Ends in an error in state: 51.
##
## as_prefix(uid) -> AS option(eols) . uid [ RBRACE EOL COMMA ]
##
## The known suffix of the stack is as follows:
## AS option(eols)
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 6, spurious reduction of production eols -> nonempty_list(eol)
## In state 53, spurious reduction of production option(eols) -> eols
##
program: MODULE UIDENT EOL PROVIDE LBRACE LIDENT AS EOL YIELD
##
## Ends in an error in state: 98.
##
## as_prefix(lid) -> AS option(eols) . lid [ RBRACE EOL COMMA ]
##
## The known suffix of the stack is as follows:
## AS option(eols)
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 6, spurious reduction of production eols -> nonempty_list(eol)
## In state 53, spurious reduction of production option(eols) -> eols
##
program: MODULE UIDENT EOL FOREIGN WASM LIDENT COLON UIDENT AS EOL YIELD
##
## Ends in an error in state: 755.
##
## as_prefix(id_str) -> AS option(eols) . id_str [ FROM ]
##
## The known suffix of the stack is as follows:
## AS option(eols)
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 6, spurious reduction of production eols -> nonempty_list(eol)
## In state 53, spurious reduction of production option(eols) -> eols
##
program: MODULE UIDENT EOL INCLUDE STRING AS EOL YIELD
##
## Ends in an error in state: 823.
##
## include_alias -> AS eols . qualified_uid [ SEMI RBRACE EOL EOF ]
##
## The known suffix of the stack is as follows:
## AS eols
##
## WARNING: This example involves spurious reductions.
## This implies that, although the LR(1) items shown above provide an
## accurate view of the past (what has been recognized so far), they
## may provide an INCOMPLETE view of the future (what was expected next).
## In state 3, spurious reduction of production nonempty_list(eol) -> EOL
## In state 6, spurious reduction of production eols -> nonempty_list(eol)
##

Expected an alias.

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/parsing/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ value_binds:
| lseparated_nonempty_list(comma, value_bind) { $1 }

as_prefix(X):
| AS X {$2}
| AS opt_eols X {$3}

aliasable(X):
| X as_prefix(X)? {($1, $2)}
Expand All @@ -331,7 +331,7 @@ use_stmt:
| FROM qualified_uid USE use_shape { Exp.use ~loc:(to_loc $loc) $2 $4 }

include_alias:
| AS qualified_uid { make_module_alias $2 }
| AS opt_eols qualified_uid { make_module_alias $3 }

include_stmt:
| INCLUDE file_path include_alias? { Inc.mk ~loc:(to_loc $loc) $2 $3 }
Expand Down
2 changes: 2 additions & 0 deletions compiler/test/formatter_inputs/includes.gr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ include "runtime/unsafe/memory"
include "runtime/unsafe/tags"
include "list"
include "option" as Opt
include "option" as
Opt
// TODO(#1627): This comment disappears
include /* special include */ "array"
include "array" as /* special include */ Foo
Expand Down
1 change: 1 addition & 0 deletions compiler/test/formatter_outputs/includes.gr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include "runtime/unsafe/memory"
include "runtime/unsafe/tags"
include "list"
include "option" as Opt
include "option" as Opt
// TODO(#1627): This comment disappears
include "array"
include "array" as Foo
Expand Down

0 comments on commit 2719034

Please sign in to comment.