Skip to content
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ formatTest/customMLFiles/*.ml
formatTest/customMLFormatOutput.re
.jenga
src/reason_parser.messages.bak
*~
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Portions Copyright (c) 2015-present, Facebook, Inc. All rights reserved.

SHELL=/bin/bash -o pipefail
SHELL=bash -o pipefail

default: build test

Expand Down Expand Up @@ -33,12 +33,12 @@ clean:

# Compile error messages into ml file, checks if the error messages are complete and not redundent
compile_error: update_error
menhir --strict --unused-tokens src/reason_parser.mly --compile-errors src/reason_parser.messages > src/reason_parser_message.ml
menhir --explain --strict --unused-tokens src/reason_parser.mly --compile-errors src/reason_parser.messages > src/reason_parser_message.ml

# Update error messages based on new grammar
update_error:
@ cp -f src/reason_parser.messages src/reason_parser.messages.bak
@ if ! menhir --strict --unused-tokens src/reason_parser.mly --update-errors src/reason_parser.messages.bak | sed -e 's/[[:space:]]*$$//g' > src/reason_parser.messages ; then \
@ if ! menhir --explain --strict --unused-tokens src/reason_parser.mly --update-errors src/reason_parser.messages.bak | sed -e 's/[[:space:]]*$$//g' > src/reason_parser.messages ; then \
cp src/reason_parser.messages.bak src/reason_parser.messages ; \
exit 1 ; \
fi
Expand Down
6 changes: 6 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ocaml/opam:debian
RUN sudo -u opam sh -c "opam depext -u merlin utop"
RUN opam remote add main https://opam.ocaml.org && \
opam pin add -y merlin https://github.com/the-lambda-church/merlin.git#reason-0.0.1 && \
opam pin add -y merlin_extend https://github.com/let-def/merlin-extend.git#reason-0.0.1 && \
opam pin add -y reason https://github.com/facebook/reason.git#0.0.6
41 changes: 41 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Dockerfile for Reason

A Docker file for Reason development.

## Build

* Ensure that you have docker [installed](https://docs.docker.com/engine/installation/).
* Build the image: `docker build -t reason .`

All set!

## Running

### Reason interactive top-level

Start the Reason interactive top-level with:

$ docker run -it reason rtop

### Build native apps

Assuming that you have a reason project directory called `hello_reason` with a
single file `hello.re`:

```
$ cat hello.re
print_string "Hello, Reason!\n"
```

To build the `hello` native app:

$ cd hello_reason
$ docker run -it -v `pwd`:/src reason
$ cd /src
$ rebuild hello.native
$ ./hello.native
Hello, Reason!

You can further edit your source file from the host machine and rebuild the
native app from your docker container. The build artifacts are found in your
host machines `hello_reason` directory.
182 changes: 182 additions & 0 deletions formatTest/unit_tests/expected_output/comments.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/*
* Multiline comment
*/
// Empty comments, or comments with whitespaces:
//
//
//
//a
/*inlinecommentwithnospaces*/
/*


*/
/*
* Multiline comment with a // single line comment
*/
// Single line comment

let testPostComment = "";

// let commentedCode = "";
// Test: inter-code comments
let testMultiline a =>
switch a {
// single line comment
| `Thingy x =>
print_string
/* multiline comment should be fine */
"matched thingy x";
let zz = 10;
// post line single line comment
zz
| `Other x =>
// single line comment above
print_string "matched other x";
x
}
// single line comment below;

/* short comment */
let x = ["test"];

/* short comment */
let x = {
// /* */
let y = "";
()
};

// /* this is a valid nested comment*/ this is a valid comment
// valid /* this is also a valid nested comment */
let z = 10;

///////////////////////////////////////////////////////////////////////////////////
// The following tests will test the conversion of /* */ to single line
// comments as well as the wrapping of interleaved comments within short sequences.
///////////////////////////////////////////////////////////////////////////////////
/*
* Test wrapping every form of named arguments where various parts are
* commented.
*/
let a = 10;

let b = 20;

/*A*/
let named /* a::a */ a::a /* b::b */ b::b =>
/* a + b */
a + b;

/*B*/
let namedAlias
/* a::aa */
a::aa
/* b::bb */
b::bb =>
/* aa + bb */
aa + bb;

/*C*/
let namedAnnot
/* a::(a: option int) */
a::(a: option int)
/* b::(b: option int) */
b::(b: option int) =>
/* 20 */
20;

/*D*/
let namedAliasAnnot
/* a::(aa: option int) */
a::(aa: option int)
/* b::(bb: option int) */
b::(bb: option int) =>
/* 20 */
20;

/*E*/
let optional
/* a::a=? */
a::a=?
/* b::b=? */
b::b=?
/* () */
() =>
/* 10 */
10;

/*F*/
let optionalAlias
/* a::aa */
a::aa=?
/* ?b:bb */
b::bb=?
/* () */
() =>
/* 10 */
10;

/*G*/
let optionalAnnot
/* a::(a: option int)=? */
a::(a: option int)=?
/* ?b:(b: option int) */
b::(b: option int)=?
/* () */
() =>
/* 10 */
10;

/*H*/
let optionalAliasAnnot
/* a::(aa: option int)=? */
a::(aa: option int)=?
/* b::(bb: option int)=? */
b::(bb: option int)=?
/* () => */
() =>
/* 10 */
10;

/*I: This one is really annoying? Where's the visual label?*/
let defOptional
/* a::a=10 */
a::a=10
/* b::b=10 */
b::b=10
/* () => */
() =>
/* 10 */
10;

/*J*/
let defOptionalAlias
/* a::aa=10 */
a::aa=10
/* b::bb=10 */
b::bb=10
/* () => */
() =>
/* 10; */
10;

/*K*/
let defOptionalAnnot
/* a::(a:int)=10 */
a::(a: int)=10
/* b::(b:int)=10 */
b::(b: int)=10
/* () => */
() =>
/* 10; */
10;

// This tests a short inline comment that should retain it's inline properties when formatted
let x = [/* sh */ "te"];

// This tests an empty /* */ nested comment
// This tests a line comment that should be converted to an inline comment when formatted
let x = [/* sh*/ "te"];

// File ends with a comment
Loading