Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved error handling #41

Merged
merged 10 commits into from Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
@@ -1,3 +1,4 @@
*.c linguist-language=C
*.h linguist-language=C
*.w32 linguist-language=JavaScript
*.inc linguist-language=PHP
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -43,7 +43,11 @@ php_test_results_*
parser/lemon
parser/scanner.c
parser/parser.c
parser/parser.php5.c
parser/parser.php5.h
parser/parser.php5.out
parser/parser.php7.c
parser/parser.php7.h
parser/parser.php7.out

release
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Expand Up @@ -6,10 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed
- Extremely simplified installation of the extension using standard PHP workflow
- Extremely simplified installation of the extension using standard PHP workflow [#38](https://github.com/phalcon/php-zephir-parser/issues/38)

### Fixed
- Improved error handling and prevent segfault on invalid syntax [#30](https://github.com/phalcon/php-zephir-parser/issues/30)

### Removed
- Removed no longer need BASH scripts
- Removed no longer need BASH scripts to build and install extension

## [1.1.2] - 2018-01-23
### Added
Expand Down
60 changes: 60 additions & 0 deletions CODE_OF_CONDUCT.md
@@ -0,0 +1,60 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making
participation in our project and our community a harassment-free experience for everyone, regardless of age, body size,
disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
project or its community. Examples of representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed representative at an online or offline
event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at
team@zephir-lang.com. The project team will review and investigate all complaints, and will respond in a way that it
deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the
reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -96,7 +96,7 @@ If you have specific PHP versions running:
```bash
git clone git://github.com/phalcon/php-zephir-parser.git
cd php-zephir-parser
phpize
/usr/local/bin/phpize
./configure --with-php-config=/usr/local/bin/php-config
make
sudo make install
Expand Down Expand Up @@ -129,7 +129,7 @@ See the [LICENSE][:ext-license:] file for more information.

[:badge-travis:]: https://travis-ci.org/phalcon/php-zephir-parser.svg?branch=development
[:badge-appveyor:]: https://ci.appveyor.com/api/projects/status/r4k8baw1iy54v2wt/branch/development?svg=true
[:badge-codecov:]: https://codecov.io/gh/phalcon/php-zephir-parser/branch/developent/graph/badge.svg
[:badge-codecov:]: https://codecov.io/gh/phalcon/php-zephir-parser/branch/development/graph/badge.svg
[:badge-license:]: https://img.shields.io/badge/license-MIT-brightgreen.svg
[:build-travis:]: https://travis-ci.org/phalcon/php-zephir-parser
[:build-appveyor:]: https://ci.appveyor.com/project/sergeyklay/php-zephir-parser/branch/master
Expand Down
11 changes: 7 additions & 4 deletions coverage.mk
@@ -1,18 +1,21 @@
OUTCOV=coverage.info
DIRCOV=coverage

.PHONY: clean-coverage
clean-coverage:
-rm -fr $(OUTCOV) $(DIRCOV)

# coverage-initial test coverage-capture
.PHONY: coverage-initial
coverage-initial: clean-coverage
@echo "Capture initial zero coverage data"
@$(LCOV) --directory ./parser --directory . --zerocounters
@$(LCOV) --directory ./parser --directory . --capture --compat-libtool --initial --base-directory=. --output-file $(OUTCOV)

.PHONY: coverage-capture
coverage-capture:
@echo "Generating $@"
@$(LCOV) --no-checksum --directory ./parser --directory . --capture --compat-libtool --output-file $(OUTCOV)
@$(LCOV) --remove $(OUTCOV) "/usr*" --remove $(OUTCOV) "${HOME}/.phpenv/*" --remove $(OUTCOV) "${HOME}/build/include/*" --compat-libtool --output-file $(OUTCOV)
@$(LCOV) --no-checksum --directory . --capture --compat-libtool --output-file $(OUTCOV)
@$(LCOV) --remove $(OUTCOV) "/usr*" --remove $(OUTCOV) "${HOME}/.phpenv/*" --compat-libtool --output-file $(OUTCOV)

.PHONY: coverage-html
coverage-html: coverage-capture
@$(GENHTML) --legend --output-directory $(DIRCOV) --title "Zephir Parser code coverage" $(OUTCOV)
11 changes: 1 addition & 10 deletions parser/base.c
@@ -1,13 +1,4 @@

/*
* This file is part of the Zephir Parser.
*
* (c) Zephir Team <team@zephir-lang.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

const xx_token_names xx_tokens[] =
{
{ XX_T_INTEGER, "INTEGER" },
Expand Down Expand Up @@ -63,7 +54,7 @@ static void xx_parse_with_token(void* xx_parser, int opcode, int parsercode, xx_
}

/**
* Parses a programm and returning an intermediate array representation
* Parses a program and returning an intermediate array representation
*/
void xx_parse_program(zval *return_value, char *program, size_t program_length, char *file_path, zval *error_msg) {

Expand Down
60 changes: 41 additions & 19 deletions tests/base/cblocks.phpt
@@ -1,13 +1,35 @@
--TEST--
Tests recognizing wrapping C-code in CBLOCKs
--SKIPIF--
<?php if (!extension_loaded("Zephir Parser")) print "skip The zephir_parser extension is not loaded"; ?>
<?php include(__DIR__ . '/../skipif.inc'); ?>
--FILE--
<?php require(__DIR__ . "/../zephir_parser_test.inc");
<?php

$code =<<<ZEP
namespace Example;

class Test
{
public function block()
{
%{

// Some comment

{
while(1) {
RETURN_MM_NULL();
}
}
}%
}
}
ZEP;

$ir = zephir_parse_file($code, '(eval code)');

$ir = parse_file("base/cblocks.zep");
var_dump($ir);
--EXPECTF--
--EXPECT--
array(2) {
[0]=>
array(5) {
Expand All @@ -16,7 +38,7 @@ array(2) {
["name"]=>
string(7) "Example"
["file"]=>
string(%d) "%s/tests/data/base/cblocks.zep"
string(11) "(eval code)"
["line"]=>
int(3)
["char"]=>
Expand Down Expand Up @@ -54,43 +76,43 @@ array(2) {
["type"]=>
string(6) "cblock"
["value"]=>
string(81) "
string(150) "

// Some comment
// Some comment

{
while(1) {
RETURN_MM_NULL();
}
}
"
{
while(1) {
RETURN_MM_NULL();
}
}
"
["file"]=>
string(%d) "%s/tests/data/base/cblocks.zep"
string(11) "(eval code)"
["line"]=>
int(17)
["char"]=>
int(2)
int(5)
}
}
["file"]=>
string(%d) "%s/tests/data/base/cblocks.zep"
string(11) "(eval code)"
["line"]=>
int(5)
["last-line"]=>
int(18)
["char"]=>
int(16)
int(19)
}
}
["file"]=>
string(%d) "%s/tests/data/base/cblocks.zep"
string(11) "(eval code)"
["line"]=>
int(3)
["char"]=>
int(5)
}
["file"]=>
string(%d) "%s/tests/data/base/cblocks.zep"
string(11) "(eval code)"
["line"]=>
int(3)
["char"]=>
Expand Down