Jean-Damien Durand > MarpaX-Languages-ECMAScript-AST > MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Pattern::Semantics

Download:
MarpaX-Languages-ECMAScript-AST-0.018.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.018   Source  

NAME ^

MarpaX::Languages::ECMAScript::AST::Grammar::ECMAScript_262_5::Pattern::Semantics - ECMAScript 262, Edition 5, pattern grammar default semantics package

VERSION ^

version 0.018

DESCRIPTION ^

This modules provide default host implementation for the actions associated to ECMAScript_262_5 pattern grammar.

new($class)

Instantiate a new object. The value will be a perl subroutine closure that returns a perl representation of a "MatchResult"; i.e. either a "State", either the perl's undef. A "State" is an ordered pair of [$endIndex, $captures] where $endIndex is an integer, and $captures is array reference whose length is the number of capturing parenthesis, holdign the result of the capture as perl strings. Note, however, that these perl strings are constructed using $str->charAt($index) method.

It will be the responsability of the caller to coerce back into host's representations of array and strings.

The perl subroutine closure will have four parameters: $str, $index, $multiline and $ignoreCase:

$str

perl's string. Typically this will JavaScript's String.prototype.valueOf() on JavaScript's string.

$index

perl's scalar. Typically Number.prototype.valueOf() on JavaScript's number.

$mutiline

perl's scalar boolean, saying if this is a multiline match. Default is a false value.

$ignoreCase

perl's scalar boolean, saying if this is an insensitive match. Default is a false value.

$upperCase

CODE reference to a function that take a single argument, a code point, and returns its upper case version. Default to a builtin subroutine reference that returns Unicode's uppercase.

This new routine is instanciated by a call to Marpa as a "semantics_package" recognizer option, and until one can pass directly arguments to it, it is using the localized variable $MarpaX::Languages::ECMAScript::AST::Grammar::Pattern::lparen, that is an array reference of left-parenthesis capture disjunctions's offsets.

Please note the a SyntaxError error can be thrown.

It will be the responsability of the caller to coerce back into host's representations of array and strings.

Internally the closures are overwriting explicitely the two internal variables __input__ and __inputLength__.

lparen($self)

Return an array reference of left-parenthesis capture disjunction's offsets.

NOTE ^

The only deviation from the standard is what I believe is an error in the ECMA-262-5 specification for Term :: Assertion. The assertion is of two types, and assertion tester and an internal matcher, while the spec assumes this is always an assertion tester. The internal matcher is when an assertion is a disjunction lookahead. In such Term :: Assertion is modified to call this matcher below and return its result.

AUTHOR ^

Jean-Damien Durand <jeandamiendurand@free.fr>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Jean-Damien Durand.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: