Homec4science

When starting the Phutil lexer in an initial state, push it onto the stack

Authored by epriestley <git@epriestley.com> on Oct 6 2012, 18:22.

Description

When starting the Phutil lexer in an initial state, push it onto the stack

Summary:
When permissively lexing PHP files, we put the lexer in an initial "php" state (i.e., has see '<?php') if there's no <? in the text. This allows us to correctly highlight PHP diffs which don't include full context.

Previously, under Pygments, we would stick "<?php" on the front and then remove it afterward, but that was messy. Now, we just start the lexer in the right state.

However, we currently set the state to the initial state, rather than pushing it onto the stack. This means a snippet like ?> causes us to pop the state and trigger the "last state was popped" exception.

Instead push the state on to the stack, so if it is popped there's still a 'start' underneath it.

Test Plan: Added a unit test which covers this case. The test fails without this change and passes with it.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1864

Differential Revision: https://secure.phabricator.com/D3648

Details

Committed
epriestley <git@epriestley.com>Oct 6 2012, 18:22
Pushed
aubortMar 17 2017, 12:03
Parents
rPHU795212bf9d7a: Show URI in HTTP/HTTPSFuture exceptions
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHUd71108874fa6: When starting the Phutil lexer in an initial state, push it onto the stack (authored by epriestley <git@epriestley.com>).Oct 6 2012, 18:22