Skip to content

Commit

Permalink
Merge pull request #9 from aMarCruz/dev
Browse files Browse the repository at this point in the history
v0.2.7
  • Loading branch information
aMarCruz committed Jan 6, 2016
2 parents 719076a + f196adc commit 5f31820
Show file tree
Hide file tree
Showing 22 changed files with 13,795 additions and 306 deletions.
6 changes: 3 additions & 3 deletions .eslintignore
@@ -1,4 +1,4 @@
**/coverage/**
**/dist/**
**/spec/**
**/coverage/
**/spec/
!**/spec/*.js
**.md
18 changes: 9 additions & 9 deletions .eslintrc
Expand Up @@ -65,7 +65,7 @@ rules:
no-sparse-arrays: 2 # disallow sparse arrays
no-unreachable: 2 # disallow unreachable statements after a return, throw, continue, or break statement
use-isnan: 2 # disallow comparisons with the value NaN
valid-jsdoc: [2, { requireReturn: false }] # ensure JSDoc comments are valid, returns optional in void functions
valid-jsdoc: [2, { "requireReturn": false }] # ensure JSDoc comments are valid, returns optional in void functions
valid-typeof: 2 # ensure that the results of typeof are compared against a valid string
no-unexpected-multiline: 2 # Avoid code that looks like two expressions but is actually one

Expand All @@ -78,12 +78,12 @@ rules:
###########################################################################

block-scoped-var: 2 # treat var statements as if they were block scoped
complexity: [1, 9] # specify the maximum cyclomatic complexity allowed in a program
complexity: [1, 9] # specify the maximum cyclomatic complexity allowed in a program
consistent-return: 1 # require return statements to either always or never specify values
curly: 0 # specify curly brace conventions for all control statements
default-case: 1 # require default case in switch statements
dot-notation: 1 # encourages use of dot notation whenever possible
eqeqeq: [2, 'smart'] # require the use of === and !==
eqeqeq: [2, "smart"] # require the use of === and !==
guard-for-in: 1 # make sure for-in loops have an if statement
no-alert: 2 # disallow the use of alert, confirm, and prompt
no-caller: 2 # disallow use of arguments.caller or arguments.callee
Expand Down Expand Up @@ -142,7 +142,7 @@ rules:
no-delete-var: 2 # disallow deletion of variables
no-label-var: 2 # disallow labels that share a name with a variable
no-shadow: 2 # disallow declaration of variables already declared in the outer scope
no-shadow-restricted-names: 2 # disallow shadowing of names such as arguments
no-shadow-restricted-names: 2 # disallow shadowing of names such as arguments
no-undef: 2 # disallow use of undeclared variables unless mentioned in a /*global */ block
no-undef-init: 1 # disallow use of undefined when initializing variables
no-undefined: 2 # disallow use of undefined variable
Expand Down Expand Up @@ -173,9 +173,9 @@ rules:

linebreak-style: [2, "unix"]

indent: [2, 2, { SwitchCase: 1, VariableDeclarator: 2 }] # Set a specific tab width
brace-style: [1, "stroustrup", { allowSingleLine: true }] # enforce stroustrup brace style
camelcase: [2, properties: "always" ] # require camel case names
indent: [2, 2, { "SwitchCase": 1, "VariableDeclarator": 2 }] # Set a specific tab width
brace-style: [1, "stroustrup", { "allowSingleLine": true }] # enforce stroustrup brace style
camelcase: [2, { "properties": "always" } ] # require camel case names
comma-spacing: 2 # enforce spacing before and after comma
comma-style: 2 # enforce one true comma style
consistent-this: 1 # enforces consistent naming when capturing the current execution context
Expand All @@ -198,10 +198,10 @@ rules:
quote-props: [2, "as-needed"] # require quotes around object literal property names only if needed
quotes: [1, "single", "avoid-escape"] # specify whether double or single quotes should be used
semi: [2, "never"] # require or disallow use of semicolons instead of ASI
#semi-spacing: [2, { before: false, after: true }] # disallow space before semicolon, require after
#semi-spacing: [2, { "before": false, "after": true }] # disallow space before semicolon, require after
space-after-keywords: [2, "always"] # require a space after certain keywords
space-before-blocks: 2 # require or disallow space before blocks
space-before-function-paren: [2, { anonymous: "always", named: "never" }]
space-before-function-paren: [2, { "anonymous": "always", "named": "never" }]
#space-in-brackets: 0 # require or disallow spaces inside brackets
#space-in-parens: 0 # require or disallow spaces inside parentheses
space-infix-ops: 1 # require spaces around operators
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,7 @@ language: node_js
sudo: false

node_js:
- "5"
- "4.2"
- "4.1"
- "4.0"
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog for jspreproc

#### Version 0.2.7 - 2016-01-05
- Rewrite of the conditional comments' parser.
- Enhancement: Multiline comment with `if/ifdef/ifndef/elif/else` allows hide conditional blocks. See [doc/syntax.md](doc/syntax.md)
- Added test with uglify-js

#### Version 0.2.6 - 2015-12-03
- Fix errors when including unicode line and paragraph characters.
- Enhancement: New `sources` filer. It supports `sourceMappingURL` and `sourceMappingURL` directives.
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -19,4 +19,7 @@ lint:
@ eslint **/*.js
# Done.

utest:
@ node spec/ut.js

.PHONY: sendc cover lint debug
Empty file modified bin/jspp.js 100644 → 100755
Empty file.
29 changes: 26 additions & 3 deletions doc/syntax.md
Expand Up @@ -7,10 +7,10 @@ However, there are some differences.

Differences from the C preprocessor:

- The `#define` keyword does not works in jspreproc as in the C preprocessor and is **deprecated** in 0.2.3 -- Use the `#set` keyword instead
- The `#define` keyword does not works in jspreproc as in the C preprocessor and is **deprecated** in 0.2.3 -- Use the `#set` keyword instead
- jspreproc does not supports function-like macros or macro-substitution on the source files, out of expressions<sub>(1)</sub>
- Escaped characters remains literals, e.g. the `\n` sequence not generate end of line, it is written to the output as the string "\n"
- The evaluation of expressions by `#set/#if/#endif` is through a Function instance, so the result is the same from a JavaScript expression, in the global scope.
- Escaped characters remains literals, e.g. `\n` does not generate an end of line, it is written to the output as the string "\n"
- The evaluation of expressions by `#set/#if/#elif` is done through a Function instance, so the result is the same as for a JavaScript expression in the global scope.

<sup>(1)</sup> See [Variables Symbols](#variable-symbols) for some exceptions.

Expand Down Expand Up @@ -85,6 +85,29 @@ These are shorthands for `#if defined(SYMBOL)` and `#if !defined(SYMBOL)`.

These are the default block and closing statement keywords.

### Hiding blocks

From v0.2.7 you can hide conditional blocks using multiline comments. This syntax is valid for the `if/ifdef/ifndef/elif/else` keywords only. The opening sequence (`/*`) must comply with the same rules as the one-line conditional comments, the closing sequence (`*/`) must follow another regular conditional comment:
```js
/*#if EXPRESSION
...
//#endif */
```

Note the `//#endif`, this is a regular conditional comment, but now the parser will ignore anything in the line starting from `*/`. Tools such as minifiers or syntax highlighters will see these blocks as a regular multiline comment, which allows you to hide the block, as in this example:
```js
//#set FOO = 1

/*#if FOO == 1
var x = one()
//#elif FOO == 2
var x = two()
//#else*/
var x = other()
//#endif
```


### Includes

**`//#include filename`**
Expand Down

0 comments on commit 5f31820

Please sign in to comment.