1.0.23 • Published 2 years ago
nv-lex-lrquoted v1.0.23
nv-lex-lrquoted
- nv-lex-lrquoted
- split lrquoted before unescape/handle the lrquoted-content lquote-content-rquote
install
- npm install nv-lex-lrquoted
usage
const {parse,split} = require("nv-lex-lrquoted");
example
split
var chunk = `
a"bcd" %%ef%% """gh"""i
/*
jk
lm
*/ #if nopq #endif <!--rrrsssttt-->
##`
const DFLT_QPAIRS = [
////
["'","'"],
["'''","'''"],
['"','"'],
['"""','"""'],
['`','`'],
['%%','%%'],
['###','###'],
////
['//','\n'],
['//',String.fromCodePoint(8232)],
['//',String.fromCodePoint(8233)],
['/*','*/'],
['<','>'],
['<!--','-->'],
['{-','-}'],
['(*','*)'],
['<%--','--%>'],
['%(','%)'],
['#|','|#'],
['#=','=#'],
['#if','#endif'],
["--[[","--]]"]
]
const {split} = require("./index");
var rslt = split(chunk,DFLT_QPAIRS)
> rslt
[
[
'\na', '"bcd"',
' ', '%%ef%%',
' ', '"""gh"""',
'i \n', '/*\njk\nlm\n*/',
' ', '#if nopq #endif',
' ', '<!--rrrsssttt-->',
'\n'
],
[],
'##'
]
>
parse
const {lexq_parse_with_pairs} = require("./index");
var [toks,lefted] = lexq_parse_with_pairs(chunk,DFLT_QPAIRS)
> lefted
'##'
>
var [ntoks,nlefted] = parse(toks)
> ntoks
[
RawTok { type: 10, raw: '\na' },
QuotedTok { type: 100, lq: '"', rq: '"', q: '"', str: 'bcd' },
RawTok { type: 10, raw: ' ' },
QuotedTok { type: 100, lq: '%%', rq: '%%', q: '%%', str: 'ef' },
RawTok { type: 10, raw: ' ' },
QuotedTok { type: 100, lq: '"""', rq: '"""', q: '"""', str: 'gh' },
RawTok { type: 10, raw: 'i \n' },
QuotedTok {
type: 100,
lq: '/*',
rq: '*/',
q: '/*',
str: '\njk\nlm\n'
},
RawTok { type: 10, raw: ' ' },
QuotedTok {
type: 100,
lq: '#if',
rq: '#endif',
q: '#if',
str: ' nopq '
},
RawTok { type: 10, raw: ' ' },
QuotedTok {
type: 100,
lq: '<!--',
rq: '-->',
q: '<!--',
str: 'rrrsssttt'
},
RawTok { type: 10, raw: '\n' }
]
>
> nlefted
[]
>
API
split(chunk:String,quote_pair_array:Array<String,String>):Array,...lefted
parse(toks:Array,quote_pair_array:Array<String,String>):Array,Array //toks and lefted-toks
DFLT_QPAIRS
- TOK_TYPE_MD
LICENSE
- ISC
1.0.22
2 years ago
1.0.23
2 years ago
1.0.20
3 years ago
1.0.19
3 years ago
1.0.18
3 years ago
1.0.17
3 years ago
1.0.15
3 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.12
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.1
3 years ago