mirror of https://github.com/Wilfred/difftastic/
Use tree-sitter-ocaml from crates.io
parent
c8818dd4be
commit
de6e6707d2
@ -1 +0,0 @@
|
||||
../tree-sitter-ocaml/queries/highlights.scm
|
||||
@ -1 +0,0 @@
|
||||
../tree-sitter-ocaml/common
|
||||
@ -1 +0,0 @@
|
||||
../tree-sitter-ocaml/interface
|
||||
@ -1 +0,0 @@
|
||||
../tree-sitter-ocaml/ocaml
|
||||
@ -1,3 +0,0 @@
|
||||
ocaml/src/parser.c linguist-vendored
|
||||
interface/src/parser.c linguist-vendored
|
||||
/examples/** linguist-vendored
|
||||
@ -1,56 +0,0 @@
|
||||
name: build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_INCREMENTAL: 0
|
||||
|
||||
jobs:
|
||||
build-node:
|
||||
name: build-node
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2-beta
|
||||
with:
|
||||
node-version: '12'
|
||||
|
||||
- name: Display Node versions
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Cache examples
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: examples
|
||||
key: ${{ hashFiles('script/parse-examples') }}
|
||||
|
||||
- name: Test corpus & parse examples
|
||||
run: npm test
|
||||
|
||||
build-rust:
|
||||
name: build-rust
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
- name: Test
|
||||
run: cargo test
|
||||
@ -1,29 +0,0 @@
|
||||
name: publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_INCREMENTAL: 0
|
||||
|
||||
jobs:
|
||||
crate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Publish crate
|
||||
uses: katyo/publish-crates@v1
|
||||
with:
|
||||
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
@ -1,19 +0,0 @@
|
||||
package-lock.json
|
||||
node_modules
|
||||
build
|
||||
examples
|
||||
*.log
|
||||
log.html
|
||||
/test.ml
|
||||
/test.mli
|
||||
target
|
||||
Cargo.lock
|
||||
|
||||
# These files would be generated by 'tree-sitter generate' with the default
|
||||
# settings. We don't want them because there's already a copy at the root.
|
||||
/interface/Cargo.toml
|
||||
/interface/binding.gyp
|
||||
/interface/bindings
|
||||
/ocaml/Cargo.toml
|
||||
/ocaml/binding.gyp
|
||||
/ocaml/bindings
|
||||
@ -1,31 +0,0 @@
|
||||
[package]
|
||||
name = "tree-sitter-ocaml"
|
||||
description = "OCaml grammar for the tree-sitter parsing library"
|
||||
version = "0.20.1"
|
||||
authors = ["Max Brunsfeld <maxbrunsfeld@gmail.com>"]
|
||||
license = "MIT"
|
||||
readme = "bindings/rust/README.md"
|
||||
keywords = ["incremental", "parsing", "ocaml"]
|
||||
categories = ["parsing", "text-editors"]
|
||||
repository = "https://github.com/tree-sitter/tree-sitter-ocaml"
|
||||
edition = "2018"
|
||||
|
||||
build = "bindings/rust/build.rs"
|
||||
include = [
|
||||
"common/*",
|
||||
"bindings/rust/*",
|
||||
"ocaml/grammar.js",
|
||||
"ocaml/src/*",
|
||||
"interface/grammar.js",
|
||||
"interface/src/*",
|
||||
"queries/*"
|
||||
]
|
||||
|
||||
[lib]
|
||||
path = "bindings/rust/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
tree-sitter = "0.20"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Max Brunsfeld and Pieter Goetschalckx
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@ -1,19 +0,0 @@
|
||||
tree-sitter-ocaml
|
||||
=================
|
||||
|
||||
[](https://github.com/tree-sitter/tree-sitter-ocaml/actions?query=workflow%3Abuild)
|
||||
|
||||
OCaml grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
|
||||
|
||||
This module defines two grammars for implementation (`.ml`) and interface (`.mli`) files. Require them as follows:
|
||||
|
||||
```js
|
||||
require('tree-sitter-ocaml').ocaml;
|
||||
require('tree-sitter-ocaml').interface;
|
||||
```
|
||||
|
||||
References
|
||||
|
||||
* [OCaml language reference](https://ocaml.org/manual/language.html)
|
||||
* [OCaml language extensions](https://ocaml.org/manual/extn.html)
|
||||
* [OCaml parser](https://github.com/ocaml/ocaml/blob/trunk/parsing/parser.mly)
|
||||
@ -1,21 +0,0 @@
|
||||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "tree_sitter_ocaml_binding",
|
||||
"include_dirs": [
|
||||
"<!(node -e \"require('nan')\")",
|
||||
"ocaml/src"
|
||||
],
|
||||
"sources": [
|
||||
"ocaml/src/parser.c",
|
||||
"ocaml/src/scanner.cc",
|
||||
"interface/src/parser.c",
|
||||
"interface/src/scanner.cc",
|
||||
"bindings/node/binding.cc"
|
||||
],
|
||||
"cflags_c": [
|
||||
"-std=c99",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
#include "tree_sitter/parser.h"
|
||||
#include <node.h>
|
||||
#include "nan.h"
|
||||
|
||||
using namespace v8;
|
||||
|
||||
extern "C" TSLanguage * tree_sitter_ocaml();
|
||||
extern "C" TSLanguage * tree_sitter_ocaml_interface();
|
||||
|
||||
namespace {
|
||||
|
||||
NAN_METHOD(New) {}
|
||||
|
||||
void Init(Local<Object> exports, Local<Object> module) {
|
||||
Local<FunctionTemplate> ocaml_tpl = Nan::New<FunctionTemplate>(New);
|
||||
ocaml_tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
||||
ocaml_tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
Local<Function> ocaml_constructor = Nan::GetFunction(ocaml_tpl).ToLocalChecked();
|
||||
Local<Object> ocaml_instance = ocaml_constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
||||
Nan::SetInternalFieldPointer(ocaml_instance, 0, tree_sitter_ocaml());
|
||||
Nan::Set(ocaml_instance, Nan::New("name").ToLocalChecked(), Nan::New("ocaml").ToLocalChecked());
|
||||
|
||||
Local<FunctionTemplate> iface_tpl = Nan::New<FunctionTemplate>(New);
|
||||
iface_tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
||||
iface_tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
Local<Function> iface_constructor = Nan::GetFunction(iface_tpl).ToLocalChecked();
|
||||
Local<Object> iface_instance = iface_constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
||||
Nan::SetInternalFieldPointer(iface_instance, 0, tree_sitter_ocaml_interface());
|
||||
Nan::Set(iface_instance, Nan::New("name").ToLocalChecked(), Nan::New("ocaml_interface").ToLocalChecked());
|
||||
|
||||
Nan::Set(exports, Nan::New("ocaml").ToLocalChecked(), ocaml_instance);
|
||||
Nan::Set(exports, Nan::New("interface").ToLocalChecked(), iface_instance);
|
||||
}
|
||||
|
||||
NODE_MODULE(tree_sitter_ocaml_binding, Init)
|
||||
|
||||
} // namespace
|
||||
@ -1,20 +0,0 @@
|
||||
try {
|
||||
module.exports = require("../../build/Release/tree_sitter_ocaml_binding");
|
||||
} catch (error1) {
|
||||
if (error1.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error1;
|
||||
}
|
||||
try {
|
||||
module.exports = require("../../build/Debug/tree_sitter_ocaml_binding");
|
||||
} catch (error2) {
|
||||
if (error2.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error2;
|
||||
}
|
||||
throw error1
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
module.exports.ocaml.nodeTypeInfo = require("../../ocaml/src/node-types.json");
|
||||
module.exports.interface.nodeTypeInfo = require("../../interface/src/node-types.json");
|
||||
} catch (_) {}
|
||||
@ -1 +0,0 @@
|
||||
module.exports = require('./index').interface;
|
||||
@ -1 +0,0 @@
|
||||
module.exports = require('./index').ocaml;
|
||||
@ -1,42 +0,0 @@
|
||||
# tree-sitter-ocaml
|
||||
|
||||
This crate provides Ocaml grammars for the [tree-sitter][] parsing library.
|
||||
There are separate grammars for implementation (`.ml`) and interface (`.mli`)
|
||||
files.
|
||||
|
||||
To use this crate, add it to the `[dependencies]` section of your `Cargo.toml`
|
||||
file. (Note that you will probably also need to depend on the
|
||||
[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful
|
||||
way.)
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
tree-sitter = "0.20"
|
||||
tree-sitter-ocaml = "0.20"
|
||||
```
|
||||
|
||||
Typically, you will use the [language][language func] function to add this
|
||||
grammar to a tree-sitter [Parser][], and then use the parser to parse some code:
|
||||
|
||||
```rust
|
||||
let code = r#"
|
||||
module M = struct
|
||||
let x = 0
|
||||
end
|
||||
"#;
|
||||
let mut parser = Parser::new();
|
||||
parser
|
||||
.set_language(tree_sitter_ocaml::language_ocaml())
|
||||
.expect("Error loading OCaml grammar");
|
||||
let tree = parser.parse(code, None).unwrap();
|
||||
```
|
||||
|
||||
If you have any questions, please reach out to us in the [tree-sitter
|
||||
discussions] page.
|
||||
|
||||
[Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||
[language func]: https://docs.rs/tree-sitter-rust/*/tree_sitter_ocaml/fn.language_ocaml.html
|
||||
[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
||||
[tree-sitter]: https://tree-sitter.github.io/
|
||||
[tree-sitter crate]: https://crates.io/crates/tree-sitter
|
||||
[tree-sitter discussions]: https://github.com/tree-sitter/tree-sitter/discussions
|
||||
@ -1,31 +0,0 @@
|
||||
fn main() {
|
||||
let root_dir = std::path::Path::new(".");
|
||||
let ocaml_dir = root_dir.join("ocaml").join("src");
|
||||
let interface_dir = root_dir.join("interface").join("src");
|
||||
|
||||
let mut c_config = cc::Build::new();
|
||||
c_config.include(&ocaml_dir);
|
||||
c_config
|
||||
.flag_if_supported("-Wno-unused-parameter")
|
||||
.flag_if_supported("-Wno-unused-but-set-variable")
|
||||
.flag_if_supported("-Wno-trigraphs");
|
||||
|
||||
let mut cpp_config = cc::Build::new();
|
||||
cpp_config.cpp(true);
|
||||
cpp_config.include(&ocaml_dir);
|
||||
cpp_config
|
||||
.flag_if_supported("-Wno-unused-parameter")
|
||||
.flag_if_supported("-Wno-unused-but-set-variable");
|
||||
|
||||
for dir in &[ocaml_dir, interface_dir] {
|
||||
let parser_path = dir.join("parser.c");
|
||||
let scanner_path = dir.join("scanner.cc");
|
||||
c_config.file(&parser_path);
|
||||
cpp_config.file(&scanner_path);
|
||||
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
||||
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||
}
|
||||
|
||||
c_config.compile("parser");
|
||||
cpp_config.compile("scanner");
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
//! This crate provides OCaml grammars for the [tree-sitter][] parsing library.
|
||||
//! There are separate grammars for implementation (`.ml`) and interface
|
||||
//! (`.mli`) files.
|
||||
//!
|
||||
//! Typically, you will use the [language_ocaml][language func] function to add
|
||||
//! this grammar to a tree-sitter [Parser][], and then use the parser to parse
|
||||
//! some code:
|
||||
//!
|
||||
//! ```
|
||||
//! let code = r#"
|
||||
//! module M = struct
|
||||
//! let x = 0
|
||||
//! end
|
||||
//! "#;
|
||||
//! let mut parser = tree_sitter::Parser::new();
|
||||
//! parser
|
||||
//! .set_language(tree_sitter_ocaml::language_ocaml())
|
||||
//! .expect("Error loading OCaml grammar");
|
||||
//! let tree = parser.parse(code, None).unwrap();
|
||||
//! ```
|
||||
//!
|
||||
//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||
//! [language func]: fn.language_ocaml.html
|
||||
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
||||
//! [tree-sitter]: https://tree-sitter.github.io/
|
||||
|
||||
use tree_sitter::Language;
|
||||
|
||||
extern "C" {
|
||||
fn tree_sitter_ocaml() -> Language;
|
||||
fn tree_sitter_ocaml_interface() -> Language;
|
||||
}
|
||||
|
||||
/// Get the tree-sitter [Language][] for OCaml.
|
||||
///
|
||||
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||
pub fn language_ocaml() -> Language {
|
||||
unsafe { tree_sitter_ocaml() }
|
||||
}
|
||||
|
||||
/// Get the tree-sitter [Language][] for OCaml interfaces.
|
||||
///
|
||||
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||
pub fn language_ocaml_interface() -> Language {
|
||||
unsafe { tree_sitter_ocaml_interface() }
|
||||
}
|
||||
|
||||
/// The content of the [`node-types.json`][] file for OCaml.
|
||||
///
|
||||
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
||||
pub const OCAML_NODE_TYPES: &'static str = include_str!("../../ocaml/src/node-types.json");
|
||||
|
||||
/// The content of the [`node-types.json`][] file for OCaml interfaces.
|
||||
///
|
||||
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
||||
pub const INTERFACE_NODE_TYPES: &'static str = include_str!("../../interface/src/node-types.json");
|
||||
|
||||
/// The syntax highlighting query for OCaml.
|
||||
pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
||||
|
||||
/// The local-variable syntax highlighting query for OCaml.
|
||||
pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
||||
|
||||
/// The symbol tagging query for OCaml.
|
||||
pub const TAGGING_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn test_ocaml() {
|
||||
let mut parser = tree_sitter::Parser::new();
|
||||
parser
|
||||
.set_language(super::language_ocaml())
|
||||
.expect("Error loading OCaml grammar");
|
||||
|
||||
let code = r#"
|
||||
module M = struct
|
||||
let x = 0
|
||||
end
|
||||
"#;
|
||||
|
||||
let tree = parser.parse(code, None).unwrap();
|
||||
let root = tree.root_node();
|
||||
assert!(!root.has_error());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ocaml_interface() {
|
||||
let mut parser = tree_sitter::Parser::new();
|
||||
parser
|
||||
.set_language(super::language_ocaml_interface())
|
||||
.expect("Error loading OCaml interface grammar");
|
||||
|
||||
let code = r#"
|
||||
module M : sig
|
||||
val x : int
|
||||
end
|
||||
"#;
|
||||
|
||||
let tree = parser.parse(code, None).unwrap();
|
||||
let root = tree.root_node();
|
||||
assert!(!root.has_error());
|
||||
}
|
||||
}
|
||||
@ -1,294 +0,0 @@
|
||||
#include <tree_sitter/parser.h>
|
||||
#include <string>
|
||||
#include <wctype.h>
|
||||
|
||||
namespace {
|
||||
|
||||
enum {
|
||||
COMMENT,
|
||||
LEFT_QUOTED_STRING_DELIM,
|
||||
RIGHT_QUOTED_STRING_DELIM,
|
||||
STRING_DELIM,
|
||||
LINE_NUMBER_DIRECTIVE,
|
||||
NULL_CHARACTER
|
||||
};
|
||||
|
||||
struct Scanner {
|
||||
bool in_string = false;
|
||||
std::string quoted_string_id;
|
||||
|
||||
unsigned serialize(char *buffer) {
|
||||
size_t size = quoted_string_id.size();
|
||||
|
||||
buffer[0] = in_string;
|
||||
quoted_string_id.copy(&buffer[1], size);
|
||||
return size + 1;
|
||||
}
|
||||
|
||||
void deserialize(const char *buffer, unsigned length) {
|
||||
if (length > 0) {
|
||||
in_string = buffer[0];
|
||||
quoted_string_id.assign(&buffer[1], length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void advance(TSLexer *lexer) {
|
||||
lexer->advance(lexer, false);
|
||||
}
|
||||
|
||||
void skip(TSLexer *lexer) {
|
||||
lexer->advance(lexer, true);
|
||||
}
|
||||
|
||||
bool scan(TSLexer *lexer, const bool *valid_symbols) {
|
||||
if (valid_symbols[LEFT_QUOTED_STRING_DELIM] && (iswlower(lexer->lookahead) || lexer->lookahead == '_' || lexer->lookahead == '|')) {
|
||||
lexer->result_symbol = LEFT_QUOTED_STRING_DELIM;
|
||||
return scan_left_quoted_string_delimiter(lexer);
|
||||
} else if (valid_symbols[RIGHT_QUOTED_STRING_DELIM] && (lexer->lookahead == '|')) {
|
||||
advance(lexer);
|
||||
lexer->result_symbol = RIGHT_QUOTED_STRING_DELIM;
|
||||
return scan_right_quoted_string_delimiter(lexer);
|
||||
} else if (in_string && valid_symbols[STRING_DELIM] && lexer->lookahead == '"') {
|
||||
advance(lexer);
|
||||
in_string = false;
|
||||
lexer->result_symbol = STRING_DELIM;
|
||||
return true;
|
||||
}
|
||||
|
||||
while (iswspace(lexer->lookahead)) {
|
||||
skip(lexer);
|
||||
}
|
||||
|
||||
if (!in_string && lexer->lookahead == '#' && lexer->get_column(lexer) == 0) {
|
||||
advance(lexer);
|
||||
|
||||
while (lexer->lookahead == ' ' || lexer->lookahead == '\t') advance(lexer);
|
||||
|
||||
if (!iswdigit(lexer->lookahead)) return false;
|
||||
while (iswdigit(lexer->lookahead)) advance(lexer);
|
||||
|
||||
while (lexer->lookahead == ' ' || lexer->lookahead == '\t') advance(lexer);
|
||||
|
||||
if (lexer->lookahead != '"') return false;
|
||||
while (lexer->lookahead != '\n' && lexer->lookahead != '\r' && lexer->lookahead != '"') advance(lexer);
|
||||
if (lexer->lookahead != '"') return false;
|
||||
|
||||
while (lexer->lookahead != '\n' && lexer->lookahead != '\r') advance(lexer);
|
||||
|
||||
lexer->result_symbol = LINE_NUMBER_DIRECTIVE;
|
||||
return true;
|
||||
} else if (!in_string && lexer->lookahead == '(') {
|
||||
advance(lexer);
|
||||
lexer->result_symbol = COMMENT;
|
||||
return scan_comment(lexer);
|
||||
} else if (!in_string && valid_symbols[STRING_DELIM] && lexer->lookahead == '"') {
|
||||
advance(lexer);
|
||||
in_string = true;
|
||||
lexer->result_symbol = STRING_DELIM;
|
||||
return true;
|
||||
} else if (valid_symbols[NULL_CHARACTER] && lexer->lookahead == '\0') {
|
||||
return !lexer->eof(lexer);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void scan_string(TSLexer *lexer) {
|
||||
for (;;) {
|
||||
switch (lexer->lookahead) {
|
||||
case '\\':
|
||||
advance(lexer);
|
||||
advance(lexer);
|
||||
break;
|
||||
case '"':
|
||||
advance(lexer);
|
||||
return;
|
||||
case '\0':
|
||||
if (lexer->eof(lexer)) return;
|
||||
advance(lexer);
|
||||
break;
|
||||
default:
|
||||
advance(lexer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char scan_character(TSLexer *lexer) {
|
||||
char last = 0;
|
||||
|
||||
switch (lexer->lookahead) {
|
||||
case '\\':
|
||||
advance(lexer);
|
||||
if (iswdigit(lexer->lookahead)) {
|
||||
advance(lexer);
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
if (!iswdigit(lexer->lookahead)) return 0;
|
||||
advance(lexer);
|
||||
}
|
||||
} else {
|
||||
switch (lexer->lookahead) {
|
||||
case 'x':
|
||||
advance(lexer);
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
if (!iswdigit(lexer->lookahead) && (towupper(lexer->lookahead) < 'A' || towupper(lexer->lookahead) > 'F')) return 0;
|
||||
advance(lexer);
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
advance(lexer);
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
if (!iswdigit(lexer->lookahead) || lexer->lookahead > '7') return 0;
|
||||
advance(lexer);
|
||||
}
|
||||
break;
|
||||
case '\'':
|
||||
case '"':
|
||||
case '\\':
|
||||
case 'n':
|
||||
case 't':
|
||||
case 'b':
|
||||
case 'r':
|
||||
case ' ':
|
||||
last = lexer->lookahead;
|
||||
advance(lexer);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '\'':
|
||||
break;
|
||||
case '\0':
|
||||
if (lexer->eof(lexer)) return 0;
|
||||
advance(lexer);
|
||||
break;
|
||||
default:
|
||||
last = lexer->lookahead;
|
||||
advance(lexer);
|
||||
}
|
||||
|
||||
if (lexer->lookahead == '\'') {
|
||||
advance(lexer);
|
||||
return 0;
|
||||
} else {
|
||||
return last;
|
||||
}
|
||||
}
|
||||
|
||||
bool scan_left_quoted_string_delimiter(TSLexer *lexer) {
|
||||
quoted_string_id.clear();
|
||||
|
||||
while (iswlower(lexer->lookahead) || lexer->lookahead == '_') {
|
||||
quoted_string_id.push_back(lexer->lookahead);
|
||||
advance(lexer);
|
||||
}
|
||||
|
||||
if (lexer->lookahead != '|') return false;
|
||||
|
||||
advance(lexer);
|
||||
in_string = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool scan_right_quoted_string_delimiter(TSLexer *lexer) {
|
||||
for (size_t i = 0; i < quoted_string_id.size(); i++) {
|
||||
if (lexer->lookahead != quoted_string_id[i]) return false;
|
||||
advance(lexer);
|
||||
}
|
||||
|
||||
if (lexer->lookahead != '}') return false;
|
||||
|
||||
in_string = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool scan_quoted_string(TSLexer *lexer) {
|
||||
if (!scan_left_quoted_string_delimiter(lexer)) return false;
|
||||
|
||||
for (;;) {
|
||||
switch (lexer->lookahead) {
|
||||
case '|':
|
||||
advance(lexer);
|
||||
if (scan_right_quoted_string_delimiter(lexer)) return true;
|
||||
break;
|
||||
case '\0':
|
||||
if (lexer->eof(lexer)) return false;
|
||||
advance(lexer);
|
||||
break;
|
||||
default:
|
||||
advance(lexer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool scan_identifier(TSLexer *lexer) {
|
||||
if (iswalpha(lexer->lookahead) || lexer->lookahead == '_') {
|
||||
advance(lexer);
|
||||
while (iswalnum(lexer->lookahead) || lexer->lookahead == '_' || lexer->lookahead == '\'') {
|
||||
advance(lexer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool scan_extattrident(TSLexer *lexer) {
|
||||
while (scan_identifier(lexer)) {
|
||||
if (lexer->lookahead != '.') return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool scan_comment(TSLexer *lexer) {
|
||||
char last = 0;
|
||||
|
||||
if (lexer->lookahead != '*') return false;
|
||||
advance(lexer);
|
||||
|
||||
for (;;) {
|
||||
switch (last ? last : lexer->lookahead) {
|
||||
case '(':
|
||||
if (last) last = 0; else advance(lexer);
|
||||
scan_comment(lexer);
|
||||
break;
|
||||
case '*':
|
||||
if (last) last = 0; else advance(lexer);
|
||||
if (lexer->lookahead == ')') {
|
||||
advance(lexer);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case '\'':
|
||||
if (last) last = 0; else advance(lexer);
|
||||
last = scan_character(lexer);
|
||||
break;
|
||||
case '"':
|
||||
if (last) last = 0; else advance(lexer);
|
||||
scan_string(lexer);
|
||||
break;
|
||||
case '{':
|
||||
if (last) last = 0; else advance(lexer);
|
||||
if (lexer->lookahead == '%') {
|
||||
advance(lexer);
|
||||
if (lexer->lookahead == '%') advance(lexer);
|
||||
if (scan_extattrident(lexer)) {
|
||||
while (iswspace(lexer->lookahead)) advance(lexer);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (scan_quoted_string(lexer)) advance(lexer);
|
||||
break;
|
||||
case '\0':
|
||||
if (lexer->eof(lexer)) return false;
|
||||
if (last) last = 0; else advance(lexer);
|
||||
break;
|
||||
default:
|
||||
if (scan_identifier(lexer) || last) last = 0; else advance(lexer);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
../../ocaml/corpus/module-items.txt
|
||||
@ -1,53 +0,0 @@
|
||||
==============================
|
||||
Value specification
|
||||
==============================
|
||||
|
||||
val x : t
|
||||
val x : 'a . 'a
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(value_specification
|
||||
(value_name)
|
||||
(type_constructor_path (type_constructor)))
|
||||
(value_specification
|
||||
(value_name)
|
||||
(polymorphic_type (type_variable) (type_variable))))
|
||||
|
||||
==============================
|
||||
Include
|
||||
==============================
|
||||
|
||||
include M
|
||||
include t
|
||||
include M.M
|
||||
include M.t
|
||||
include M.M.M
|
||||
include M.M.t
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(include_module_type (module_type_path (module_type_name)))
|
||||
(include_module_type (module_type_path (module_type_name)))
|
||||
(include_module_type
|
||||
(module_type_path
|
||||
(extended_module_path (module_name))
|
||||
(module_type_name)))
|
||||
(include_module_type
|
||||
(module_type_path
|
||||
(extended_module_path (module_name))
|
||||
(module_type_name)))
|
||||
(include_module_type
|
||||
(module_type_path
|
||||
(extended_module_path
|
||||
(extended_module_path (module_name))
|
||||
(module_name))
|
||||
(module_type_name)))
|
||||
(include_module_type
|
||||
(module_type_path
|
||||
(extended_module_path
|
||||
(extended_module_path (module_name))
|
||||
(module_name))
|
||||
(module_type_name))))
|
||||
@ -1,7 +0,0 @@
|
||||
module.exports = grammar(require('../ocaml/grammar'), {
|
||||
name: 'ocaml_interface',
|
||||
|
||||
rules: {
|
||||
compilation_unit: $ => optional($._signature)
|
||||
}
|
||||
})
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"main": "../bindings/node/interface"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,29 +0,0 @@
|
||||
#include "../../common/scanner.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void *tree_sitter_ocaml_interface_external_scanner_create() {
|
||||
return new Scanner();
|
||||
}
|
||||
|
||||
void tree_sitter_ocaml_interface_external_scanner_destroy(void *payload) {
|
||||
Scanner *scanner = static_cast<Scanner *>(payload);
|
||||
delete scanner;
|
||||
}
|
||||
|
||||
unsigned tree_sitter_ocaml_interface_external_scanner_serialize(void *payload, char *buffer) {
|
||||
Scanner *scanner = static_cast<Scanner *>(payload);
|
||||
return scanner->serialize(buffer);
|
||||
}
|
||||
|
||||
void tree_sitter_ocaml_interface_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) {
|
||||
Scanner *scanner = static_cast<Scanner *>(payload);
|
||||
scanner->deserialize(buffer, length);
|
||||
}
|
||||
|
||||
bool tree_sitter_ocaml_interface_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
|
||||
Scanner *scanner = static_cast<Scanner *>(payload);
|
||||
return scanner->scan(lexer, valid_symbols);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,224 +0,0 @@
|
||||
#ifndef TREE_SITTER_PARSER_H_
|
||||
#define TREE_SITTER_PARSER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||
#define ts_builtin_sym_end 0
|
||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||
|
||||
typedef uint16_t TSStateId;
|
||||
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
typedef uint16_t TSSymbol;
|
||||
typedef uint16_t TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
TSFieldId field_id;
|
||||
uint8_t child_index;
|
||||
bool inherited;
|
||||
} TSFieldMapEntry;
|
||||
|
||||
typedef struct {
|
||||
uint16_t index;
|
||||
uint16_t length;
|
||||
} TSFieldMapSlice;
|
||||
|
||||
typedef struct {
|
||||
bool visible;
|
||||
bool named;
|
||||
bool supertype;
|
||||
} TSSymbolMetadata;
|
||||
|
||||
typedef struct TSLexer TSLexer;
|
||||
|
||||
struct TSLexer {
|
||||
int32_t lookahead;
|
||||
TSSymbol result_symbol;
|
||||
void (*advance)(TSLexer *, bool);
|
||||
void (*mark_end)(TSLexer *);
|
||||
uint32_t (*get_column)(TSLexer *);
|
||||
bool (*is_at_included_range_start)(const TSLexer *);
|
||||
bool (*eof)(const TSLexer *);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TSParseActionTypeShift,
|
||||
TSParseActionTypeReduce,
|
||||
TSParseActionTypeAccept,
|
||||
TSParseActionTypeRecover,
|
||||
} TSParseActionType;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t type;
|
||||
TSStateId state;
|
||||
bool extra;
|
||||
bool repetition;
|
||||
} shift;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t child_count;
|
||||
TSSymbol symbol;
|
||||
int16_t dynamic_precedence;
|
||||
uint16_t production_id;
|
||||
} reduce;
|
||||
uint8_t type;
|
||||
} TSParseAction;
|
||||
|
||||
typedef struct {
|
||||
uint16_t lex_state;
|
||||
uint16_t external_lex_state;
|
||||
} TSLexMode;
|
||||
|
||||
typedef union {
|
||||
TSParseAction action;
|
||||
struct {
|
||||
uint8_t count;
|
||||
bool reusable;
|
||||
} entry;
|
||||
} TSParseActionEntry;
|
||||
|
||||
struct TSLanguage {
|
||||
uint32_t version;
|
||||
uint32_t symbol_count;
|
||||
uint32_t alias_count;
|
||||
uint32_t token_count;
|
||||
uint32_t external_token_count;
|
||||
uint32_t state_count;
|
||||
uint32_t large_state_count;
|
||||
uint32_t production_id_count;
|
||||
uint32_t field_count;
|
||||
uint16_t max_alias_sequence_length;
|
||||
const uint16_t *parse_table;
|
||||
const uint16_t *small_parse_table;
|
||||
const uint32_t *small_parse_table_map;
|
||||
const TSParseActionEntry *parse_actions;
|
||||
const char * const *symbol_names;
|
||||
const char * const *field_names;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
const TSSymbol *public_symbol_map;
|
||||
const uint16_t *alias_map;
|
||||
const TSSymbol *alias_sequences;
|
||||
const TSLexMode *lex_modes;
|
||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||
TSSymbol keyword_capture_token;
|
||||
struct {
|
||||
const bool *states;
|
||||
const TSSymbol *symbol_map;
|
||||
void *(*create)(void);
|
||||
void (*destroy)(void *);
|
||||
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
||||
unsigned (*serialize)(void *, char *);
|
||||
void (*deserialize)(void *, const char *, unsigned);
|
||||
} external_scanner;
|
||||
const TSStateId *primary_state_ids;
|
||||
};
|
||||
|
||||
/*
|
||||
* Lexer Macros
|
||||
*/
|
||||
|
||||
#define START_LEXER() \
|
||||
bool result = false; \
|
||||
bool skip = false; \
|
||||
bool eof = false; \
|
||||
int32_t lookahead; \
|
||||
goto start; \
|
||||
next_state: \
|
||||
lexer->advance(lexer, skip); \
|
||||
start: \
|
||||
skip = false; \
|
||||
lookahead = lexer->lookahead;
|
||||
|
||||
#define ADVANCE(state_value) \
|
||||
{ \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define SKIP(state_value) \
|
||||
{ \
|
||||
skip = true; \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define ACCEPT_TOKEN(symbol_value) \
|
||||
result = true; \
|
||||
lexer->result_symbol = symbol_value; \
|
||||
lexer->mark_end(lexer);
|
||||
|
||||
#define END_STATE() return result;
|
||||
|
||||
/*
|
||||
* Parse Table Macros
|
||||
*/
|
||||
|
||||
#define SMALL_STATE(id) id - LARGE_STATE_COUNT
|
||||
|
||||
#define STATE(id) id
|
||||
|
||||
#define ACTIONS(id) id
|
||||
|
||||
#define SHIFT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_REPEAT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value, \
|
||||
.repetition = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_EXTRA() \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.extra = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define REDUCE(symbol_val, child_count_val, ...) \
|
||||
{{ \
|
||||
.reduce = { \
|
||||
.type = TSParseActionTypeReduce, \
|
||||
.symbol = symbol_val, \
|
||||
.child_count = child_count_val, \
|
||||
__VA_ARGS__ \
|
||||
}, \
|
||||
}}
|
||||
|
||||
#define RECOVER() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeRecover \
|
||||
}}
|
||||
|
||||
#define ACCEPT_INPUT() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeAccept \
|
||||
}}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_PARSER_H_
|
||||
@ -1,173 +0,0 @@
|
||||
===========================
|
||||
Floating attributes
|
||||
===========================
|
||||
|
||||
[@@@id]
|
||||
[@@@I.D]
|
||||
[@@@id let x = x]
|
||||
[@@@id:]
|
||||
[@@@id : t]
|
||||
[@@@id : type t type t]
|
||||
[@@@id ? A x]
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(floating_attribute (attribute_id))
|
||||
(floating_attribute (attribute_id))
|
||||
(floating_attribute
|
||||
(attribute_id)
|
||||
(attribute_payload
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name))))))
|
||||
(floating_attribute (attribute_id) (attribute_payload))
|
||||
(floating_attribute
|
||||
(attribute_id)
|
||||
(attribute_payload
|
||||
(type_constructor_path (type_constructor))))
|
||||
(floating_attribute
|
||||
(attribute_id)
|
||||
(attribute_payload
|
||||
(type_definition (type_binding (type_constructor)))
|
||||
(type_definition (type_binding (type_constructor)))))
|
||||
(floating_attribute
|
||||
(attribute_id)
|
||||
(attribute_payload
|
||||
(constructor_pattern
|
||||
(constructor_path (constructor_name))
|
||||
(value_pattern)))))
|
||||
|
||||
===========================
|
||||
Item attributes
|
||||
===========================
|
||||
|
||||
x [@@id] [@@id]
|
||||
let x = x [@@id] and x = x [@@id]
|
||||
module M = M [@@id]
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item (value_path (value_name))
|
||||
(item_attribute (attribute_id))
|
||||
(item_attribute (attribute_id)))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name))
|
||||
(item_attribute (attribute_id)))
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name))
|
||||
(item_attribute (attribute_id))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_path (module_name))
|
||||
(item_attribute (attribute_id)))))
|
||||
|
||||
===========================
|
||||
Attributes
|
||||
===========================
|
||||
|
||||
let%id x = x and [@id] x = x [@id]
|
||||
type t = A [@id] [@id]
|
||||
type t = { x : t [@id]; [@id] }
|
||||
module M = struct [@id] end [@id];;
|
||||
x ;%id x
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(value_definition
|
||||
(attribute_id)
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name)))
|
||||
(attribute (attribute_id))
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name))))
|
||||
(attribute (attribute_id))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(variant_declaration
|
||||
(constructor_declaration
|
||||
(constructor_name)))))
|
||||
(attribute (attribute_id))
|
||||
(attribute (attribute_id))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(record_declaration
|
||||
(field_declaration
|
||||
(field_name)
|
||||
(type_constructor_path (type_constructor)))
|
||||
(attribute (attribute_id))
|
||||
(attribute (attribute_id)))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(structure (attribute (attribute_id)))))
|
||||
(attribute (attribute_id))
|
||||
(expression_item
|
||||
(sequence_expression
|
||||
(value_path (value_name))
|
||||
(attribute_id)
|
||||
(value_path (value_name)))))
|
||||
|
||||
===========================
|
||||
Item extension
|
||||
===========================
|
||||
|
||||
[%%id];;
|
||||
{%%M.id|payload|};;
|
||||
{%%id ab|payload|ab};;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(item_extension (attribute_id))
|
||||
(quoted_item_extension (attribute_id) (quoted_string_content))
|
||||
(quoted_item_extension (attribute_id) (quoted_string_content)))
|
||||
|
||||
===========================
|
||||
Extension
|
||||
===========================
|
||||
|
||||
module type T = [%id]
|
||||
module M = [%id]
|
||||
type t = [%id]
|
||||
let x = [%id]
|
||||
let x = {%id|payload|}
|
||||
let x = {%id ab|payload|ab};;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_type_definition
|
||||
(module_type_name)
|
||||
(extension (attribute_id)))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(extension (attribute_id))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(extension (attribute_id))))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(extension (attribute_id))))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(quoted_extension (attribute_id) (quoted_string_content))))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(quoted_extension (attribute_id) (quoted_string_content)))))
|
||||
@ -1,77 +0,0 @@
|
||||
==============================
|
||||
Comments
|
||||
==============================
|
||||
|
||||
(**)
|
||||
(* *)
|
||||
(**
|
||||
doc
|
||||
*)
|
||||
( *)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(comment)
|
||||
(comment)
|
||||
(comment)
|
||||
(expression_item (value_path (parenthesized_operator (infix_operator)))))
|
||||
|
||||
==============================
|
||||
Strings and comments
|
||||
==============================
|
||||
|
||||
(* "*)" *)
|
||||
"(**)";;
|
||||
"(*";;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(comment)
|
||||
(expression_item (string (string_content)))
|
||||
(expression_item (string (string_content))))
|
||||
|
||||
==============================
|
||||
Characters and comments
|
||||
==============================
|
||||
|
||||
(* '"' *)
|
||||
(* f' '"' *)
|
||||
(* *)
|
||||
(* '\o170' '"' *)
|
||||
(* '\'"' *)
|
||||
(* '\" " *)
|
||||
(* '" " *)
|
||||
(* '*)
|
||||
x
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(comment)
|
||||
(comment)
|
||||
(comment)
|
||||
(comment)
|
||||
(comment)
|
||||
(comment)
|
||||
(comment)
|
||||
(comment)
|
||||
(expression_item (value_path (value_name))))
|
||||
|
||||
==============================
|
||||
Quoted strings and comments
|
||||
==============================
|
||||
|
||||
(* {|*)|} *)
|
||||
(* {%id |*)|} *)
|
||||
{|(**)|};;
|
||||
{|(*|};;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(comment)
|
||||
(comment)
|
||||
(expression_item (quoted_string (quoted_string_content)))
|
||||
(expression_item (quoted_string (quoted_string_content))))
|
||||
@ -1,719 +0,0 @@
|
||||
===========================
|
||||
Values
|
||||
===========================
|
||||
|
||||
x;;
|
||||
M.x;;
|
||||
( + );;
|
||||
M.( + );;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item (value_path (value_name)))
|
||||
(expression_item
|
||||
(value_path
|
||||
(module_path (module_name))
|
||||
(value_name)))
|
||||
(expression_item
|
||||
(value_path (parenthesized_operator (infix_operator))))
|
||||
(expression_item
|
||||
(value_path
|
||||
(module_path (module_name))
|
||||
(parenthesized_operator (infix_operator)))))
|
||||
|
||||
===========================
|
||||
Constants
|
||||
===========================
|
||||
|
||||
493;;
|
||||
10_000_000;;
|
||||
0x1ed;;
|
||||
0o644;;
|
||||
0b111101101;;
|
||||
4.93e2;;
|
||||
493e+0;;
|
||||
0x7b.4p2;;
|
||||
'x';;
|
||||
'\n';;
|
||||
'\'';;
|
||||
'\120';;
|
||||
'\x78';;
|
||||
'\o170';;
|
||||
'
|
||||
';;
|
||||
"OCaml";;
|
||||
"\"\079\u{43}aml\"";;
|
||||
"OCaml\
|
||||
OCaml";;
|
||||
"%d %05.2f";;
|
||||
"@[%s@ %d@]@.";;
|
||||
"
|
||||
";;
|
||||
" ";;
|
||||
"";;
|
||||
{|OCaml|};;
|
||||
{id||id};;
|
||||
{id|{|}id}|idd||id};;
|
||||
{|%d@.|};;
|
||||
{|
|
||||
|};;
|
||||
{| |};;
|
||||
true;;
|
||||
();;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item (number))
|
||||
(expression_item (number))
|
||||
(expression_item (number))
|
||||
(expression_item (number))
|
||||
(expression_item (number))
|
||||
(expression_item (number))
|
||||
(expression_item (number))
|
||||
(expression_item (number))
|
||||
(expression_item (character (character_content)))
|
||||
(expression_item (character (character_content (escape_sequence))))
|
||||
(expression_item (character (character_content (escape_sequence))))
|
||||
(expression_item (character (character_content (escape_sequence))))
|
||||
(expression_item (character (character_content (escape_sequence))))
|
||||
(expression_item (character (character_content (escape_sequence))))
|
||||
(expression_item (character (character_content)))
|
||||
(expression_item (string (string_content)))
|
||||
(expression_item (string (string_content (escape_sequence) (escape_sequence) (escape_sequence) (escape_sequence))))
|
||||
(expression_item (string (string_content (escape_sequence))))
|
||||
(expression_item (string (string_content (conversion_specification) (conversion_specification))))
|
||||
(expression_item (string (string_content
|
||||
(pretty_printing_indication)
|
||||
(conversion_specification)
|
||||
(pretty_printing_indication)
|
||||
(conversion_specification)
|
||||
(pretty_printing_indication)
|
||||
(pretty_printing_indication))))
|
||||
(expression_item (string (string_content)))
|
||||
(expression_item (string (string_content)))
|
||||
(expression_item (string))
|
||||
(expression_item (quoted_string (quoted_string_content)))
|
||||
(expression_item (quoted_string))
|
||||
(expression_item (quoted_string (quoted_string_content)))
|
||||
(expression_item (quoted_string (quoted_string_content
|
||||
(conversion_specification)
|
||||
(pretty_printing_indication))))
|
||||
(expression_item (quoted_string (quoted_string_content)))
|
||||
(expression_item (quoted_string (quoted_string_content)))
|
||||
(expression_item (boolean))
|
||||
(expression_item (unit)))
|
||||
|
||||
===========================
|
||||
Typed expression
|
||||
===========================
|
||||
|
||||
(x : t)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(typed_expression
|
||||
(value_path (value_name))
|
||||
(type_constructor_path (type_constructor)))))
|
||||
|
||||
===========================
|
||||
Lists, arrays and records
|
||||
===========================
|
||||
|
||||
[];;
|
||||
[x; x; x];;
|
||||
x :: x :: xs;;
|
||||
[||];;
|
||||
[| x; x; x |];;
|
||||
{ x = x; x; };;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item (list_expression))
|
||||
(expression_item
|
||||
(list_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(cons_expression
|
||||
(value_path (value_name))
|
||||
(cons_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name)))))
|
||||
(expression_item (array_expression))
|
||||
(expression_item
|
||||
(array_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(record_expression
|
||||
(field_expression
|
||||
(field_path (field_name))
|
||||
(value_path (value_name)))
|
||||
(field_expression
|
||||
(field_path (field_name))))))
|
||||
|
||||
===========================
|
||||
Get and set expressions
|
||||
===========================
|
||||
|
||||
x.y.z <- x;;
|
||||
x.(0).[0].{0,0} <- x;;
|
||||
x.%(0).M.%(0) <- x;;
|
||||
1 #? x.%(0);;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(set_expression
|
||||
(field_get_expression
|
||||
(field_get_expression
|
||||
(value_path (value_name))
|
||||
(field_path (field_name)))
|
||||
(field_path (field_name)))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(set_expression
|
||||
(bigarray_get_expression
|
||||
(string_get_expression
|
||||
(array_get_expression
|
||||
(value_path (value_name))
|
||||
(number))
|
||||
(number))
|
||||
(product_expression
|
||||
(number)
|
||||
(number)))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(set_expression
|
||||
(array_get_expression
|
||||
(array_get_expression
|
||||
(value_path (value_name))
|
||||
(indexing_operator_path (indexing_operator))
|
||||
(number))
|
||||
(indexing_operator_path
|
||||
(module_path (module_name))
|
||||
(indexing_operator))
|
||||
(number))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(hash_expression
|
||||
(number)
|
||||
(hash_operator)
|
||||
(array_get_expression
|
||||
(value_path (value_name))
|
||||
(indexing_operator_path (indexing_operator))
|
||||
(number)))))
|
||||
|
||||
===========================
|
||||
Coercions
|
||||
===========================
|
||||
|
||||
(x :> t);;
|
||||
(x : t :> t);;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(coercion_expression
|
||||
(value_path (value_name))
|
||||
(type_constructor_path (type_constructor))))
|
||||
(expression_item
|
||||
(coercion_expression
|
||||
(value_path (value_name))
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor)))))
|
||||
|
||||
===========================
|
||||
Local opens
|
||||
===========================
|
||||
|
||||
M.(x);;
|
||||
M.[x; x];;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(local_open_expression
|
||||
(module_path (module_name))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(local_open_expression
|
||||
(module_path (module_name))
|
||||
(list_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))))))
|
||||
|
||||
===========================
|
||||
Package expressions
|
||||
===========================
|
||||
|
||||
(module M);;
|
||||
(module M : T);;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(package_expression
|
||||
(module_path (module_name))))
|
||||
(expression_item
|
||||
(package_expression
|
||||
(module_path (module_name))
|
||||
(module_type_path (module_type_name)))))
|
||||
|
||||
===========================
|
||||
Product expressions
|
||||
===========================
|
||||
|
||||
x, y, z;;
|
||||
(x, y)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(product_expression
|
||||
(product_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name)))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(parenthesized_expression
|
||||
(product_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))))))
|
||||
|
||||
===========================
|
||||
Constructors
|
||||
===========================
|
||||
|
||||
A;;
|
||||
M.A;;
|
||||
A x;;
|
||||
( :: ) (x, l);;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(constructor_path (constructor_name)))
|
||||
(expression_item
|
||||
(constructor_path
|
||||
(module_path (module_name))
|
||||
(constructor_name)))
|
||||
(expression_item
|
||||
(application_expression
|
||||
(constructor_path (constructor_name))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(application_expression
|
||||
(constructor_path (constructor_name))
|
||||
(parenthesized_expression
|
||||
(product_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name)))))))
|
||||
|
||||
===========================
|
||||
Tags
|
||||
===========================
|
||||
|
||||
`A;;
|
||||
`A x;;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item (tag))
|
||||
(expression_item
|
||||
(application_expression
|
||||
(tag)
|
||||
(value_path (value_name)))))
|
||||
|
||||
===========================
|
||||
Function application
|
||||
===========================
|
||||
|
||||
f x;;
|
||||
f x x;;
|
||||
f ~x ?x:x ~(x:x);;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(application_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(application_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(application_expression
|
||||
(value_path (value_name))
|
||||
(labeled_argument (label_name))
|
||||
(labeled_argument
|
||||
(label_name)
|
||||
(value_path (value_name)))
|
||||
(labeled_argument
|
||||
(label_name)
|
||||
(type_constructor_path (type_constructor))))))
|
||||
|
||||
===========================
|
||||
Operators
|
||||
===========================
|
||||
|
||||
!x;;
|
||||
~-x;;
|
||||
-x;;
|
||||
x - y;;
|
||||
x lsl 1;;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(prefix_expression
|
||||
(prefix_operator)
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(prefix_expression
|
||||
(prefix_operator)
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(sign_expression
|
||||
(sign_operator)
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(infix_expression
|
||||
(value_path (value_name))
|
||||
(infix_operator)
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(infix_expression
|
||||
(value_path (value_name))
|
||||
(infix_operator)
|
||||
(number))))
|
||||
|
||||
===========================
|
||||
If, while and for
|
||||
===========================
|
||||
|
||||
if x then y;;
|
||||
if x then y else z;;
|
||||
while x do y done;;
|
||||
for i = 1 to n do x done;;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(if_expression
|
||||
(value_path (value_name))
|
||||
(then_clause (value_path (value_name)))))
|
||||
(expression_item
|
||||
(if_expression
|
||||
(value_path (value_name))
|
||||
(then_clause (value_path (value_name)))
|
||||
(else_clause (value_path (value_name)))))
|
||||
(expression_item
|
||||
(while_expression
|
||||
(value_path (value_name))
|
||||
(do_clause (value_path (value_name)))))
|
||||
(expression_item
|
||||
(for_expression
|
||||
(value_pattern)
|
||||
(number)
|
||||
(value_path (value_name))
|
||||
(do_clause (value_path (value_name))))))
|
||||
|
||||
===========================
|
||||
Sequence expressions
|
||||
===========================
|
||||
|
||||
x; y; z;;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(sequence_expression
|
||||
(value_path (value_name))
|
||||
(sequence_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))))))
|
||||
|
||||
===========================
|
||||
Match expressions
|
||||
===========================
|
||||
|
||||
match x with
|
||||
| x -> x
|
||||
| x when x -> x
|
||||
| x | x -> x
|
||||
| exception x -> x;;
|
||||
match+ x with x -> x;;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(match_expression
|
||||
(value_path (value_name))
|
||||
(match_case
|
||||
(value_pattern)
|
||||
(value_path (value_name)))
|
||||
(match_case
|
||||
(value_pattern)
|
||||
(guard (value_path (value_name)))
|
||||
(value_path (value_name)))
|
||||
(match_case
|
||||
(or_pattern (value_pattern) (value_pattern))
|
||||
(value_path (value_name)))
|
||||
(match_case
|
||||
(exception_pattern (value_pattern))
|
||||
(value_path (value_name)))))
|
||||
(expression_item
|
||||
(match_expression
|
||||
(match_operator)
|
||||
(value_path (value_name))
|
||||
(match_case
|
||||
(value_pattern)
|
||||
(value_path (value_name))))))
|
||||
|
||||
===========================
|
||||
Function expressions
|
||||
===========================
|
||||
|
||||
function 0 -> 0 | x -> 1;;
|
||||
function A (type a) x -> 1;;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(number)
|
||||
(number))
|
||||
(match_case
|
||||
(value_pattern)
|
||||
(number))))
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(constructor_pattern
|
||||
(constructor_path (constructor_name))
|
||||
(abstract_type (type_constructor))
|
||||
(value_pattern))
|
||||
(number)))))
|
||||
|
||||
===========================
|
||||
Try expressions
|
||||
===========================
|
||||
|
||||
try x with Exception -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(try_expression
|
||||
(value_path (value_name))
|
||||
(match_case
|
||||
(constructor_path (constructor_name))
|
||||
(unit)))))
|
||||
|
||||
===========================
|
||||
Let expressions
|
||||
===========================
|
||||
|
||||
let x = 0 in x;;
|
||||
let rec x = y and y = x in x;;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(let_expression
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(number)))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(let_expression
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name)))
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name))))
|
||||
(value_path (value_name)))))
|
||||
|
||||
===========================
|
||||
Assert expressions
|
||||
===========================
|
||||
|
||||
assert x
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(assert_expression (value_path (value_name)))))
|
||||
|
||||
===========================
|
||||
Lazy expressions
|
||||
===========================
|
||||
|
||||
lazy x
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(lazy_expression (value_path (value_name)))))
|
||||
|
||||
===========================
|
||||
Let module, open, exception
|
||||
===========================
|
||||
|
||||
let module M = M in x;;
|
||||
let open M in x;;
|
||||
let exception E in x;;
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(let_module_expression
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_path (module_name))))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(let_open_expression
|
||||
(open_module (module_path (module_name)))
|
||||
(value_path (value_name))))
|
||||
(expression_item
|
||||
(let_exception_expression
|
||||
(exception_definition
|
||||
(constructor_declaration (constructor_name)))
|
||||
(value_path (value_name)))))
|
||||
|
||||
===========================
|
||||
Parenthesized expressions
|
||||
===========================
|
||||
|
||||
let x = (x)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(parenthesized_expression (value_path (value_name))))))
|
||||
|
||||
===========================
|
||||
Precedence
|
||||
===========================
|
||||
|
||||
let x = x in if x then x <- x := ! x . x ## x x x lsl x ** x * x mod x + x - x :: x :: x @ x ^ x < x > x & x && x or x || x, x, x; x; x
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(let_expression
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name))))
|
||||
(sequence_expression
|
||||
(if_expression
|
||||
(value_path (value_name))
|
||||
(then_clause
|
||||
(set_expression
|
||||
(instance_variable_name)
|
||||
(infix_expression
|
||||
(value_path (value_name))
|
||||
(infix_operator)
|
||||
(product_expression
|
||||
(product_expression
|
||||
(infix_expression
|
||||
(infix_expression
|
||||
(infix_expression
|
||||
(infix_expression
|
||||
(infix_expression
|
||||
(cons_expression
|
||||
(infix_expression
|
||||
(infix_expression
|
||||
(infix_expression
|
||||
(infix_expression
|
||||
(infix_expression
|
||||
(application_expression
|
||||
(hash_expression
|
||||
(field_get_expression
|
||||
(prefix_expression
|
||||
(prefix_operator)
|
||||
(value_path (value_name)))
|
||||
(field_path (field_name)))
|
||||
(hash_operator)
|
||||
(value_path (value_name)))
|
||||
(value_path (value_name))
|
||||
(value_path (value_name)))
|
||||
(infix_operator)
|
||||
(infix_expression
|
||||
(value_path (value_name))
|
||||
(infix_operator)
|
||||
(value_path (value_name))))
|
||||
(infix_operator)
|
||||
(value_path (value_name)))
|
||||
(infix_operator)
|
||||
(value_path (value_name)))
|
||||
(infix_operator)
|
||||
(value_path (value_name)))
|
||||
(infix_operator)
|
||||
(value_path (value_name)))
|
||||
(cons_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name))))
|
||||
(infix_operator)
|
||||
(infix_expression
|
||||
(value_path (value_name))
|
||||
(infix_operator)
|
||||
(value_path (value_name))))
|
||||
(infix_operator)
|
||||
(value_path (value_name)))
|
||||
(infix_operator)
|
||||
(value_path (value_name)))
|
||||
(infix_operator)
|
||||
(infix_expression
|
||||
(value_path (value_name))
|
||||
(infix_operator)
|
||||
(value_path (value_name))))
|
||||
(infix_operator)
|
||||
(infix_expression
|
||||
(value_path (value_name))
|
||||
(infix_operator)
|
||||
(value_path (value_name))))
|
||||
(value_path (value_name)))
|
||||
(value_path (value_name)))))))
|
||||
(sequence_expression
|
||||
(value_path (value_name))
|
||||
(value_path (value_name)))))))
|
||||
@ -1,146 +0,0 @@
|
||||
==========================
|
||||
Module paths
|
||||
==========================
|
||||
|
||||
module M = M
|
||||
module M = M.M
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_path (module_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_path
|
||||
(module_path (module_name))
|
||||
(module_name)))))
|
||||
|
||||
============================
|
||||
Structures
|
||||
============================
|
||||
|
||||
module M = struct
|
||||
let x = x
|
||||
end
|
||||
module M = struct ;; end
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(structure
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(value_path (value_name)))))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(structure))))
|
||||
|
||||
============================
|
||||
Module applications
|
||||
============================
|
||||
|
||||
module M = M (M)
|
||||
module M = M (M) (M)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_application
|
||||
(module_path (module_name))
|
||||
(parenthesized_module_expression (module_path (module_name))))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_application
|
||||
(module_application
|
||||
(module_path (module_name))
|
||||
(parenthesized_module_expression (module_path (module_name))))
|
||||
(parenthesized_module_expression (module_path (module_name)))))))
|
||||
|
||||
==========================
|
||||
Typed module expressions
|
||||
==========================
|
||||
|
||||
module M = (M : T)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(typed_module_expression
|
||||
(module_path (module_name))
|
||||
(module_type_path (module_type_name))))))
|
||||
|
||||
=========================
|
||||
Packed modules
|
||||
==========================
|
||||
|
||||
module M = (val m)
|
||||
module M = (val m : T)
|
||||
module M = M (val m)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(packed_module (value_path (value_name)))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(packed_module
|
||||
(value_path (value_name))
|
||||
(module_type_path (module_type_name)))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_application
|
||||
(module_path (module_name))
|
||||
(packed_module (value_path (value_name)))))))
|
||||
|
||||
=========================
|
||||
Functors
|
||||
==========================
|
||||
|
||||
module M = functor (M : T) -> M
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(functor
|
||||
(module_parameter
|
||||
(module_name)
|
||||
(module_type_path (module_type_name)))
|
||||
(module_path (module_name))))))
|
||||
|
||||
==============================
|
||||
Parenthesized module expressions
|
||||
==============================
|
||||
|
||||
module M = (M)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(parenthesized_module_expression (module_path (module_name))))))
|
||||
@ -1,98 +0,0 @@
|
||||
==============================
|
||||
Value definition
|
||||
==============================
|
||||
|
||||
let x = y
|
||||
let ( + ) = x
|
||||
let rec x = y and y = x
|
||||
let x, y = y, x
|
||||
let x : 'a . 'a t = y
|
||||
let f ~x ~l:y ~(x : t) ?(l = y) ?l:((x, y) : t = xy) = x
|
||||
let f (type t) x : t = x
|
||||
let+ x = a and+ y = b
|
||||
let%ext x
|
||||
let* x and* y
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(value_definition
|
||||
(let_binding (value_name) (value_path (value_name))))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(parenthesized_operator (infix_operator))
|
||||
(value_path (value_name))))
|
||||
(value_definition
|
||||
(let_binding (value_name) (value_path (value_name)))
|
||||
(let_binding (value_name) (value_path (value_name))))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(tuple_pattern (value_name) (value_name))
|
||||
(product_expression (value_path (value_name)) (value_path (value_name)))))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(polymorphic_type
|
||||
(type_variable)
|
||||
(constructed_type (type_variable) (type_constructor_path (type_constructor))))
|
||||
(value_path (value_name))))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(parameter (value_pattern))
|
||||
(parameter (label_name) (value_pattern))
|
||||
(parameter (value_pattern) (type_constructor_path (type_constructor)))
|
||||
(parameter (value_pattern) (value_path (value_name)))
|
||||
(parameter
|
||||
(label_name)
|
||||
(parenthesized_pattern
|
||||
(tuple_pattern (value_pattern) (value_pattern)))
|
||||
(type_constructor_path (type_constructor))
|
||||
(value_path (value_name)))
|
||||
(value_path (value_name))))
|
||||
(value_definition
|
||||
(let_binding
|
||||
(value_name)
|
||||
(abstract_type (type_constructor))
|
||||
(parameter (value_pattern))
|
||||
(type_constructor_path (type_constructor))
|
||||
(value_path (value_name))))
|
||||
(value_definition
|
||||
(let_operator)
|
||||
(let_binding (value_name) (value_path (value_name)))
|
||||
(and_operator)
|
||||
(let_binding (value_name) (value_path (value_name))))
|
||||
(value_definition (attribute_id) (let_binding (value_name)))
|
||||
(value_definition
|
||||
(let_operator)
|
||||
(let_binding (value_name))
|
||||
(and_operator)
|
||||
(let_binding (value_name))))
|
||||
|
||||
==============================
|
||||
Include
|
||||
==============================
|
||||
|
||||
include M
|
||||
include M.M
|
||||
include M.M.M
|
||||
include M(M)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(include_module (module_path (module_name)))
|
||||
(include_module
|
||||
(module_path
|
||||
(module_path (module_name))
|
||||
(module_name)))
|
||||
(include_module
|
||||
(module_path
|
||||
(module_path
|
||||
(module_path (module_name))
|
||||
(module_name))
|
||||
(module_name)))
|
||||
(include_module
|
||||
(module_application
|
||||
(module_path (module_name))
|
||||
(parenthesized_module_expression (module_path (module_name))))))
|
||||
@ -1,215 +0,0 @@
|
||||
==============================
|
||||
External
|
||||
==============================
|
||||
|
||||
external x : int = "x"
|
||||
external x : 'a . 'a = "x"
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(external
|
||||
(value_name)
|
||||
(type_constructor_path (type_constructor))
|
||||
(string (string_content)))
|
||||
(external
|
||||
(value_name)
|
||||
(polymorphic_type (type_variable) (type_variable))
|
||||
(string (string_content))))
|
||||
|
||||
==============================
|
||||
Type definition
|
||||
==============================
|
||||
|
||||
type t
|
||||
type nonrec 'a t = t and ('a, 'b) t = t
|
||||
type t = private t
|
||||
type t = A | B of t | C of t * t | D of {x : t}
|
||||
type _ t =
|
||||
| A : t -> t
|
||||
| B : 'a . 'a -> 'a t
|
||||
type t = {
|
||||
mutable x : t;
|
||||
}
|
||||
type t = t constraint 'a = t
|
||||
type t = |
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition (type_binding (type_constructor)))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_variable)
|
||||
(type_constructor)
|
||||
(type_constructor_path (type_constructor)))
|
||||
(type_binding
|
||||
(type_variable) (type_variable)
|
||||
(type_constructor)
|
||||
(type_constructor_path (type_constructor))))
|
||||
(type_definition (type_binding (type_constructor) (type_constructor_path (type_constructor))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(variant_declaration
|
||||
(constructor_declaration (constructor_name))
|
||||
(constructor_declaration
|
||||
(constructor_name)
|
||||
(type_constructor_path (type_constructor)))
|
||||
(constructor_declaration
|
||||
(constructor_name)
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor)))
|
||||
(constructor_declaration
|
||||
(constructor_name)
|
||||
(record_declaration
|
||||
(field_declaration
|
||||
(field_name)
|
||||
(type_constructor_path (type_constructor))))))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_variable)
|
||||
(type_constructor)
|
||||
(variant_declaration
|
||||
(constructor_declaration
|
||||
(constructor_name)
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor)))
|
||||
(constructor_declaration
|
||||
(constructor_name)
|
||||
(type_variable)
|
||||
(type_variable)
|
||||
(constructed_type (type_variable) (type_constructor_path (type_constructor)))))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(record_declaration
|
||||
(field_declaration (field_name) (type_constructor_path (type_constructor))))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constraint (type_variable) (type_constructor_path (type_constructor)))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(variant_declaration))))
|
||||
|
||||
==============================
|
||||
Exception definition
|
||||
==============================
|
||||
|
||||
exception E
|
||||
exception E of t
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(exception_definition (constructor_declaration (constructor_name)))
|
||||
(exception_definition
|
||||
(constructor_declaration
|
||||
(constructor_name)
|
||||
(type_constructor_path (type_constructor)))))
|
||||
|
||||
==============================
|
||||
Module definition
|
||||
==============================
|
||||
|
||||
module M
|
||||
module M : T
|
||||
module M (M : T) : E
|
||||
module rec M : T and M : T
|
||||
|
||||
module M = M
|
||||
module M := M
|
||||
module M : T = M
|
||||
module M (M : T) = M
|
||||
module rec M = N and N = M
|
||||
|
||||
module _ (_ : T) = M
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_type_path (module_type_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_parameter (module_name) (module_type_path (module_type_name)))
|
||||
(module_type_path (module_type_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_type_path (module_type_name)))
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_type_path (module_type_name))))
|
||||
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_path (module_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_path (module_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_type_path (module_type_name))
|
||||
(module_path (module_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_parameter (module_name) (module_type_path (module_type_name)))
|
||||
(module_path (module_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_path (module_name)))
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_path (module_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_parameter (module_name) (module_type_path (module_type_name)))
|
||||
(module_path (module_name)))))
|
||||
|
||||
==============================
|
||||
Module type definition
|
||||
==============================
|
||||
|
||||
module type T = T
|
||||
module type T := T
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_type_definition
|
||||
(module_type_name)
|
||||
(module_type_path (module_type_name)))
|
||||
(module_type_definition
|
||||
(module_type_name)
|
||||
(module_type_path (module_type_name))))
|
||||
|
||||
==============================
|
||||
Open
|
||||
==============================
|
||||
|
||||
open M
|
||||
open! M
|
||||
open ! M
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(open_module (module_path (module_name)))
|
||||
(open_module (module_path (module_name)))
|
||||
(open_module (module_path (module_name))))
|
||||
@ -1,118 +0,0 @@
|
||||
==============================
|
||||
Module type path
|
||||
==============================
|
||||
|
||||
module M : T
|
||||
module M : M.T
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_type_path (module_type_name))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_type_path
|
||||
(extended_module_path (module_name))
|
||||
(module_type_name)))))
|
||||
|
||||
==============================
|
||||
Signatures
|
||||
==============================
|
||||
|
||||
module M : sig
|
||||
val x : t
|
||||
end
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(signature
|
||||
(value_specification
|
||||
(value_name)
|
||||
(type_constructor_path (type_constructor)))))))
|
||||
|
||||
==============================
|
||||
Constraints
|
||||
==============================
|
||||
|
||||
module M : T with type t = t and module M := M and module type T = T
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_type_constraint
|
||||
(module_type_path (module_type_name))
|
||||
(constrain_type
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor)))
|
||||
(constrain_module
|
||||
(module_path (module_name))
|
||||
(extended_module_path (module_name)))
|
||||
(constrain_module_type
|
||||
(module_type_path (module_type_name))
|
||||
(module_type_path (module_type_name)))))))
|
||||
|
||||
==============================
|
||||
Module type of
|
||||
==============================
|
||||
|
||||
module M : module type of M
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(module_type_of (module_path (module_name))))))
|
||||
|
||||
==============================
|
||||
Functor types
|
||||
==============================
|
||||
|
||||
module M : functor (M : T) -> T
|
||||
module M : T -> T -> T
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(functor_type
|
||||
(module_parameter
|
||||
(module_name)
|
||||
(module_type_path (module_type_name)))
|
||||
(module_type_path (module_type_name)))))
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(functor_type
|
||||
(module_type_path (module_type_name))
|
||||
(functor_type
|
||||
(module_type_path (module_type_name))
|
||||
(module_type_path (module_type_name)))))))
|
||||
|
||||
==============================
|
||||
Parenthesized module types
|
||||
==============================
|
||||
|
||||
module M : (T)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(module_definition
|
||||
(module_binding
|
||||
(module_name)
|
||||
(parenthesized_module_type (module_type_path (module_type_name))))))
|
||||
@ -1,235 +0,0 @@
|
||||
============================
|
||||
Values
|
||||
============================
|
||||
|
||||
function x -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case (value_pattern) (unit)))))
|
||||
|
||||
============================
|
||||
Constant patterns
|
||||
============================
|
||||
|
||||
function 1 | +1.0 | 'x' | "x" | {|x|} | true | () -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(number)
|
||||
(signed_number))
|
||||
(character (character_content)))
|
||||
(string (string_content)))
|
||||
(quoted_string (quoted_string_content)))
|
||||
(boolean))
|
||||
(unit))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Typed patterns
|
||||
============================
|
||||
|
||||
function (x : t) -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(typed_pattern
|
||||
(value_pattern)
|
||||
(type_constructor_path (type_constructor)))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Constructors and tags
|
||||
============================
|
||||
|
||||
function A x | A | `A | `A x -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(constructor_pattern
|
||||
(constructor_path (constructor_name))
|
||||
(value_pattern))
|
||||
(constructor_path (constructor_name)))
|
||||
(tag))
|
||||
(tag_pattern (tag) (value_pattern)))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Polymorphic variant patterns
|
||||
============================
|
||||
|
||||
function #t -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(polymorphic_variant_pattern
|
||||
(type_constructor_path (type_constructor)))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Records, lists and arrays
|
||||
============================
|
||||
|
||||
function {x} | [x] | [|x|] | [|x;y;|] | x :: xs -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(or_pattern
|
||||
(record_pattern
|
||||
(field_pattern (field_path (field_name))))
|
||||
(list_pattern (value_pattern)))
|
||||
(array_pattern (value_pattern)))
|
||||
(array_pattern (value_pattern) (value_pattern)))
|
||||
(cons_pattern (value_pattern) (value_pattern)))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Local open patterns
|
||||
============================
|
||||
|
||||
function M.(A x) | M.[x] -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(or_pattern
|
||||
(local_open_pattern
|
||||
(module_path (module_name))
|
||||
(constructor_pattern
|
||||
(constructor_path (constructor_name))
|
||||
(value_pattern)))
|
||||
(local_open_pattern
|
||||
(module_path (module_name))
|
||||
(list_pattern (value_pattern))))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Package patterns
|
||||
============================
|
||||
|
||||
function (module M) -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(package_pattern (module_name))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Alias patterns
|
||||
============================
|
||||
|
||||
function x as t -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(alias_pattern (value_pattern) (value_pattern))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Tuple patterns
|
||||
============================
|
||||
|
||||
function x, x, x -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(tuple_pattern
|
||||
(tuple_pattern
|
||||
(value_pattern)
|
||||
(value_pattern))
|
||||
(value_pattern))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Range patterns
|
||||
============================
|
||||
|
||||
function 'a' .. 'z' -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(range_pattern (character (character_content)) (character (character_content)))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Lazy patterns
|
||||
============================
|
||||
|
||||
function lazy x -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case (lazy_pattern (value_pattern))
|
||||
(unit)))))
|
||||
|
||||
============================
|
||||
Parenthesized patterns
|
||||
============================
|
||||
|
||||
function (x) -> ()
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(expression_item
|
||||
(function_expression
|
||||
(match_case
|
||||
(parenthesized_pattern (value_pattern))
|
||||
(unit)))))
|
||||
@ -1,31 +0,0 @@
|
||||
==============================
|
||||
Toplevel directives
|
||||
==============================
|
||||
|
||||
#help
|
||||
#use "file.ml"
|
||||
#show_module M
|
||||
#show x
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(toplevel_directive (directive))
|
||||
(toplevel_directive (directive) (string (string_content)))
|
||||
(toplevel_directive (directive) (module_path (module_name)))
|
||||
(toplevel_directive
|
||||
(directive)
|
||||
(value_path (value_name))))
|
||||
|
||||
==============================
|
||||
Line number directives
|
||||
==============================
|
||||
|
||||
# 1 "test.ml"
|
||||
# 2 "test.ml" (* comment *)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(line_number_directive)
|
||||
(line_number_directive))
|
||||
@ -1,244 +0,0 @@
|
||||
===========================
|
||||
Type variables
|
||||
===========================
|
||||
|
||||
type 'a t = 'a
|
||||
type ('a, 'b) t = 'a
|
||||
type +'a t = 'a
|
||||
type !+'a t = 'a
|
||||
type +!'a t = 'a
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_variable)
|
||||
(type_constructor)
|
||||
(type_variable)))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_variable)
|
||||
(type_variable)
|
||||
(type_constructor)
|
||||
(type_variable)))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_variable)
|
||||
(type_constructor)
|
||||
(type_variable)))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_variable)
|
||||
(type_constructor)
|
||||
(type_variable)))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_variable)
|
||||
(type_constructor)
|
||||
(type_variable))))
|
||||
|
||||
===========================
|
||||
Type constructors
|
||||
===========================
|
||||
|
||||
type t = t
|
||||
type t = M.t
|
||||
type t = M(M).t
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(type_constructor_path (type_constructor))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(type_constructor_path
|
||||
(extended_module_path (module_name))
|
||||
(type_constructor))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(type_constructor_path
|
||||
(extended_module_path
|
||||
(extended_module_path (module_name))
|
||||
(extended_module_path (module_name)))
|
||||
(type_constructor)))))
|
||||
|
||||
===========================
|
||||
Constructed types
|
||||
===========================
|
||||
|
||||
type t = int list
|
||||
type t = int list list
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(constructed_type
|
||||
(type_constructor_path (type_constructor)) (type_constructor_path (type_constructor)))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(constructed_type
|
||||
(constructed_type
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor)))
|
||||
(type_constructor_path (type_constructor))))))
|
||||
|
||||
===========================
|
||||
Polymorphic variant types
|
||||
===========================
|
||||
|
||||
type t = [`A | `B of t]
|
||||
type t = [>
|
||||
| t
|
||||
| `C
|
||||
]
|
||||
type t = [< `A of t & t ]
|
||||
type t = [< `A > `A ]
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(polymorphic_variant_type
|
||||
(tag_specification (tag))
|
||||
(tag_specification
|
||||
(tag)
|
||||
(type_constructor_path (type_constructor))))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(polymorphic_variant_type
|
||||
(type_constructor_path (type_constructor))
|
||||
(tag_specification (tag)))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(polymorphic_variant_type
|
||||
(tag_specification
|
||||
(tag)
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor))))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(polymorphic_variant_type
|
||||
(tag_specification (tag))
|
||||
(tag)))))
|
||||
|
||||
===========================
|
||||
Package types
|
||||
===========================
|
||||
|
||||
type t = (module T)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(package_type
|
||||
(module_type_path (module_type_name))))))
|
||||
|
||||
===========================
|
||||
Function types
|
||||
===========================
|
||||
|
||||
type t = t -> t
|
||||
type t = t -> t -> t
|
||||
type t = l:t -> ?l:t -> t
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(function_type
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor)))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(function_type
|
||||
(type_constructor_path (type_constructor)) (function_type
|
||||
(type_constructor_path (type_constructor)) (type_constructor_path (type_constructor))))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(function_type
|
||||
(typed_label
|
||||
(label_name)
|
||||
(type_constructor_path (type_constructor)))
|
||||
(function_type
|
||||
(typed_label
|
||||
(label_name)
|
||||
(type_constructor_path (type_constructor)))
|
||||
(type_constructor_path (type_constructor)))))))
|
||||
|
||||
===========================
|
||||
Tuple types
|
||||
===========================
|
||||
|
||||
type t = t * t
|
||||
type t = t * t * t
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(tuple_type
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor)))))
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(tuple_type
|
||||
(tuple_type
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_constructor_path (type_constructor)))
|
||||
(type_constructor_path (type_constructor))))))
|
||||
|
||||
===========================
|
||||
Aliased types
|
||||
===========================
|
||||
|
||||
type t = t as 't
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(aliased_type
|
||||
(type_constructor_path (type_constructor))
|
||||
(type_variable)))))
|
||||
|
||||
===========================
|
||||
Parenthesized types
|
||||
===========================
|
||||
|
||||
type t = (t)
|
||||
|
||||
---
|
||||
|
||||
(compilation_unit
|
||||
(type_definition
|
||||
(type_binding
|
||||
(type_constructor)
|
||||
(parenthesized_type
|
||||
(type_constructor_path (type_constructor))))))
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
||||
{
|
||||
"main": "../bindings/node/ocaml"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,29 +0,0 @@
|
||||
#include "../../common/scanner.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void *tree_sitter_ocaml_external_scanner_create() {
|
||||
return new Scanner();
|
||||
}
|
||||
|
||||
void tree_sitter_ocaml_external_scanner_destroy(void *payload) {
|
||||
Scanner *scanner = static_cast<Scanner *>(payload);
|
||||
delete scanner;
|
||||
}
|
||||
|
||||
unsigned tree_sitter_ocaml_external_scanner_serialize(void *payload, char *buffer) {
|
||||
Scanner *scanner = static_cast<Scanner *>(payload);
|
||||
return scanner->serialize(buffer);
|
||||
}
|
||||
|
||||
void tree_sitter_ocaml_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) {
|
||||
Scanner *scanner = static_cast<Scanner *>(payload);
|
||||
scanner->deserialize(buffer, length);
|
||||
}
|
||||
|
||||
bool tree_sitter_ocaml_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
|
||||
Scanner *scanner = static_cast<Scanner *>(payload);
|
||||
return scanner->scan(lexer, valid_symbols);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,224 +0,0 @@
|
||||
#ifndef TREE_SITTER_PARSER_H_
|
||||
#define TREE_SITTER_PARSER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||
#define ts_builtin_sym_end 0
|
||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||
|
||||
typedef uint16_t TSStateId;
|
||||
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
typedef uint16_t TSSymbol;
|
||||
typedef uint16_t TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
TSFieldId field_id;
|
||||
uint8_t child_index;
|
||||
bool inherited;
|
||||
} TSFieldMapEntry;
|
||||
|
||||
typedef struct {
|
||||
uint16_t index;
|
||||
uint16_t length;
|
||||
} TSFieldMapSlice;
|
||||
|
||||
typedef struct {
|
||||
bool visible;
|
||||
bool named;
|
||||
bool supertype;
|
||||
} TSSymbolMetadata;
|
||||
|
||||
typedef struct TSLexer TSLexer;
|
||||
|
||||
struct TSLexer {
|
||||
int32_t lookahead;
|
||||
TSSymbol result_symbol;
|
||||
void (*advance)(TSLexer *, bool);
|
||||
void (*mark_end)(TSLexer *);
|
||||
uint32_t (*get_column)(TSLexer *);
|
||||
bool (*is_at_included_range_start)(const TSLexer *);
|
||||
bool (*eof)(const TSLexer *);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TSParseActionTypeShift,
|
||||
TSParseActionTypeReduce,
|
||||
TSParseActionTypeAccept,
|
||||
TSParseActionTypeRecover,
|
||||
} TSParseActionType;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t type;
|
||||
TSStateId state;
|
||||
bool extra;
|
||||
bool repetition;
|
||||
} shift;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t child_count;
|
||||
TSSymbol symbol;
|
||||
int16_t dynamic_precedence;
|
||||
uint16_t production_id;
|
||||
} reduce;
|
||||
uint8_t type;
|
||||
} TSParseAction;
|
||||
|
||||
typedef struct {
|
||||
uint16_t lex_state;
|
||||
uint16_t external_lex_state;
|
||||
} TSLexMode;
|
||||
|
||||
typedef union {
|
||||
TSParseAction action;
|
||||
struct {
|
||||
uint8_t count;
|
||||
bool reusable;
|
||||
} entry;
|
||||
} TSParseActionEntry;
|
||||
|
||||
struct TSLanguage {
|
||||
uint32_t version;
|
||||
uint32_t symbol_count;
|
||||
uint32_t alias_count;
|
||||
uint32_t token_count;
|
||||
uint32_t external_token_count;
|
||||
uint32_t state_count;
|
||||
uint32_t large_state_count;
|
||||
uint32_t production_id_count;
|
||||
uint32_t field_count;
|
||||
uint16_t max_alias_sequence_length;
|
||||
const uint16_t *parse_table;
|
||||
const uint16_t *small_parse_table;
|
||||
const uint32_t *small_parse_table_map;
|
||||
const TSParseActionEntry *parse_actions;
|
||||
const char * const *symbol_names;
|
||||
const char * const *field_names;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
const TSSymbol *public_symbol_map;
|
||||
const uint16_t *alias_map;
|
||||
const TSSymbol *alias_sequences;
|
||||
const TSLexMode *lex_modes;
|
||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||
TSSymbol keyword_capture_token;
|
||||
struct {
|
||||
const bool *states;
|
||||
const TSSymbol *symbol_map;
|
||||
void *(*create)(void);
|
||||
void (*destroy)(void *);
|
||||
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
||||
unsigned (*serialize)(void *, char *);
|
||||
void (*deserialize)(void *, const char *, unsigned);
|
||||
} external_scanner;
|
||||
const TSStateId *primary_state_ids;
|
||||
};
|
||||
|
||||
/*
|
||||
* Lexer Macros
|
||||
*/
|
||||
|
||||
#define START_LEXER() \
|
||||
bool result = false; \
|
||||
bool skip = false; \
|
||||
bool eof = false; \
|
||||
int32_t lookahead; \
|
||||
goto start; \
|
||||
next_state: \
|
||||
lexer->advance(lexer, skip); \
|
||||
start: \
|
||||
skip = false; \
|
||||
lookahead = lexer->lookahead;
|
||||
|
||||
#define ADVANCE(state_value) \
|
||||
{ \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define SKIP(state_value) \
|
||||
{ \
|
||||
skip = true; \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define ACCEPT_TOKEN(symbol_value) \
|
||||
result = true; \
|
||||
lexer->result_symbol = symbol_value; \
|
||||
lexer->mark_end(lexer);
|
||||
|
||||
#define END_STATE() return result;
|
||||
|
||||
/*
|
||||
* Parse Table Macros
|
||||
*/
|
||||
|
||||
#define SMALL_STATE(id) id - LARGE_STATE_COUNT
|
||||
|
||||
#define STATE(id) id
|
||||
|
||||
#define ACTIONS(id) id
|
||||
|
||||
#define SHIFT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_REPEAT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value, \
|
||||
.repetition = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_EXTRA() \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.extra = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define REDUCE(symbol_val, child_count_val, ...) \
|
||||
{{ \
|
||||
.reduce = { \
|
||||
.type = TSParseActionTypeReduce, \
|
||||
.symbol = symbol_val, \
|
||||
.child_count = child_count_val, \
|
||||
__VA_ARGS__ \
|
||||
}, \
|
||||
}}
|
||||
|
||||
#define RECOVER() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeRecover \
|
||||
}}
|
||||
|
||||
#define ACCEPT_INPUT() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeAccept \
|
||||
}}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_PARSER_H_
|
||||
@ -1,45 +0,0 @@
|
||||
{
|
||||
"name": "tree-sitter-ocaml",
|
||||
"version": "0.20.1",
|
||||
"description": "OCaml grammar for tree-sitter",
|
||||
"keywords": [
|
||||
"parser",
|
||||
"ocaml"
|
||||
],
|
||||
"author": "Max Brunsfeld",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nan": "^2.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tree-sitter-cli": "^0.20.6"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build-ocaml && npm run build-interface",
|
||||
"build-ocaml": "cd ocaml && tree-sitter generate",
|
||||
"build-interface": "cd interface && tree-sitter generate",
|
||||
"test": "npm run test-ocaml && npm run test-interface && npm run test-highlight && script/parse-examples",
|
||||
"test-ocaml": "cd ocaml && tree-sitter test",
|
||||
"test-interface": "cd interface && tree-sitter test",
|
||||
"test-highlight": "tree-sitter test"
|
||||
},
|
||||
"tree-sitter": [
|
||||
{
|
||||
"scope": "source.ocaml",
|
||||
"file-types": [
|
||||
"ml"
|
||||
],
|
||||
"first-line-regex": "",
|
||||
"path": "ocaml",
|
||||
"injection-regex": "^(ocaml|ml)$"
|
||||
},
|
||||
{
|
||||
"scope": "source.ocaml.interface",
|
||||
"file-types": [
|
||||
"mli"
|
||||
],
|
||||
"path": "interface",
|
||||
"injection-regex": "^ocaml_interface$"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,147 +0,0 @@
|
||||
; Modules
|
||||
;--------
|
||||
|
||||
[(module_name) (module_type_name)] @constructor
|
||||
|
||||
; Types
|
||||
;------
|
||||
|
||||
(
|
||||
(type_constructor) @type.builtin
|
||||
(#match? @type.builtin "^(int|char|bytes|string|float|bool|unit|exn|array|list|option|int32|int64|nativeint|format6|lazy_t)$")
|
||||
)
|
||||
|
||||
[(class_name) (class_type_name) (type_constructor)] @type
|
||||
|
||||
[(constructor_name) (tag)] @tag
|
||||
|
||||
; Functions
|
||||
;----------
|
||||
|
||||
(let_binding
|
||||
pattern: (value_name) @function
|
||||
(parameter))
|
||||
|
||||
(let_binding
|
||||
pattern: (value_name) @function
|
||||
body: [(fun_expression) (function_expression)])
|
||||
|
||||
(value_specification (value_name) @function)
|
||||
|
||||
(external (value_name) @function)
|
||||
|
||||
(method_name) @function.method
|
||||
|
||||
; Application
|
||||
;------------
|
||||
|
||||
(
|
||||
(value_name) @function.builtin
|
||||
(#match? @function.builtin "^(raise(_notrace)?|failwith|invalid_arg)$")
|
||||
)
|
||||
|
||||
(infix_expression
|
||||
left: (value_path (value_name) @function)
|
||||
(infix_operator) @operator
|
||||
(#eq? @operator "@@"))
|
||||
|
||||
(infix_expression
|
||||
(infix_operator) @operator
|
||||
right: (value_path (value_name) @function)
|
||||
(#eq? @operator "|>"))
|
||||
|
||||
(application_expression
|
||||
function: (value_path (value_name) @function))
|
||||
|
||||
; Variables
|
||||
;----------
|
||||
|
||||
[(value_name) (type_variable)] @variable
|
||||
|
||||
(value_pattern) @variable.parameter
|
||||
|
||||
; Properties
|
||||
;-----------
|
||||
|
||||
[(label_name) (field_name) (instance_variable_name)] @property
|
||||
|
||||
; Constants
|
||||
;----------
|
||||
|
||||
(boolean) @constant
|
||||
|
||||
[(number) (signed_number)] @number
|
||||
|
||||
[(string) (character)] @string
|
||||
|
||||
(quoted_string "{" @string "}" @string) @string
|
||||
|
||||
(escape_sequence) @escape
|
||||
|
||||
(conversion_specification) @string.special
|
||||
|
||||
; Operators
|
||||
;----------
|
||||
|
||||
(match_expression (match_operator) @keyword)
|
||||
|
||||
(value_definition [(let_operator) (and_operator)] @keyword)
|
||||
|
||||
[
|
||||
(prefix_operator)
|
||||
(sign_operator)
|
||||
(infix_operator)
|
||||
(hash_operator)
|
||||
(indexing_operator)
|
||||
(let_operator)
|
||||
(and_operator)
|
||||
(match_operator)
|
||||
] @operator
|
||||
|
||||
(infix_operator ["&" "+" "-" "=" ">" "|" "%"] @operator)
|
||||
(signed_number ["+" "-"] @operator)
|
||||
|
||||
["*" "#" "::" "<-"] @operator
|
||||
|
||||
; Keywords
|
||||
;---------
|
||||
|
||||
[
|
||||
"and" "as" "assert" "begin" "class" "constraint" "do" "done" "downto" "else"
|
||||
"end" "exception" "external" "for" "fun" "function" "functor" "if" "in"
|
||||
"include" "inherit" "initializer" "lazy" "let" "match" "method" "module"
|
||||
"mutable" "new" "nonrec" "object" "of" "open" "private" "rec" "sig" "struct"
|
||||
"then" "to" "try" "type" "val" "virtual" "when" "while" "with"
|
||||
] @keyword
|
||||
|
||||
; Punctuation
|
||||
;------------
|
||||
|
||||
(attribute ["[@" "]"] @punctuation.special)
|
||||
(item_attribute ["[@@" "]"] @punctuation.special)
|
||||
(floating_attribute ["[@@@" "]"] @punctuation.special)
|
||||
(extension ["[%" "]"] @punctuation.special)
|
||||
(item_extension ["[%%" "]"] @punctuation.special)
|
||||
(quoted_extension ["{%" "}"] @punctuation.special)
|
||||
(quoted_item_extension ["{%%" "}"] @punctuation.special)
|
||||
|
||||
"%" @punctuation.special
|
||||
|
||||
["(" ")" "[" "]" "{" "}" "[|" "|]" "[<" "[>"] @punctuation.bracket
|
||||
|
||||
(object_type ["<" ">"] @punctuation.bracket)
|
||||
|
||||
[
|
||||
"," "." ";" ":" "=" "|" "~" "?" "+" "-" "!" ">" "&"
|
||||
"->" ";;" ":>" "+=" ":=" ".."
|
||||
] @punctuation.delimiter
|
||||
|
||||
; Attributes
|
||||
;-----------
|
||||
|
||||
(attribute_id) @attribute
|
||||
|
||||
; Comments
|
||||
;---------
|
||||
|
||||
[(comment) (line_number_directive) (directive) (shebang)] @comment
|
||||
@ -1,24 +0,0 @@
|
||||
; Scopes
|
||||
;-------
|
||||
|
||||
[
|
||||
(let_binding)
|
||||
(class_binding)
|
||||
(class_function)
|
||||
(method_definition)
|
||||
(fun_expression)
|
||||
(object_expression)
|
||||
(for_expression)
|
||||
(match_case)
|
||||
(attribute_payload)
|
||||
] @local.scope
|
||||
|
||||
; Definitions
|
||||
;------------
|
||||
|
||||
(value_pattern) @local.definition
|
||||
|
||||
; References
|
||||
;-----------
|
||||
|
||||
(value_path . (value_name) @local.reference)
|
||||
@ -1,116 +0,0 @@
|
||||
; Modules
|
||||
;--------
|
||||
|
||||
(
|
||||
(comment)? @doc .
|
||||
(module_definition (module_binding (module_name) @name) @definition.module)
|
||||
(#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
|
||||
)
|
||||
|
||||
(module_path (module_name) @name) @reference.module
|
||||
|
||||
; Modules types
|
||||
;--------------
|
||||
|
||||
(
|
||||
(comment)? @doc .
|
||||
(module_type_definition (module_type_name) @name) @definition.interface
|
||||
(#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
|
||||
)
|
||||
|
||||
(module_type_path (module_type_name) @name) @reference.implementation
|
||||
|
||||
; Functions
|
||||
;----------
|
||||
|
||||
(
|
||||
(comment)? @doc .
|
||||
(value_definition
|
||||
[
|
||||
(let_binding
|
||||
pattern: (value_name) @name
|
||||
(parameter))
|
||||
(let_binding
|
||||
pattern: (value_name) @name
|
||||
body: [(fun_expression) (function_expression)])
|
||||
] @definition.function
|
||||
)
|
||||
(#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
|
||||
)
|
||||
|
||||
(
|
||||
(comment)? @doc .
|
||||
(external (value_name) @name) @definition.function
|
||||
(#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
|
||||
)
|
||||
|
||||
(application_expression
|
||||
function: (value_path (value_name) @name)) @reference.call
|
||||
|
||||
(infix_expression
|
||||
left: (value_path (value_name) @name)
|
||||
(infix_operator) @reference.call
|
||||
(#eq? @reference.call "@@"))
|
||||
|
||||
(infix_expression
|
||||
(infix_operator) @reference.call
|
||||
right: (value_path (value_name) @name)
|
||||
(#eq? @reference.call "|>"))
|
||||
|
||||
; Operator
|
||||
;---------
|
||||
|
||||
(
|
||||
(comment)? @doc .
|
||||
(value_definition
|
||||
(let_binding
|
||||
pattern: (parenthesized_operator [
|
||||
(prefix_operator)
|
||||
(infix_operator)
|
||||
(hash_operator)
|
||||
(indexing_operator)
|
||||
(let_operator)
|
||||
(and_operator)
|
||||
(match_operator)
|
||||
] @name)) @definition.function)
|
||||
(#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
|
||||
)
|
||||
|
||||
[
|
||||
(prefix_operator)
|
||||
(sign_operator)
|
||||
(infix_operator)
|
||||
(hash_operator)
|
||||
(indexing_operator)
|
||||
(let_operator)
|
||||
(and_operator)
|
||||
(match_operator)
|
||||
] @name @reference.call
|
||||
|
||||
; Classes
|
||||
;--------
|
||||
|
||||
(
|
||||
(comment)? @doc .
|
||||
[
|
||||
(class_definition (class_binding (class_name) @name) @definition.class)
|
||||
(class_type_definition (class_type_binding (class_type_name) @name) @definition.class)
|
||||
]
|
||||
(#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
|
||||
)
|
||||
|
||||
[
|
||||
(class_path (class_name) @name)
|
||||
(class_type_path (class_type_name) @name)
|
||||
] @reference.class
|
||||
|
||||
; Methods
|
||||
;--------
|
||||
|
||||
(
|
||||
(comment)? @doc .
|
||||
(method_definition (method_name) @name) @definition.method
|
||||
(#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
|
||||
)
|
||||
|
||||
(method_invocation (method_name) @name) @reference.call
|
||||
@ -1,47 +0,0 @@
|
||||
examples/lablgtk/applications/osiris/osiris.ml
|
||||
examples/lablgtk/examples/csview.ml
|
||||
examples/lablgtk/tools/introspection/stubs/stubs_Atk.ml
|
||||
examples/lablgtk/tools/introspection/stubs/stubs_Pango.ml
|
||||
examples/lwt/src/react/lwt_react.cppo.ml
|
||||
examples/lwt/src/unix/lwt_unix.cppo.ml
|
||||
examples/lwt/src/unix/lwt_unix.cppo.mli
|
||||
examples/lwt/test/unix/test_lwt_unix.cppo.ml
|
||||
examples/merlin/tests/test-dirs/completion/infix.t/infix.ml
|
||||
examples/merlin/tests/test-dirs/completion/parenthesize.t/parenthesize.ml
|
||||
examples/merlin/tests/test-dirs/construct/c-modules.t/functor_app.ml
|
||||
examples/merlin/tests/test-dirs/construct/c-modules.t/module.ml
|
||||
examples/merlin/tests/test-dirs/errors/typing-after-parsing.t/test.ml
|
||||
examples/merlin/tests/test-dirs/locate/context-detection/cd-label.t/label.ml
|
||||
examples/ocaml/stdlib/templates/float.template.mli
|
||||
examples/ocaml/stdlib/templates/moreLabels.template.mli
|
||||
examples/ocaml/testsuite/tests/generated-parse-errors/errors.ml
|
||||
examples/ocaml/testsuite/tests/lexing/escape.ml
|
||||
examples/ocaml/testsuite/tests/lexing/uchar_esc.ml
|
||||
examples/ocaml/testsuite/tests/parse-errors/*
|
||||
examples/ocaml/testsuite/tests/parsing/anonymous_class_parameter.ml
|
||||
examples/ocaml/testsuite/tests/parsing/arrow_ambiguity.ml
|
||||
examples/ocaml/testsuite/tests/parsing/constructor_declarations.ml
|
||||
examples/ocaml/testsuite/tests/parsing/docstrings.ml
|
||||
examples/ocaml/testsuite/tests/parsing/pr6604_2.ml
|
||||
examples/ocaml/testsuite/tests/parsing/pr6604.ml
|
||||
examples/ocaml/testsuite/tests/tool-toplevel/error_highlighting_use2.ml
|
||||
examples/ocaml/testsuite/tests/tool-toplevel/error_highlighting_use3.ml
|
||||
examples/ocaml/testsuite/tests/tool-toplevel/error_highlighting.ml
|
||||
examples/ocaml/testsuite/tests/typing-misc/typecore_errors.ml
|
||||
examples/ocaml/testsuite/tests/typing-sigsubst/sig_local_aliases_syntax_errors.ml
|
||||
examples/ocaml/testsuite/tests/typing-sigsubst/sig_local_aliases.ml
|
||||
examples/ocaml/testsuite/tests/typing-warnings/pr7261.ml
|
||||
examples/ocamlformat/test/failing/*/*
|
||||
examples/ocamlformat/test/passing/*/*
|
||||
examples/ocamlformat/test/rpc/big_margin/foo.ml
|
||||
examples/ocamlformat/vendor/parser-recovery/test/expect/signature/*.mli
|
||||
examples/ocamlformat/vendor/parser-recovery/test/expect/structure/*.ml
|
||||
examples/ppxlib/astlib/astlib.ml
|
||||
examples/ppxlib/astlib/location.ml
|
||||
examples/ppxlib/astlib/longident.ml
|
||||
examples/ppxlib/test/code_path/test.ml
|
||||
examples/ppxlib/test/driver/non-compressible-suffix/test.ml
|
||||
examples/ppxlib/test/ppx_import_support/test.ml
|
||||
examples/ppxlib/test/quoter/test.ml
|
||||
examples/opam/src/core/opamCompat.ml
|
||||
examples/opam/src/core/opamCompat.mli
|
||||
@ -1,60 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
function clone_repo {
|
||||
owner=$1
|
||||
name=$2
|
||||
sha=$3
|
||||
|
||||
path=examples/$name
|
||||
if [ ! -d "$path" ]; then
|
||||
echo "Cloning $owner/$name"
|
||||
git clone "https://github.com/$owner/$name" "$path"
|
||||
fi
|
||||
|
||||
pushd "$path" > /dev/null
|
||||
head=$(git rev-parse HEAD)
|
||||
if [ "$head" != "$sha" ]; then
|
||||
echo "Updating $owner/$name from $head to $sha"
|
||||
git fetch
|
||||
git reset --hard $sha
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
clone_repo 0install 0install b88111c7dc1612b0beaa175df9c91df4fa36556b
|
||||
clone_repo BinaryAnalysisPlatform bap a972f8a419294dfb21847db5172ba58c5d7767eb
|
||||
clone_repo dbuenzli cmdliner 2c370b7ca519473584c04a3c4f89683f3cc0aad0
|
||||
clone_repo facebook flow 5ada26749e0a95a1e562aee955859cc10decf517
|
||||
clone_repo facebook pyre-check b794d924f77dd005af15da6fafb73010394804e3
|
||||
clone_repo garrigue lablgtk b298ee1b4cba588537df1c4cfd996358e3a8750b
|
||||
clone_repo janestreet base 8993e35ba2e83e5020b2deb548253ef1e4a699d4
|
||||
clone_repo mirage ocaml-cohttp 628d8716b22bb7933863dd584673745c974707be
|
||||
clone_repo ocaml dune 50815dbdda5c924142bf2c54feba87c5894465d5
|
||||
clone_repo ocaml merlin dd7663fcff929ac395909cada9e829acdc77e97e
|
||||
clone_repo ocaml ocaml 1042d5cd441ec2c8b5c87151313dbe7d1eebf2e7
|
||||
clone_repo ocaml opam 51d458b5946d938aa2b45ddc924a2ad75130fb69
|
||||
clone_repo ocaml-ppx ocamlformat b436f8d9e53661c1f5b51d40f701b9bd74cd4f84
|
||||
clone_repo ocaml-ppx ppxlib 5fe8514d59ccbdd312b709ed3aea00781feefca3
|
||||
clone_repo ocsigen js_of_ocaml ee5c335882aab362e66f5993d2a97bf7886cd247
|
||||
clone_repo ocsigen lwt b3e7dd029dacbe37df9565c142c2206cfe6831c2
|
||||
clone_repo owlbarn owl eead31f1920e63b876421e6a30e61c947f29827f
|
||||
|
||||
known_failures="$(cat script/known_failures.txt)"
|
||||
|
||||
tree-sitter parse -q \
|
||||
'examples/**/*.ml' \
|
||||
'examples/**/*.mli' \
|
||||
$(for failure in $known_failures; do echo "!${failure}"; done)
|
||||
|
||||
example_count=$(find examples -name '*.ml' -o -name '*.mli' | wc -l)
|
||||
failure_count=$(wc -w <<< "$known_failures")
|
||||
success_count=$(( $example_count - $failure_count ))
|
||||
success_percent=$(bc -l <<< "100*${success_count}/${example_count}")
|
||||
|
||||
printf \
|
||||
"Successfully parsed %d of %d example files (%.1f%%)\n" \
|
||||
$success_count $example_count $success_percent
|
||||
@ -1,4 +0,0 @@
|
||||
[@@@id payload]
|
||||
(* <- punctuation.special *)
|
||||
(* ^ attribute *)
|
||||
(* ^ punctuation.special *)
|
||||
@ -1,14 +0,0 @@
|
||||
let t = true
|
||||
(* ^ constant *)
|
||||
|
||||
let c = 'c'
|
||||
(* ^ string *)
|
||||
|
||||
let () = Printf.printf "string\n%d" 5
|
||||
(* ^ punctuation.bracket *)
|
||||
(* ^ string *)
|
||||
(* ^ escape *)
|
||||
(* ^ string.special *)
|
||||
(* ^ number *)
|
||||
let x = {id|string|id}
|
||||
(* ^ string *)
|
||||
@ -1,32 +0,0 @@
|
||||
let f x = failwith "not_implemented"
|
||||
(* ^ function *)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ function.builtin *)
|
||||
let f = fun x -> x
|
||||
(* ^ function *)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable.parameter *)
|
||||
|
||||
let f = function Some x -> true | None -> false
|
||||
(* ^ function *)
|
||||
|
||||
module type T = sig
|
||||
val f : int -> int
|
||||
(* ^ function *)
|
||||
end
|
||||
|
||||
external f : int -> int = "f"
|
||||
(* ^ function *)
|
||||
|
||||
let x = f 0
|
||||
(* ^ variable *)
|
||||
(* ^ function *)
|
||||
|
||||
let x = f @@ x |> f
|
||||
(* ^ variable *)
|
||||
(* ^ function *)
|
||||
(* ^ variable *)
|
||||
(* ^ function *)
|
||||
|
||||
let f ~l:x = 0
|
||||
(* ^ property *)
|
||||
@ -1,47 +0,0 @@
|
||||
let f x ({a = y} as r) (Some z) =
|
||||
(* ^ function *)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ property *)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable.parameter *)
|
||||
(x, a, y, r, z)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable *)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable.parameter *)
|
||||
|
||||
let f = fun x -> (x, y)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable *)
|
||||
|
||||
let _ =
|
||||
match o with
|
||||
| Some x -> x
|
||||
(* ^ variable.parameter *)
|
||||
| None -> y
|
||||
(* ^ variable *)
|
||||
|
||||
let () =
|
||||
for x = 1 to n do
|
||||
ignore x;
|
||||
(* ^ variable.parameter *)
|
||||
ignore n;
|
||||
(* ^ variable *)
|
||||
done
|
||||
|
||||
let (x, y) = (x, y)
|
||||
(* ^ variable *)
|
||||
(* ^ variable *)
|
||||
(* ^ variable *)
|
||||
(* ^ variable *)
|
||||
|
||||
let {a = x} = assert false
|
||||
(* ^ variable *)
|
||||
|
||||
let f x = (M.x, x)
|
||||
(* ^ variable.parameter *)
|
||||
(* ^ variable *)
|
||||
(* ^ variable.parameter *)
|
||||
@ -1,38 +0,0 @@
|
||||
module type T = sig
|
||||
(* <- keyword *)
|
||||
(* ^ keyword *)
|
||||
(* ^ constructor *)
|
||||
(* ^ punctuation.delimiter *)
|
||||
(* ^ keyword *)
|
||||
val x : int
|
||||
end
|
||||
(* <- keyword *)
|
||||
|
||||
module M : T = struct
|
||||
(* <- keyword *)
|
||||
(* ^ constructor *)
|
||||
(* ^ punctuation.delimiter *)
|
||||
(* ^ constructor *)
|
||||
let x = 0
|
||||
end
|
||||
|
||||
module F (M : T) = struct
|
||||
(* ^ constructor *)
|
||||
(* ^ punctuation.bracket *)
|
||||
(* ^ constructor *)
|
||||
(* ^ constructor *)
|
||||
(* ^ punctuation.bracket *)
|
||||
(* ^ keyword *)
|
||||
include M
|
||||
(* <- keyword *)
|
||||
(* ^ constructor *)
|
||||
end
|
||||
|
||||
module N = F (M)
|
||||
(* ^ constructor *)
|
||||
(* ^ constructor *)
|
||||
(* ^ constructor *)
|
||||
|
||||
let x = N.x
|
||||
(* ^ constructor *)
|
||||
(* ^ punctuation.delimiter *)
|
||||
@ -1,19 +0,0 @@
|
||||
let ( + ) = ( * )
|
||||
(* ^ operator *)
|
||||
(* ^ operator *)
|
||||
let x = (1 + 2) :: 3
|
||||
(* ^ operator *)
|
||||
(* ^ operator *)
|
||||
|
||||
let f = function +1 -> true | -1 -> true | _ -> false
|
||||
(* ^ operator *)
|
||||
(* ^ operator *)
|
||||
|
||||
let ( let* ) x f = f x
|
||||
(* ^ operator *)
|
||||
|
||||
let () =
|
||||
let* x = 0 and* y = 1 in
|
||||
(* <- keyword *)
|
||||
(* ^ keyword *)
|
||||
ignore x
|
||||
@ -1,33 +0,0 @@
|
||||
type ('a, 'b) either = Left of 'a | Right of 'b
|
||||
(* <- keyword *) (* ^ tag *)
|
||||
(* ^ variable *) (* ^ keyword *)
|
||||
(* ^ variable *) (* ^ variable *)
|
||||
(* ^ type *) (* ^ punctuation.delimiter *)
|
||||
|
||||
let x : (bool, int) either = Left true
|
||||
(* ^ type.builtin *)
|
||||
(* ^ type.builtin *)
|
||||
(* ^ type *)
|
||||
(* ^ tag *)
|
||||
|
||||
|
||||
type ('a, 'b) either' = [`Left of 'a | `Right of 'b]
|
||||
(* ^ punctuation.bracket *)
|
||||
(* ^ punctuation.delimiter *)
|
||||
(* ^ punctuation.bracket *)
|
||||
(* ^ tag *) (* ^ tag *)
|
||||
|
||||
type pos = {x : int; y : int}
|
||||
(* ^ punctuation.bracket *)
|
||||
(* ^ property *)
|
||||
(* ^ punctuation.delimiter *)
|
||||
(* ^ property *)
|
||||
(* ^ punctuation.bracket *)
|
||||
|
||||
type x = < x : int >
|
||||
(* ^ punctuation.bracket *)
|
||||
(* ^ punctuation.bracket *)
|
||||
|
||||
type (-'a, +'b) func = 'a -> 'b
|
||||
(* ^ punctuation.delimiter *)
|
||||
(* ^ punctuation.delimiter *)
|
||||
Loading…
Reference in New Issue