Skip to content

Доработан парсер#1

Merged
mwmaleks merged 12 commits intowbrfrom
parcer
Aug 19, 2017
Merged

Доработан парсер#1
mwmaleks merged 12 commits intowbrfrom
parcer

Conversation

@markitosha
Copy link
Copy Markdown
Owner

No description provided.

@mwmaleks
Copy link
Copy Markdown
Collaborator

@markitosha давай сделаем пулл на wbr ветку?

@markitosha markitosha changed the base branch from master to wbr August 14, 2017 13:59
Comment thread test/html.js Outdated

it('should parse "<DIV><a><img/></A><p></P></div>.." fast', function() {

console.time('timer');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timer

Comment thread test/html.js

describe('Matcher', function() {

it('should match corrent elements', function() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha а почему ты убрала этот тесткейс?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потому что я целиком убрала класс Matcher. Он нужен был для работы querySelector, но так как мы проходимся по всему дереву когда собираем html, то им мы не пользуемся

Comment thread index.js Outdated
return makeState(IS_SELF_CLOSING, match, bracketStack);
}

match[3] += sym;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha зачем тут тоже эта операция?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

потому что символ '/' вполне себе может оказаться внутри атрибутов. Если у нас счетчик открытых скобок не равен 1, значит он точно лежит внутри атрибута и надо его добавить в строку атрибутов

Comment thread index.js
default:
match[3] += sym;
return makeState(READ_ATTRIBUTES, match, bracketStack);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha тут точно нужно что бы в случае case '<' выполнялся default

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, добавила комментарий

Comment thread index.js
exec: function (str) {
var state = {
state: INITIAL,
match: ['', '', '', '', ''],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha наверно будет неплохо написать, что именно ты ожидаешь в этих 5 элементах в итоге. Вообще будет неплохо, если ты напишешь доку, что именно тут переделано и почему.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha давай зададим эти элементы иначе
сделай 5 констант, обзови их ожидаемыми результатами и обращайся к ним по этим константам

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправлено

Comment thread index.js Outdated
var lastIndex = 0;

function makeState(state, match, bracketStack ) {
return {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha у тебя везде 4 отступа, а тут 2

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправлено

Comment thread index.js Outdated
return {
exec: function (str) {
var state = {
state: INITIAL,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha не очень-то у объекта state делать поле state

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправлено

Comment thread index.js Outdated
var state = {
state: INITIAL,
match: ['', '', '', '', ''],
bracketStack: 0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha ну еще я привык, что стэк это какой-то массив или список... тут скорее counter в имени применить... openedBracketCounter

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено

Comment thread index.js Outdated

/**
* Make state object from params
* @param {string} status next parcer status
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha parcer пишется через s :)

Comment thread index.js Outdated
}
}

// Status functions that determine the processing of the next character
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markitosha "processing of the next character" читаю как обработку следующего символа, а других статусов для обработки следующего символа не бывает что ли?

@mwmaleks
Copy link
Copy Markdown
Collaborator

👍

@mwmaleks mwmaleks merged commit e4e4e57 into wbr Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants