pareto-fountain-pen 0.1.41 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exceptional/serialize/block.js +2 -2
- package/dist/exceptional/serialize/semi_lines.js +8 -8
- package/dist/implementation/{procedures → algorithms/procedures}/guaranteed/console_error.d.ts +1 -1
- package/dist/implementation/{procedures → algorithms/procedures}/guaranteed/console_error.js +2 -2
- package/dist/implementation/{procedures → algorithms/procedures}/guaranteed/console_log.d.ts +1 -1
- package/dist/implementation/{procedures → algorithms/procedures}/guaranteed/console_log.js +2 -2
- package/dist/implementation/{procedures → algorithms/procedures}/unguaranteed/write_to_directory.d.ts +1 -1
- package/dist/implementation/{procedures → algorithms/procedures}/unguaranteed/write_to_directory.js +4 -4
- package/dist/implementation/{procedures → algorithms/procedures}/unguaranteed/write_to_file.d.ts +1 -1
- package/dist/implementation/{procedures → algorithms/procedures}/unguaranteed/write_to_file.js +4 -4
- package/dist/implementation/{procedures → algorithms/procedures}/unguaranteed/write_to_node.d.ts +1 -1
- package/dist/implementation/{procedures → algorithms/procedures}/unguaranteed/write_to_node.js +1 -1
- package/dist/implementation/{transformations → algorithms/transformations}/block/lines.d.ts +2 -2
- package/dist/implementation/{transformations → algorithms/transformations}/block/lines.js +1 -1
- package/dist/implementation/algorithms/transformations/block/semi_lines.d.ts +4 -0
- package/dist/implementation/{transformations → algorithms/transformations}/block/semi_lines.js +1 -1
- package/dist/implementation/{transformations → algorithms/transformations}/semi_lines/lines.d.ts +2 -2
- package/dist/implementation/algorithms/transformations/semi_lines/lines.js +45 -0
- package/dist/implementation/generated/pareto/generic/parse/ast.d.ts +10 -0
- package/dist/implementation/generated/pareto/generic/parse/ast.js +245 -0
- package/dist/implementation/generated/pareto/generic/parse/astn_parse_generic.d.ts +13 -0
- package/dist/implementation/generated/pareto/generic/parse/astn_parse_generic.js +50 -0
- package/dist/implementation/generated/pareto/generic/parse/parse.d.ts +6 -0
- package/dist/implementation/generated/pareto/generic/parse/parse.js +65 -0
- package/dist/implementation/generated/pareto/generic/parse/string_iterator.d.ts +40 -0
- package/dist/implementation/generated/pareto/generic/parse/string_iterator.js +109 -0
- package/dist/implementation/generated/pareto/generic/parse/token.d.ts +9 -0
- package/dist/implementation/generated/pareto/generic/parse/token.js +519 -0
- package/dist/implementation/generated/pareto/generic/resolve.js +7 -7
- package/dist/implementation/generated/pareto/generic/serialize.d.ts +4 -0
- package/dist/implementation/generated/pareto/generic/serialize.js +93 -0
- package/dist/implementation/generated/pareto/generic/unmarshall.d.ts +26 -26
- package/dist/implementation/generated/pareto/generic/unmarshall.js +38 -29
- package/dist/implementation/generated/pareto/schemas/block/deserialize.d.ts +7 -0
- package/dist/implementation/generated/pareto/schemas/block/deserialize.js +40 -0
- package/dist/implementation/generated/pareto/schemas/block/serialize.d.ts +7 -0
- package/dist/implementation/generated/pareto/schemas/block/serialize.js +53 -0
- package/dist/implementation/generated/pareto/schemas/lines/deserialize.d.ts +3 -0
- package/dist/implementation/generated/pareto/schemas/lines/deserialize.js +32 -0
- package/dist/implementation/generated/pareto/schemas/lines/serialize.d.ts +3 -0
- package/dist/implementation/generated/pareto/schemas/lines/serialize.js +37 -0
- package/dist/implementation/generated/pareto/schemas/semi_lines/deserialize.d.ts +3 -0
- package/dist/implementation/generated/pareto/schemas/semi_lines/deserialize.js +32 -0
- package/dist/implementation/generated/pareto/schemas/semi_lines/serialize.d.ts +3 -0
- package/dist/implementation/generated/pareto/schemas/semi_lines/serialize.js +37 -0
- package/dist/implementation/generated/pareto/schemas/text/deserialize.d.ts +3 -0
- package/dist/implementation/generated/pareto/schemas/text/deserialize.js +32 -0
- package/dist/implementation/generated/pareto/schemas/text/serialize.d.ts +3 -0
- package/dist/implementation/generated/pareto/schemas/text/serialize.js +37 -0
- package/dist/interface/algorithms/procedures/guaranteed/console_error.d.ts +1 -0
- package/dist/interface/algorithms/procedures/guaranteed/console_error.js +5 -0
- package/dist/interface/algorithms/procedures/guaranteed/console_log.d.ts +1 -0
- package/dist/interface/algorithms/procedures/guaranteed/console_log.js +5 -0
- package/dist/interface/algorithms/procedures/unguaranteed/write_to_directory.d.ts +1 -0
- package/dist/interface/algorithms/procedures/unguaranteed/write_to_directory.js +5 -0
- package/dist/interface/algorithms/procedures/unguaranteed/write_to_file.d.ts +1 -0
- package/dist/interface/algorithms/procedures/unguaranteed/write_to_file.js +5 -0
- package/dist/interface/algorithms/procedures/unguaranteed/write_to_node.d.ts +1 -0
- package/dist/interface/algorithms/procedures/unguaranteed/write_to_node.js +5 -0
- package/dist/interface/algorithms/transformations/block/lines.d.ts +1 -0
- package/dist/interface/algorithms/transformations/block/lines.js +5 -0
- package/dist/interface/algorithms/transformations/block/semi_lines.d.ts +1 -0
- package/dist/interface/algorithms/transformations/block/semi_lines.js +5 -0
- package/dist/interface/algorithms/transformations/semi_lines/lines.d.ts +1 -0
- package/dist/interface/algorithms/transformations/semi_lines/lines.js +5 -0
- package/dist/interface/generated/pareto/core/astn_source.d.ts +15 -0
- package/dist/interface/generated/pareto/core/parse_result.d.ts +25 -0
- package/dist/interface/generated/pareto/core/parse_result.js +3 -0
- package/dist/interface/generated/pareto/core/resolve.d.ts +1 -1
- package/dist/interface/generated/pareto/core/resolved.d.ts +3 -3
- package/dist/interface/generated/pareto/core/token.d.ts +49 -0
- package/dist/interface/generated/pareto/core/token.js +3 -0
- package/dist/interface/generated/pareto/schemas/block/deserialize.d.ts +158 -0
- package/dist/interface/generated/pareto/schemas/block/deserialize.js +3 -0
- package/dist/interface/generated/pareto/schemas/block/serialize.d.ts +158 -0
- package/dist/interface/generated/pareto/schemas/block/serialize.js +3 -0
- package/dist/interface/generated/pareto/schemas/lines/deserialize.d.ts +54 -0
- package/dist/interface/generated/pareto/schemas/lines/deserialize.js +3 -0
- package/dist/interface/generated/pareto/schemas/lines/serialize.d.ts +54 -0
- package/dist/interface/generated/pareto/schemas/lines/serialize.js +3 -0
- package/dist/interface/generated/pareto/schemas/semi_lines/deserialize.d.ts +54 -0
- package/dist/interface/generated/pareto/schemas/semi_lines/deserialize.js +3 -0
- package/dist/interface/generated/pareto/schemas/semi_lines/serialize.d.ts +54 -0
- package/dist/interface/generated/pareto/schemas/semi_lines/serialize.js +3 -0
- package/dist/interface/generated/pareto/schemas/text/deserialize.d.ts +54 -0
- package/dist/interface/generated/pareto/schemas/text/deserialize.js +3 -0
- package/dist/interface/generated/pareto/schemas/text/serialize.d.ts +54 -0
- package/dist/interface/generated/pareto/schemas/text/serialize.js +3 -0
- package/dist/shorthands/block.d.ts +1 -1
- package/dist/temp/temp_types.d.ts +2 -2
- package/package.json +7 -14
- package/dist/implementation/transformations/block/semi_lines.d.ts +0 -4
- package/dist/implementation/transformations/semi_lines/lines.js +0 -45
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create_astn_token_iterator = exports.throw_unexpected_token = exports.throw_lexer_error = exports.Parse_Error_Class = void 0;
|
|
4
|
+
class Parse_Error_Class {
|
|
5
|
+
type;
|
|
6
|
+
range;
|
|
7
|
+
constructor(type, range) {
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.range = range;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.Parse_Error_Class = Parse_Error_Class;
|
|
13
|
+
const throw_parse_error = (type, range) => {
|
|
14
|
+
throw new Parse_Error_Class(type, range);
|
|
15
|
+
};
|
|
16
|
+
const throw_lexer_error = (type, range) => {
|
|
17
|
+
throw new Parse_Error_Class(['lexer', type], range);
|
|
18
|
+
};
|
|
19
|
+
exports.throw_lexer_error = throw_lexer_error;
|
|
20
|
+
const throw_unexpected_token = (found, expected) => {
|
|
21
|
+
return throw_parse_error(['parser', {
|
|
22
|
+
'expected': expected,
|
|
23
|
+
'cause': ['unexpected token', {
|
|
24
|
+
'found': found.type,
|
|
25
|
+
}]
|
|
26
|
+
}], {
|
|
27
|
+
'start': found.start,
|
|
28
|
+
'end': found.end
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.throw_unexpected_token = throw_unexpected_token;
|
|
32
|
+
const create_astn_token_iterator = ($, end) => {
|
|
33
|
+
let position = 0;
|
|
34
|
+
return {
|
|
35
|
+
'get required token': (pet) => {
|
|
36
|
+
return $.__get_element_at(position).transform(($) => $, () => throw_parse_error(['parser', {
|
|
37
|
+
'expected': pet,
|
|
38
|
+
'cause': ['missing token', null]
|
|
39
|
+
}], {
|
|
40
|
+
'start': end,
|
|
41
|
+
'end': end,
|
|
42
|
+
}));
|
|
43
|
+
},
|
|
44
|
+
'consume token': () => {
|
|
45
|
+
position += 1;
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
exports.create_astn_token_iterator = create_astn_token_iterator;
|
|
50
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXN0bl9wYXJzZV9nZW5lcmljLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2ltcGxlbWVudGF0aW9uL2dlbmVyYXRlZC9wYXJldG8vZ2VuZXJpYy9wYXJzZS9hc3RuX3BhcnNlX2dlbmVyaWMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBUUEsTUFBYSxpQkFBaUI7SUFHTjtJQUNBO0lBRnBCLFlBQ29CLElBQXlDLEVBQ3pDLEtBQXVCO1FBRHZCLFNBQUksR0FBSixJQUFJLENBQXFDO1FBQ3pDLFVBQUssR0FBTCxLQUFLLENBQWtCO0lBRTFDLENBQUM7Q0FDTDtBQVBELDhDQU9DO0FBRUQsTUFBTSxpQkFBaUIsR0FBRyxDQUN0QixJQUF5QyxFQUN6QyxLQUF1QixFQUNsQixFQUFFO0lBQ1AsTUFBTSxJQUFJLGlCQUFpQixDQUFDLElBQUksRUFBRSxLQUFLLENBQUMsQ0FBQTtBQUM1QyxDQU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QUU7b0JBQ1AsVUFBVSxFQUFFLEdBQUc7b0JBQ2YsT0FBTyxFQUFFLENBQUMsZUFBZSxFQUFFLElBQUksQ0FBQztpQkFDbkMsQ0FBQyxFQUNGO2dCQUNJLE9BQU8sRUFBRSxHQUFHO2dCQUNaLEtBQUssRUFBRSxHQUFHO2FBQ2IsQ0FDSixDQUNKLENBQUE7UUFDTCxDQUFDO1FBQ0QsZUFBZSxFQUFFLEdBQUcsRUFBRTtZQUNsQixRQUFRLElBQUksQ0FBQyxDQUFBO1FBQ2pCLENBQUM7S0FDSixDQUFBO0FBQ0wsQ0FBQyxDQUFBO0FBdEJZLFFBQUEsMEJBQTBCLDhCQXNCdEMifQ==
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as _ea from 'exupery-core-alg';
|
|
2
|
+
import * as _target from "../../../../../interface/generated/pareto/core/parse_result";
|
|
3
|
+
import * as s_ast from "../../../../../interface/generated/pareto/core/astn_source";
|
|
4
|
+
export declare const parse: ($: string, $p: {
|
|
5
|
+
"tab size": number;
|
|
6
|
+
}) => _ea.Refinement_Result<s_ast._T_Document, _target._T_Parse_Error>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.parse = void 0;
|
|
27
|
+
const _ea = __importStar(require("exupery-core-alg"));
|
|
28
|
+
const d_ast = __importStar(require("./ast"));
|
|
29
|
+
const pg = __importStar(require("./astn_parse_generic"));
|
|
30
|
+
const si = __importStar(require("./string_iterator"));
|
|
31
|
+
const tokenize = __importStar(require("./token"));
|
|
32
|
+
const parse = ($, $p) => {
|
|
33
|
+
try {
|
|
34
|
+
const string_iterator = si.create_string_iterator($, {
|
|
35
|
+
'tab size': $p['tab size']
|
|
36
|
+
});
|
|
37
|
+
const tokenizer_result = tokenize.Tokenizer_Result(null, {
|
|
38
|
+
'string iterator': string_iterator
|
|
39
|
+
});
|
|
40
|
+
// tokenizer_result.tokens.__for_each(($) => {
|
|
41
|
+
// _edev.log_debug_message(`token: ${_ea.cc($.type, ($) => {
|
|
42
|
+
// switch ($[0]) {
|
|
43
|
+
// case 'string': return _ea.ss($, ($) => `string: ${$.value.value}`)
|
|
44
|
+
// default: return `structural: ${$[0]}`
|
|
45
|
+
// }
|
|
46
|
+
// })}`)
|
|
47
|
+
// })
|
|
48
|
+
const token_iterator = pg.create_astn_token_iterator(tokenizer_result.tokens, tokenizer_result.end);
|
|
49
|
+
return _ea.refinement.successful(d_ast.Document(token_iterator));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error instanceof pg.Parse_Error_Class) {
|
|
53
|
+
return _ea.refinement.failed({
|
|
54
|
+
'type': error.type,
|
|
55
|
+
'range': {
|
|
56
|
+
'start': error.range.start,
|
|
57
|
+
'end': error.range.end,
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return _ea.deprecated_panic("unknown error thrown");
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.parse = parse;
|
|
65
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyc2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvaW1wbGVtZW50YXRpb24vZ2VuZXJhdGVkL3BhcmV0by9nZW5lcmljL3BhcnNlL3BhcnNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsc0RBQXVDO0FBR3ZDLDZDQUE4QjtBQUk5Qix5REFBMEM7QUFDMUMsc0RBQXVDO0FBRXZDLGtEQUFtQztBQUc1QixNQUFNLEtBQUssR0FBRyxDQUNqQixDQUFTLEVBQ1QsRUFFQyxFQUMrRCxFQUFFO0lBQ2xFLElBQUksQ0FBQztRQUNELE1BQU0sZUFBZSxHQUFHLEVBQUUsQ0FBQyxzQkFBc0IsQ0FBQyxDQUFDLEVBQUU7WUFDakQsVUFBVSxFQUFFLEVBQUUsQ0FBQyxVQUFVLENBQUM7U0FDN0IsQ0FBQyxDQUFBO1FBQ0YsTUFBTSxnQkFBZ0IsR0FBRyxRQUFRLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxFQUFFO1lBQ3JELGlCQUFpQixFQUFFLGVBQWU7U0FDckMsQ0FBQyxDQUFBO1FBQ0YsOENBQThDO1FBQzlDLGdFQUFnRTtRQUNoRSwwQkFBMEI7UUFDMUIsaUZBQWlGO1FBQ2pGLG9EQUFvRDtRQUNwRCxZQUFZO1FBQ1osWUFBWTtRQUNaLEtBQUs7UUFDTCxNQUFNLGNBQWMsR0FBRyxFQUFFLENBQUMsMEJBQTBCLENBQUMsZ0JBQWdCLENBQUMsTUFBTSxFQUFFLGdCQUFnQixDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQ25HLE9BQU8sR0FBRyxDQUFDLFVBQVUsQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDLFFBQVEsQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFBO0lBRXBFLENBQUM7SUFBQyxPQUFPLEtBQUssRUFBRSxDQUFDO1FBQ2IsSUFBSSxLQUFLLFlBQVksRUFBRSxDQUFDLGlCQUFpQixFQUFFLENBQUM7WUFFeEMsT0FBTyxHQUFHLENBQUMsVUFBVSxDQUFDLE1BQU0sQ0FBQztnQkFDekIsTUFBTSxFQUFFLEtBQUssQ0FBQyxJQUFJO2dCQUNsQixPQUFPLEVBQUU7b0JBQ0wsT0FBTyxFQUFFLEtBQUssQ0FBQyxLQUFLLENBQUMsS0FBSztvQkFDMUIsS0FBSyxFQUFFLEtBQUssQ0FBQyxLQUFLLENBQUMsR0FBRztpQkFDekI7YUFDSixDQUFDLENBQUE7UUFDTixDQUFDO1FBQ0QsT0FBTyxHQUFHLENBQUMsZ0JBQWdCLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtJQUN2RCxDQUFDO0FBQ0wsQ0FBQyxDQUFBO0FBckNZLFFBQUEsS0FBSyxTQXFDakIifQ==
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as _et from 'exupery-core-types';
|
|
2
|
+
export type Location = {
|
|
3
|
+
'absolute': number;
|
|
4
|
+
'relative': {
|
|
5
|
+
'line': number;
|
|
6
|
+
'column': number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export type String_Iterator = {
|
|
10
|
+
'consume character': () => void;
|
|
11
|
+
'consume string': ($: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* returns the current character, or null if the end of the string has been reached.
|
|
14
|
+
* equivalent to `look ahead(0)`
|
|
15
|
+
*/
|
|
16
|
+
'get current character': () => number | null;
|
|
17
|
+
'look ahead': ($: number) => number | null;
|
|
18
|
+
'create offset location info': (subtract: number) => Location;
|
|
19
|
+
'create location info': () => Location;
|
|
20
|
+
'create location info string': () => string;
|
|
21
|
+
/**
|
|
22
|
+
* if no non-whitespace character has been found yet on the current line,
|
|
23
|
+
* this will return the current column,
|
|
24
|
+
* otherwise it will return the offset of that first non-whitespace character
|
|
25
|
+
* (which is the indentation of the line)
|
|
26
|
+
*/
|
|
27
|
+
'get line indentation': () => number;
|
|
28
|
+
};
|
|
29
|
+
export declare const is_control_character: ($: number) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a string iterator that allows iterating over characters in a string,
|
|
32
|
+
* while keeping track of line numbers, columns, and line indentation.
|
|
33
|
+
*/
|
|
34
|
+
export declare const create_string_iterator: ($: string, $p: {
|
|
35
|
+
"tab size": number;
|
|
36
|
+
}) => String_Iterator;
|
|
37
|
+
export type Token_Iterator<Expected, Token> = {
|
|
38
|
+
'get required token': (expected: _et.Array<Expected>) => Token;
|
|
39
|
+
'consume token': () => void;
|
|
40
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create_string_iterator = exports.is_control_character = void 0;
|
|
4
|
+
const to_character_list_1 = require("exupery-standard-library/dist/implementation/algorithms/operations/impure/text/to_character_list");
|
|
5
|
+
const WhitespaceChars = {
|
|
6
|
+
tab: 0x09, // \t
|
|
7
|
+
line_feed: 0x0A, // \n
|
|
8
|
+
carriage_return: 0x0D, // \r
|
|
9
|
+
space: 0x20, //
|
|
10
|
+
};
|
|
11
|
+
const is_control_character = ($) => {
|
|
12
|
+
return ($ < 0x20 && $ !== WhitespaceChars.tab && $ !== WhitespaceChars.line_feed && $ !== WhitespaceChars.carriage_return);
|
|
13
|
+
};
|
|
14
|
+
exports.is_control_character = is_control_character;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a string iterator that allows iterating over characters in a string,
|
|
17
|
+
* while keeping track of line numbers, columns, and line indentation.
|
|
18
|
+
*/
|
|
19
|
+
const create_string_iterator = ($, $p) => {
|
|
20
|
+
const source = $;
|
|
21
|
+
const characters = (0, to_character_list_1.$$)($);
|
|
22
|
+
const length = characters.__get_number_of_elements();
|
|
23
|
+
let found_carriage_return_before = false;
|
|
24
|
+
let position = 0;
|
|
25
|
+
let relative_position = {
|
|
26
|
+
'line': 0,
|
|
27
|
+
'column': 0,
|
|
28
|
+
'line indentation': null
|
|
29
|
+
};
|
|
30
|
+
const consume_character = () => {
|
|
31
|
+
const c = characters.__get_element_at(position);
|
|
32
|
+
const start = relative_position;
|
|
33
|
+
relative_position = c.transform(($) => {
|
|
34
|
+
return $ === WhitespaceChars.line_feed
|
|
35
|
+
? {
|
|
36
|
+
'line': relative_position.line + 1,
|
|
37
|
+
'column': 0,
|
|
38
|
+
'line indentation': null,
|
|
39
|
+
}
|
|
40
|
+
: found_carriage_return_before
|
|
41
|
+
? {
|
|
42
|
+
'line': relative_position.line + 1,
|
|
43
|
+
'column': 0,
|
|
44
|
+
'line indentation': null,
|
|
45
|
+
}
|
|
46
|
+
: {
|
|
47
|
+
'line': relative_position.line,
|
|
48
|
+
'column': relative_position['column'] + ($ === WhitespaceChars.tab
|
|
49
|
+
? $p['tab size']
|
|
50
|
+
: 1),
|
|
51
|
+
'line indentation': relative_position['line indentation'] !== null
|
|
52
|
+
? relative_position['line indentation']
|
|
53
|
+
: $ === WhitespaceChars.space || $ === WhitespaceChars.tab
|
|
54
|
+
? null
|
|
55
|
+
: relative_position['column'],
|
|
56
|
+
};
|
|
57
|
+
}, () => relative_position //this is weird, we were already at the end of the list
|
|
58
|
+
);
|
|
59
|
+
found_carriage_return_before = c.transform(($) => $ === WhitespaceChars.carriage_return, () => false);
|
|
60
|
+
position += 1;
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
'consume string': ($) => {
|
|
64
|
+
(0, to_character_list_1.$$)($).__for_each(() => {
|
|
65
|
+
consume_character();
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
'consume character': consume_character,
|
|
69
|
+
'get current character': () => {
|
|
70
|
+
if (position === length) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return characters.__get_element_at(position).transform(($) => $, () => null);
|
|
74
|
+
},
|
|
75
|
+
'look ahead': ($) => {
|
|
76
|
+
const next_position = position + $;
|
|
77
|
+
if (next_position >= length) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return characters.__get_element_at(next_position).transform(($) => $, () => null);
|
|
81
|
+
},
|
|
82
|
+
'create location info': () => {
|
|
83
|
+
return {
|
|
84
|
+
'absolute': position,
|
|
85
|
+
'relative': {
|
|
86
|
+
'line': relative_position.line,
|
|
87
|
+
'column': relative_position['column'],
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
'create offset location info': (subtract) => {
|
|
92
|
+
return {
|
|
93
|
+
'absolute': position - subtract,
|
|
94
|
+
'relative': {
|
|
95
|
+
'line': relative_position.line,
|
|
96
|
+
'column': relative_position['column'] - subtract,
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
'create location info string': () => `${relative_position.line}:${relative_position['column']}`,
|
|
101
|
+
'get line indentation': () => {
|
|
102
|
+
return relative_position['line indentation'] !== null
|
|
103
|
+
? relative_position['line indentation']
|
|
104
|
+
: relative_position['column'];
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
exports.create_string_iterator = create_string_iterator;
|
|
109
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RyaW5nX2l0ZXJhdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2ltcGxlbWVudGF0aW9uL2dlbmVyY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PQUFPLGlCQUFpQixDQUFDLGtCQUFrQixDQUFDLEtBQUssSUFBSTtnQkFDakQsQ0FBQyxDQUFDLGlCQUFpQixDQUFDLGtCQUFrQixDQUFDO2dCQUN2QyxDQUFDLENBQUMsaUJBQWlCLENBQUMsUUFBUSxDQUFDLENBQUE7UUFDckMsQ0FBQztLQUNKLENBQUE7QUFDTCxDQUFDLENBQUE7QUFsSFksUUFBQSxzQkFBc0IsMEJBa0hsQyJ9
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _out from "../../../../../interface/generated/pareto/core/token";
|
|
2
|
+
import { String_Iterator } from "./string_iterator";
|
|
3
|
+
export declare const Whitespace: (string_iterator: String_Iterator) => _out._T_Whitespace;
|
|
4
|
+
export declare const Trivia: (string_iterator: String_Iterator) => _out._T_Trivia;
|
|
5
|
+
export declare const Annotated_Token: (st: String_Iterator) => _out._T_Annotated_Token;
|
|
6
|
+
export declare const Delimited_String: (string_iterator: String_Iterator, is_end_character: (character: number) => boolean, allow_newlines: boolean) => _out._T_Delimited_String;
|
|
7
|
+
export declare const Tokenizer_Result: ($: null, $p: {
|
|
8
|
+
"string iterator": String_Iterator;
|
|
9
|
+
}) => _out._T_Tokenizer_Result;
|