1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | const Parser = require( "./boilerplate.view.parser.constructor" );
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | require( "./boilerplate.view.parser.names" )( Parser );
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | Parser.prototype.parse = parser_parse;
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | Parser.prototype.parseViewAttribs = parser_parseViewAttribs;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | require( "./boilerplate.view.parser.parseConverter" )( Parser );
|
48 |
|
49 | module.exports = Parser;
|
50 |
|
51 |
|
52 | const Util = require( "./boilerplate.util" );
|
53 |
|
54 | const RX_VIEW_ATTRIB = /^[a-z](-[a-z0-9]+)*$/;
|
55 |
|
56 |
|
57 | function parser_parse( xjs ) {
|
58 | try {
|
59 | throw Error( "Not implemented!" );
|
60 | } catch ( ex ) {
|
61 | Util.throwError( "Error in module `boilerplate.view.parser`", ex );
|
62 | }
|
63 | }
|
64 |
|
65 | function parser_parseViewAttribs( attribs ) {
|
66 | try {
|
67 | var attribName, attribValue;
|
68 | for ( attribName in attribs ) {
|
69 | attribValue = attribs[ attribName ];
|
70 | parser_parseViewAttribs_parseAttrib.call( this, attribName, attribValue );
|
71 | }
|
72 | } catch ( ex ) {
|
73 | Util.throwError( "Error while parsing `view.attribs`", ex );
|
74 | }
|
75 | }
|
76 |
|
77 | function parser_parseViewAttribs_parseAttrib( attribName, attribValue ) {
|
78 | parser_parseViewAttribs_parseAttrib_check( attribName, attribValue );
|
79 |
|
80 | try {
|
81 | var type = attribValue[ '0' ].toLowerCase();
|
82 | if ( CONVERTERS.indexOf( type ) > -1 )
|
83 | return parser_parseViewAttribs_parseAttrib_simple.call( this, type );
|
84 | } catch ( ex ) {
|
85 | Util.throwError( "Error while parsing attribute `" + attribName + "`", ex );
|
86 | }
|
87 | }
|
88 |
|
89 | function parser_parseViewAttribs_parseAttrib_simple( type ) {
|
90 | var varName = this.parseConverter( type );
|
91 | }
|
92 |
|
93 | function parser_parseViewAttribs_parseAttrib_check( attribName, attribValue ) {
|
94 | if ( !RX_VIEW_ATTRIB.test( attribName ) ) {
|
95 | throw "`" + attribName +
|
96 | "` is not a valid attribute name. Examples of valid names are: `x`, `orientation`, `is-enabled`.";
|
97 | }
|
98 | if ( !Util.isSpecial( attribValue ) && !Array.isArray( attribValue[ '0' ] ) ) {
|
99 | throw "`" + attribName + "` must be a special object";
|
100 | }
|
101 | } |
\ | No newline at end of file |