RegLexer - wkpark/reglexer GitHub Wiki
RegLexer
SimpleTest์ ํฌํจ๋์ด ์๋ lexer.php
๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊ฐ์ ๋ ๋์ฟ ์ํค์ lexer.php
๋ฅผ ๋ฐํ์ผ๋ก ํ์๋ค.
๋์ฟ ์ํค์์๋ lexer.php๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ๋์๋ค.
- support for lookback and lookahead patterns
- support for changing the pattern modifiers from within the pattern.
- notifying the Handler of the starting byte index in the raw text, where a token was matched.
์ฌ๊ธฐ์ ๋ค์๊ณผ ๊ฐ์ ์ ์ ์์ ๊ฐ์ ํ์ฌ regex์ ํจ์ฉ์ฑ์ ๋์๋ค.
- capture ์ง์.
- token์ ๋ฐ์์ ์ ๋ฌํ๋ ๊ฒ์ด ์๋, match๋ ๋ฐฐ์ด ์ ์ฒด๋ฅผ ์ ๋ฌํ์ฌ regex ์ฌ์ฉ ๊ทน๋ํ.
- match offset ์ธ์๋ฅผ ์ฌ์ฉํ๋ฉฐ,
^
anchor๋ฅผ ์ฌ์ฉ ๊ฐ๋ฅ. PREG_OFFSET_CAPTURE
๋ฅผ ์ฌ์ฉํ์ฌ, ํจํด์ด ๋น์ด์๋ ๊ฒฝ์ฐ(์๋ฅผ ๋ค์ด"(?=\n)"
๊ฐ์ ํจํด)๋ ์ฌ์ฉ ๊ฐ๋ฅ.- ์ด๋ฒคํธ๋ฅผ ๋ณ๊ฒฝ ๊ฐ๋ฅํ๋ฉฐ ์ ์ฐ์ฑ์ ๋์๋ค. ์ฆ,
LEXER_EXIT
์ด๋ฒคํธ๋ฅผ ์ ๋ฌ๋ฐ์์ ์ด๊ฒ์ดLEXER_EXIT
์ด ์๋๋ผ๊ณ ํ๋ณ๋๋ฉดLEXER_UNMATCHED
๋ฑ์ ๋ค๋ฅธ ์ด๋ฒคํธ๋ก ๋ณ๊ฒฝ ๊ฐ๋ฅ. - ์๋ชจ๋ ํ ํฐ ๊ธธ์ด ์ฌ์ง์ ๊ฐ๋ฅ. ์ฆ,
'''''
ํ ํฐ์ ์ ๋ฌ๋ฐ์์'''
๋ฌธ์ 3๊ฐ๋ง ์๋ชจํ๋ ๊ฒฝ์ฐ์ 3์ ๋ฆฌํดํ๋ ๋ฐฉ์์ผ๋ก ์๋ชจ๋ ํ ํฐ์ ๊ธธ์ด ์ฌ์ง์ ํ์ฌ ์ ์ฐ์ฑ์ ๋์๋ค.