mirror of
https://gitee.com/openharmony/developtools_ace_ets2bundle
synced 2024-12-11 18:53:59 +00:00
Signed-off-by: houhaoyu <houhaoyu@huawei.com> Change-Id: I1b2c3eb0dc703e2f613ed53a9bbcd65d148c4663
This commit is contained in:
parent
59f315a540
commit
72c3e2d41a
@ -19,13 +19,8 @@ start = extendAttributes:extendAttribute+
|
||||
}
|
||||
|
||||
extendAttribute = whiteSpace '.' whiteSpace attribute item
|
||||
|
||||
attribute = attr_head attr_tail
|
||||
|
||||
attr_head = $ [a-zA-Z_$]+
|
||||
|
||||
attr_tail = $ [a-zA-Z0-9_$]*
|
||||
|
||||
item = whiteSpace '(' [^()]* item* [^()]* ')' whiteSpace
|
||||
|
||||
whiteSpace = [ \t\r\n]*
|
@ -42,9 +42,7 @@ start = blocks: block+
|
||||
}
|
||||
|
||||
block = extend/(prefix extend?)
|
||||
|
||||
prefix = $((!prefix_extend .)+)
|
||||
|
||||
extend =
|
||||
whiteSpace1:whiteSpace prefix_extend:prefix_extend funcBody_extend:funcBody_extend
|
||||
whiteSpace2: whiteSpace right:'}' whiteSpace3:whiteSpace
|
||||
@ -80,13 +78,9 @@ prefix_extend_another =
|
||||
}
|
||||
|
||||
component = $ [a-zA-Z_]+
|
||||
|
||||
function_name = $ (function_name_head function_name_tail)
|
||||
|
||||
function_name_head = $ [a-zA-Z_$]+
|
||||
|
||||
function_name_tail = $ [a-zA-Z0-9_$]*
|
||||
|
||||
parameters = $ ([^()]* item* [^()]*)
|
||||
|
||||
//extract Extend internal attribute SyntaxError
|
||||
@ -119,5 +113,4 @@ funcBody_extend = body:($[^{}]* item* [^{}]*)
|
||||
}
|
||||
|
||||
item = $ (whiteSpace '{' [^{}]* item* [^{}]* '}' whiteSpace)
|
||||
|
||||
whiteSpace = $ [ \t\r\n]*
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
replaceResult,
|
||||
ReplaceResult,
|
||||
sourceReplace,
|
||||
validateUISyntax,
|
||||
processSystemApi
|
||||
@ -28,9 +28,9 @@ import { BUILD_ON } from './pre_define';
|
||||
function preProcess(source: string): string {
|
||||
process.env.compiler = BUILD_ON;
|
||||
if (/\.ets$/.test(this.resourcePath)) {
|
||||
const result: replaceResult = sourceReplace(source, this.resourcePath)
|
||||
const newContent: string = result.content
|
||||
const log: LogInfo[] = result.log
|
||||
const result: ReplaceResult = sourceReplace(source, this.resourcePath);
|
||||
const newContent: string = result.content;
|
||||
const log: LogInfo[] = result.log;
|
||||
log.concat(validateUISyntax(source, newContent, this.resourcePath, this.resourceQuery));
|
||||
if (log.length) {
|
||||
emitLogInfo(this, log);
|
||||
|
@ -59,7 +59,7 @@ import {
|
||||
addLog,
|
||||
hasDecorator
|
||||
} from './utils';
|
||||
const parser = require('../peg_parser/dist/index.js')
|
||||
const parser = require('../peg_parser/dist/peg_parser.js');
|
||||
|
||||
export interface ComponentCollection {
|
||||
entryComponent: string;
|
||||
@ -666,12 +666,12 @@ function collectionStates(decorator: string, name: string, states: Set<string>,
|
||||
}
|
||||
}
|
||||
|
||||
export interface replaceResult {
|
||||
export interface ReplaceResult {
|
||||
content: string,
|
||||
log: LogInfo[]
|
||||
}
|
||||
|
||||
export function sourceReplace(source: string, sourcePath: string): replaceResult {
|
||||
export function sourceReplace(source: string, sourcePath: string): ReplaceResult {
|
||||
let content: string = source;
|
||||
const log: LogInfo[] = [];
|
||||
// replace struct->class
|
||||
@ -692,27 +692,31 @@ export function sourceReplace(source: string, sourcePath: string): replaceResult
|
||||
}
|
||||
|
||||
export function preprocessExtend(content: string, sourcePath: string, log: LogInfo[]): string {
|
||||
let pegCheckContent;
|
||||
let result;
|
||||
let pegCheckContent: string;
|
||||
let result: any;
|
||||
try {
|
||||
result = parser.parse(content);
|
||||
pegCheckContent = result.content;
|
||||
for (let i=0; i<result.collect_extend.component.length; i++) {
|
||||
collectExtend(result.collect_extend.component[i], result.collect_extend.functionName[i], result.collect_extend.parameters[i]);
|
||||
for (let i = 0; i < result.collect_extend.component.length; i++) {
|
||||
collectExtend(
|
||||
result.collect_extend.component[i],
|
||||
result.collect_extend.functionName[i],
|
||||
result.collect_extend.parameters[i]
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
result = err;
|
||||
log.push({
|
||||
type: LogType.ERROR,
|
||||
message: parser.SyntaxError.buildMessage(err.expected,err.found),
|
||||
message: parser.SyntaxError.buildMessage(err.expected, err.found),
|
||||
line: err.location.start.line,
|
||||
column: err.location.start.column,
|
||||
fileName: sourcePath
|
||||
});
|
||||
pegCheckContent = content;
|
||||
}
|
||||
if(result.error_otherParsers) {
|
||||
for(let i=0; i<result.error_otherParsers.length; i++) {
|
||||
if (result.error_otherParsers) {
|
||||
for(let i = 0; i < result.error_otherParsers.length; i++) {
|
||||
log.push({
|
||||
type: LogType.ERROR,
|
||||
message: result.error_otherParsers[i].errMessage,
|
||||
|
Loading…
Reference in New Issue
Block a user