zend_language_scanner.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.00 of the Zend license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.zend.com/license/2_00.txt. |
  11. | If you did not receive a copy of the Zend license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@zend.com so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Andi Gutmans <andi@php.net> |
  16. | Zeev Suraski <zeev@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef ZEND_SCANNER_H
  20. #define ZEND_SCANNER_H
  21. typedef struct _zend_lex_state {
  22. unsigned int yy_leng;
  23. unsigned char *yy_start;
  24. unsigned char *yy_text;
  25. unsigned char *yy_cursor;
  26. unsigned char *yy_marker;
  27. unsigned char *yy_limit;
  28. int yy_state;
  29. zend_stack state_stack;
  30. zend_ptr_stack heredoc_label_stack;
  31. zend_stack nest_location_stack; /* for syntax error reporting */
  32. zend_file_handle *in;
  33. uint32_t lineno;
  34. zend_string *filename;
  35. /* original (unfiltered) script */
  36. unsigned char *script_org;
  37. size_t script_org_size;
  38. /* filtered script */
  39. unsigned char *script_filtered;
  40. size_t script_filtered_size;
  41. /* input/output filters */
  42. zend_encoding_filter input_filter;
  43. zend_encoding_filter output_filter;
  44. const zend_encoding *script_encoding;
  45. /* hooks */
  46. void (*on_event)(
  47. zend_php_scanner_event event, int token, int line,
  48. const char *text, size_t length, void *context);
  49. void *on_event_context;
  50. zend_ast *ast;
  51. zend_arena *ast_arena;
  52. } zend_lex_state;
  53. typedef struct _zend_heredoc_label {
  54. char *label;
  55. int length;
  56. int indentation;
  57. bool indentation_uses_spaces;
  58. } zend_heredoc_label;
  59. /* Track locations of unclosed {, [, (, etc. for better syntax error reporting */
  60. typedef struct _zend_nest_location {
  61. char text;
  62. int lineno;
  63. } zend_nest_location;
  64. BEGIN_EXTERN_C()
  65. ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state);
  66. ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state);
  67. ZEND_API void zend_prepare_string_for_scanning(zval *str, zend_string *filename);
  68. ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding);
  69. ZEND_API zend_result zend_multibyte_set_filter(const zend_encoding *onetime_encoding);
  70. ZEND_API zend_result zend_lex_tstring(zval *zv, unsigned char *ident);
  71. END_EXTERN_C()
  72. #endif