walt-syntax
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -7,3 +7,104 @@ (function (global, factory) { | ||
const keyword = [ | ||
// EcmaScript | ||
'break', | ||
'if', | ||
'else', | ||
'import', | ||
'as', | ||
'from', | ||
'export', | ||
'return', | ||
'switch', | ||
'case', | ||
'default', | ||
'const', | ||
'let', | ||
'for', | ||
'continue', | ||
'do', | ||
'while', | ||
'function', | ||
// s-expression | ||
'global', | ||
'module', | ||
'type', | ||
'lambda', | ||
]; | ||
const punctuator = [ | ||
'+', | ||
'++', | ||
'-', | ||
'--', | ||
'>>', | ||
'>>>', | ||
'<<', | ||
'=', | ||
'==', | ||
'+=', | ||
'-=', | ||
'=>', | ||
'<=', | ||
'>=', | ||
'!=', | ||
'%', | ||
'*', | ||
'/', | ||
'^', | ||
'&', | ||
'~', | ||
'|', | ||
'!', | ||
'**', | ||
':', | ||
'(', | ||
')', | ||
'.', | ||
'{', | ||
'}', | ||
',', | ||
'[', | ||
']', | ||
';', | ||
'>', | ||
'<', | ||
'?', | ||
'||', | ||
'&&', | ||
'{', | ||
'}', | ||
'...', | ||
]; | ||
const type = ['i32', 'i64', 'f32', 'f64', 'bool']; | ||
const tokens = { | ||
whitespace: /[ \t]+/, | ||
comment: [{ match: /\/\/.*?$/ }, { match: /\/\*.*?\*\// }], | ||
number: [ | ||
{ match: /0[xX][0-9a-fA-F]+/ }, | ||
{ match: /0[oO][0-9]+/ }, | ||
{ match: /0[bB][01]+/ }, | ||
{ match: /(?:[0-9]+(?:\.[0-9]+)?e-?[0-9]+)/ }, | ||
{ match: /[0-9]+\.[0-9]+|[0-9]+/ }, | ||
], | ||
char: [ | ||
{ match: /'(?:\\['\\bfnrtv0]|[^'\\\n])'/, value: x => x.slice(1, -1) }, | ||
], | ||
string: [ | ||
{ match: /"(?:\\["\\rn]|[^"\\\n])*?"/, value: x => x.slice(1, -1) }, | ||
{ match: /'(?:\\['\\bfnrtv0]|[^'\\\n])*?'/, value: x => x.slice(1, -1) }, | ||
{ match: /`(?:\\['\\bfnrtv0]|[^'\\])*?`/, value: x => x.slice(1, -1) }, | ||
], | ||
identifier: { | ||
match: /[A-Za-z_$][A-Za-z0-9_$]*/, | ||
keywords: { keyword, type }, | ||
}, | ||
punctuator, | ||
newline: { match: /\n/, lineBreaks: true }, | ||
}; | ||
// Main Program | ||
const Program = 'Program'; | ||
@@ -244,2 +345,3 @@ const Keyword = 'Keyword'; | ||
exports.default = index; | ||
exports.tokens = tokens; | ||
@@ -246,0 +348,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "walt-syntax", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Walt Syntax", | ||
@@ -8,3 +8,5 @@ "main": "dist/walt-syntax.js", | ||
"test": "ava", | ||
"build": "cross-env node_modules/rollup/bin/rollup -c rollup.config.js" | ||
"build": "cross-env node_modules/rollup/bin/rollup -c rollup.config.js", | ||
"preversion": "npm run build", | ||
"lint": "eslint" | ||
}, | ||
@@ -30,8 +32,10 @@ "repository": { | ||
"ava": "0.24.0", | ||
"babel-eslint": "^9.0.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-register": "^6.26.0", | ||
"cross-env": "^5.2.0", | ||
"eslint": "^5.0.0", | ||
"eslint": "^5.4.0", | ||
"husky": "0.14.3", | ||
"lint-staged": "6.0.0", | ||
"moo": "^0.4.3", | ||
"prettier": "1.9.2", | ||
@@ -38,0 +42,0 @@ "rollup": "^0.64.1" |
// Main Program | ||
export { tokens } from './tokens'; | ||
export const Program = 'Program'; | ||
@@ -3,0 +5,0 @@ export const Keyword = 'Keyword'; |
33058
10
630
11