Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Forked from Inviz/parser.js
Created March 20, 2012 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save subtleGradient/2139456 to your computer and use it in GitHub Desktop.
Save subtleGradient/2139456 to your computer and use it in GitHub Desktop.
var regexp = LSD.RegExp({
'fn_tail': '\\.',
'fn_arguments': '\\g<inside_round>',
'fn_name': '\\g<unicode>',
'fn': '\\g<fn_tail>?\\g<fn_name>\\(\\g<fn_arguments>\\)',
'block_arguments': '\\g<inside_curly>',
'block_body': '\\g<inside_curly>',
'block': '\\{\\g<block_arguments>?\\g<block_body>\\}',
'double_string': '"((?:[^"]|\\")*)"/',
'single_string': "'((?:[^']|\\')*)'",
'string': '\\g<double_string>|\\g<single_string>'
'whitespace': '\\s+',
'comma': ',',
'semicolon': ';',
'separator': '(\\g<whitespace>|\\g<comma>|\\g<semicolon>)'
'index': '\\[\\s*\\g<inside_square>\\s*\\]',
'token_tail': '\\.',
'token_name': '\\g<unicode>',
'token': '\\g<token_tail>?\\g<token_name>',
'length_number': '[-+]?(?:\\d+\\.\\d*|\\d*\\.\\d+)'
'length_unit': 'em|px|pt|%|fr|deg|(?=$|[^a-zA-Z0-9.])'
'length': '\\g<length_number>\\g<length_unit>',
'operator': '([-+]|[\\/%^~=><*\\^!|&$]+)'
}, {
fn: function(tail, name, args) {
},
block: function(args, body) {
},
index: function(content) {
},
token: function(name) {
},
length: function(number, unit) {
},
operator: function(name) {
},
separator: function(token) {
switch (token) {
case ';':
break;
case ',':
break;
}
}
})
var results = regexp.exec(string);
@subtleGradient
Copy link
Author

This is what it would look like using 'Subexp call ("Tanaka Akira special")'.
Cf. http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt #9

@Inviz
Copy link

Inviz commented Mar 20, 2012

Yeah, perhaps it makes sense to try to follow someone else's syntax. Although \g really adds some mess around to what already is hard to read.
Thanks, i'll keep it in mind and change the subgroups to square brackets thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment