Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Remove "with" as internal token. #329

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3782,7 +3782,7 @@ and parseAtomicTypExpr ~attrs p =
and parsePackageType ~startPos ~attrs p =
let modTypePath = parseModuleLongIdent ~lowercase:true p in
begin match p.Parser.token with
| With ->
| Lident "with" ->
Parser.next p;
let constraints = parsePackageConstraints p in
let loc = mkLoc startPos p.prevEndPos in
Expand Down Expand Up @@ -5769,7 +5769,7 @@ and parseFunctorModuleType p =

and parseWithConstraints moduleType p =
match p.Parser.token with
| With ->
| Lident "with" ->
Parser.next p;
let first = parseWithConstraint p in
let rec loop p acc =
Expand Down
5 changes: 1 addition & 4 deletions src/res_token.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type t =
| Include
| Module
| Of
| With
| Land | Lor
| Band (* Bitwise and: & *)
| BangEqual | BangEqualEqual
Expand Down Expand Up @@ -143,7 +142,6 @@ let toString = function
| Include -> "include"
| Module -> "module"
| Of -> "of"
| With -> "with"
| Lor -> "||"
| Band -> "&" | Land -> "&&"
| BangEqual -> "!=" | BangEqualEqual -> "!=="
Expand Down Expand Up @@ -191,15 +189,14 @@ let keywordTable = function
| "type" -> Typ
| "when" -> When
| "while" -> While
| "with" -> With
| _ -> raise Not_found
[@@raises Not_found]

let isKeyword = function
| And | As | Assert | Constraint | Else | Exception | Export
| External | False | For | If | Import | In | Include | Land | Lazy
| Let | List | Lor | Module | Mutable | Of | Open | Private | Rec
| Switch | True | Try | Typ | When | While | With -> true
| Switch | True | Try | Typ | When | While -> true
| _ -> false

let lookupKeyword str =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ let x = _ident_ident
let x = _ident_ident_
let x = __ident__
let x = list
let x = Foo.Bar.list"
let x = Foo.Bar.list
let with = with"
`;

exports[`if.js 1`] = `
Expand Down
2 changes: 2 additions & 0 deletions tests/parsing/grammar/expressions/ident.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ let x = __ident__

let x = list
let x = Foo.Bar.list

let with = with