Skip to content

Commit

Permalink
SHOULD ONLY BE MERGED AFTER typescript 2.0 is out.
Browse files Browse the repository at this point in the history
Uses UMD module syntax which only works with typescript 2+

Use typings property in package.json

relates to #251
  • Loading branch information
bd82 committed Aug 9, 2016
1 parent bf9a09b commit 40086b8
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/language_services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"xregexp": "^3.1.1"
},
"devDependencies": {
"typescript": "~1.8.10",
"typescript": "^2.0.0",
"chai": "^3.4.1",
"grunt": "^1.0.1",
"grunt-cli": "~1.2.0",
Expand Down
3 changes: 0 additions & 3 deletions examples/language_services/src/env.ts

This file was deleted.

16 changes: 3 additions & 13 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,27 +238,17 @@ module.exports = function(grunt) {
options: {
// TODO: seems like the HashTable class may need to be included in the public API
banner: banner + '\n' +
'declare namespace chevrotain {\n' +
' class HashTable<V>{}\n ',
'export as namespace chevrotain;\n' +
'declare class HashTable<V>{}\n',

process: function processDefinitions(src, filePath) {
var withOutImports = src.replace(/import.*;(\n|\r\n)/g, '')
// TODO: investigate why do Typescript definition files include private members.
var withoutPrivate = withOutImports.replace(/private.*;(\n|\r\n)/g, '')

// need to remove inner declares as we are wrapping in a namespace
var withoutDeclare = withoutPrivate.replace(/declare /g, '')
var fixedInnerIdent = withoutDeclare.replace(/(\r\n|\n)/g, grunt.util.linefeed + fourSpaces)
return fixedInnerIdent
return withoutPrivate
},

// this syntax allows usage of chevrotain.d.ts from either
// ES6 modules / older namespaces style in typescript.
footer: '\n}\n\n' +
'declare module "chevrotain" {\n' +
' export = chevrotain;\n' +
'}\n',

// extra spaces needed to fix indentation.
separator: grunt.util.linefeed + fourSpaces
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@
"requirejs": "2.2.0",
"semver": "^5.3.0",
"tslint": "^3.13.0",
"typescript": "~1.8.10",
"typescript": "^2.0.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1",
"wrench": "^1.5.9"
}
},
"typings": "lib/chevrotain.d.ts"
}
3 changes: 2 additions & 1 deletion src/parse/grammar/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export function validateGrammar(topLevels:gast.Rule[], maxLookahead:number, igno
let ambiguousAltsErrors = map(topLevels, currTopRule =>
validateAmbiguousAlternationAlternatives(currTopRule, maxLookahead, ignoredIssues))

return <any>utils.flatten(duplicateErrors.concat(leftRecursionErrors, emptyAltErrors, ambiguousAltsErrors))
return <any>utils.flatten(
duplicateErrors.concat(<any>leftRecursionErrors, <any>emptyAltErrors, <any>ambiguousAltsErrors))
}

function validateDuplicateProductions(topLevelRule:gast.Rule):IParserDuplicatesDefinitionError[] {
Expand Down
4 changes: 2 additions & 2 deletions test/parse/gast_builder_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe("The GAst Builder namespace", () => {
})

it("can build a Terminal Production from a RangeProd", () => {
gastBuilder.terminalNameToConstructor = <any>tok
(gastBuilder as any).terminalNameToConstructor = <any>tok
let actual = buildProdGast({
range: new Range(1, 2),
text: "this.CONSUME2(IdentTok)",
Expand All @@ -282,7 +282,7 @@ describe("The GAst Builder namespace", () => {
})

it("will fail building a terminal if it cannot find it's constructor", () => {
gastBuilder.terminalNameToConstructor = {}
(gastBuilder as any).terminalNameToConstructor = {}
let buildMissingTerminal = () => buildProdGast({
range: new Range(1, 2),
text: "this.CONSUME2(IdentTok)",
Expand Down
3 changes: 1 addition & 2 deletions test_integration/definitions/es6_modules.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference path="../../lib/chevrotain.d.ts" />
import {Parser, Lexer, gast} from "chevrotain"
import {Parser, Lexer, gast} from "../../lib/chevrotain"

/**
* This File will be compiled using TSC to verify that the custom build chevrotain.d.ts
Expand Down

0 comments on commit 40086b8

Please sign in to comment.