Skip to content

Commit

Permalink
Squashed 'resources/webidl2/' changes from dd57b9f0db..68a37d21e8
Browse files Browse the repository at this point in the history
68a37d21e8 chore(package): bump version number to 12.1.0
621d0b6c17 fix: prevent keywords from being identifiers (#157)
9ad8932034 chore(package): bump version number to 12.0.0
a154b63cea BREAKING CHANGE: remove allowNestedTypedefs (#155)
5a495f76a5 refactor: remove all_ws() and gather trivia implicitly (#154)
e717aa67fa tests: Remove test/widlproc (#153)
131e74cc57 chore(package): bump version number to 11.0.0
09f8a1daae Prevent incorrect enums (#151)
fa060611a9 BREAKING CHANGE: remove opt.ws (#150)
2bb4e1cbb2 chore(package): bump version number to 10.3.3 (#149)
80936fa3c9 oefactor simple_extended_attr() (#148)
c060079cca docs: remove description about typePair (#147)
4169268630 docs: simple WebIDL checker. (#146)
a28c7b55f7 chore(package): bump version number to 10.3.2
e311680dc0 fix: correctly handle whitespaces of implements and includes. (#145)
50c828344d refactor: remove eas.length check (#144)
968ca63fd4 refactor: one-to-one match for token matcher (#143)
8531535861 chore(package): bump version number to 10.3.1
96deeb3480 const-type as full IDL Type (#142)
a13dfa8cf5 chore(package): bump version number to 10.3.0
c0ab164af2 always add extAttrs for .idlType (#141)
932dcfb96d docs(README): add missing typedef-type
56777f49dc docs(README): add missing types-of-types
c14d7c1767 docs(README): add types of types (#140)
730a3b99db chore(CHANGELOG): regenerate

git-subtree-dir: resources/webidl2
git-subtree-split: 68a37d21e81740563a5e98198e0e979232d363c0
  • Loading branch information
foolip committed May 18, 2018
1 parent 6597dc5 commit 7bb4c71
Show file tree
Hide file tree
Showing 75 changed files with 1,351 additions and 942 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [v10.2.1](https://github.com/w3c/webidl2.js/tree/v10.2.1) (2018-03-09)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.2.0...v10.2.1)

**Merged pull requests:**

- Optimise tokenisation and whitespace skipping [\#139](https://github.com/w3c/webidl2.js/pull/139) ([ricea](https://github.com/ricea))
- refactor: small syntax changes [\#137](https://github.com/w3c/webidl2.js/pull/137) ([saschanaz](https://github.com/saschanaz))

## [v10.2.0](https://github.com/w3c/webidl2.js/tree/v10.2.0) (2018-01-30)
[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.1.0...v10.2.0)

Expand Down
77 changes: 39 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,6 @@ In the browser:
</script>
```

### Advanced Parsing

`parse()` can optionally accept a second parameter, an options object, which can be used to
modify parsing behavior.

The following options are recognized:
```JS
{
allowNestedTypedefs: false
}
```

And their meanings are as follows:

* `allowNestedTypedefs`: Boolean indicating whether the parser should accept `typedef`s as valid members of `interface`s.
This is non-standard syntax and therefore the default is `false`.

### Errors

When there is a syntax error in the WebIDL, it throws an exception object with the following
Expand Down Expand Up @@ -93,16 +76,19 @@ attached to a field called `idlType`:

```JS
{
"type": "attribute-type",
"sequence": false,
"generic": null,
"idlType": "void",
"idlType": "unsigned short",
"nullable": false,
"union": false,
"extAttrs": [...]
}
```

Where the fields are as follows:

* `type`: String indicating where this type is used. Can be `null` if not applicable.
* `sequence`: Boolean indicating if it is a sequence. Same as `generic === "sequence"`.
* `generic`: String indicating the generic type (e.g. "Promise", "sequence"). `null`
otherwise.
Expand All @@ -113,6 +99,7 @@ Where the fields are as follows:
description for the type in the sequence, the eventual value of the promise, etc.
* `nullable`: Boolean indicating whether this is nullable or not.
* `union`: Boolean indicating whether this is a union type or not.
* `extAttrs`: A list of [extended attributes](#extended-attributes).

### Interface

Expand Down Expand Up @@ -211,11 +198,13 @@ A callback looks like this:
"type": "callback",
"name": "AsyncOperationCallback",
"idlType": {
"type": "return-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "void"
"idlType": "void",
"extAttrs": []
},
"arguments": [...],
"extAttrs": []
Expand Down Expand Up @@ -244,11 +233,13 @@ A dictionary looks like this:
"name": "fillPattern",
"required": false,
"idlType": {
"type": "dictionary-type",
"sequence": false,
"generic": null,
"nullable": true,
"union": false,
"idlType": "DOMString"
"idlType": "DOMString",
"extAttrs": [...]
},
"extAttrs": [],
"default": {
Expand Down Expand Up @@ -311,17 +302,21 @@ A typedef looks like this:
{
"type": "typedef",
"idlType": {
"type": "typedef-type",
"sequence": true,
"generic": "sequence",
"nullable": false,
"union": false,
"idlType": {
"type": "typedef-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "Point"
}
"idlType": "Point",
"extAttrs": [...]
},
"extAttrs": [...]
},
"name": "PointSequence",
"extAttrs": []
Expand Down Expand Up @@ -388,23 +383,27 @@ An operation looks like this:
"static": false,
"stringifier": false,
"idlType": {
"type": "return-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "void"
"idlType": "void",
"extAttrs": []
},
"name": "intersection",
"arguments": [{
"optional": false,
"variadic": true,
"extAttrs": [],
"idlType": {
"type": "argument-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "long"
"idlType": "long",
"extAttrs": [...]
},
"name": "ints"
}],
Expand Down Expand Up @@ -437,11 +436,13 @@ An attribute member looks like this:
"inherit": false,
"readonly": false,
"idlType": {
"type": "attribute-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "RegExp"
"idlType": "RegExp",
"extAttrs": [...]
},
"name": "regexp",
"extAttrs": []
Expand All @@ -467,7 +468,15 @@ A constant member looks like this:
{
"type": "const",
"nullable": false,
"idlType": "boolean",
"idlType": {
"type": "const-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "boolean"
"extAttrs": []
},
"name": "DEBUG",
"value": {
"type": "boolean",
Expand All @@ -481,7 +490,7 @@ The fields are as follows:

* `type`: Always "const".
* `nullable`: Whether its type is nullable.
* `idlType`: The type of the constant (a simple type, the type name).
* `idlType`: An [IDL Type](#idl-type) of the constant that represents a simple type, the type name.
* `name`: The name of the constant.
* `value`: The constant value as described by [Const Values](#default-and-const-values)
* `extAttrs`: A list of [extended attributes](#extended-attributes).
Expand All @@ -497,11 +506,13 @@ The arguments (e.g. for an operation) look like this:
"variadic": true,
"extAttrs": [],
"idlType": {
"type": "argument-type",
"sequence": false,
"generic": null,
"nullable": false,
"union": false,
"idlType": "long"
"idlType": "long",
"extAttrs": [...]
},
"name": "ints"
}]
Expand Down Expand Up @@ -546,8 +557,6 @@ The fields are as follows:
* `type`: Always `"extended-attribute"`.
* `rhs`: If there is a right-hand side, this will capture its `type` (which can be
"identifier" or "identifier-list") and its `value`.
* `typePair`: If the extended attribute is a `MapClass` this will capture the
map's key type and value type respectively.

### Default and Const Values

Expand Down Expand Up @@ -587,14 +596,6 @@ The fields are as follows:

## Testing

In order to run the tests you need to ensure that the widlproc submodule inside `test` is
initialized and up to date:

```Bash
git submodule init
git submodule update
```

### Running

The test runs with mocha and expect.js. Normally, running mocha in the root directory
Expand Down
55 changes: 55 additions & 0 deletions checker/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<title>WebIDL 2 Checker</title>

<script src='../lib/webidl2.js'></script>
<script>
let parserResult = undefined;

function formatParserOutput() {
const outputEl = document.getElementById('webidl-checker-output');
if (parserResult) {
const prettyPrintEl = document.getElementById('pretty-print');
outputEl.innerText = JSON.stringify(parserResult, null, prettyPrintEl.checked ? 2 : null);
} else {
outputEl.innerText = '';
}
}

function checkWebIDL(textToCheck) {
const validation = document.getElementById('webidl-checker-validation');
parserResult = null;
try {
parserResult = WebIDL2.parse(textToCheck);
validation.innerText = 'WebIDL parsed successfully!';
} catch (e) {
validation.innerText = 'Exception while parsing WebIDL. See JavaScript console for more details.\n\n' + e.toString();
// Pass it along to the JavaScript console.
throw e;
} finally {
formatParserOutput();
}
}
</script>
<style>
textarea {
font-family: monospace;
}
</style>
</head>
<body>
<h2>WebIDL Checker</h2>
<p>This is an online checker for WebIDL built on the <a href="https://github.com/w3c/webidl2.js">webidl2.js</a> project.</p>
<p>Enter your WebIDL to check below:</p>
<textarea id='webidl-to-check' rows='20' cols='80'></textarea>
<br>
<input type='button' value='Check WebIDL' onclick='checkWebIDL(document.getElementById("webidl-to-check").value)'>
<p>Validation results:</p>
<textarea id='webidl-checker-validation' rows='20' cols='80'></textarea>
<p>Parser output:</p>
<textarea id='webidl-checker-output' rows='20' cols='80'></textarea>
<br>
<input type='checkbox' id='pretty-print' checked='true' onchange='formatParserOutput()'>Pretty Print
</body>
</html>
Loading

0 comments on commit 7bb4c71

Please sign in to comment.