syntax-checking

PHP Sanity Check

好久不见. 提交于 2020-02-21 06:13:46
问题 I am looking for applications or methods for performing sanity checks of php code. I hope to to avoid finding out about the coding mistakes the hard way, but instead find them before publishing the website. display_errors = on and similar run-time methods find the problems too late. So far I have found the following ways, which I think are not thorough enough: php_check_syntax() from within php php -l from the command line ioncube php encoder netbeans and eclipse as editors What better way is

PHP Sanity Check

喜你入骨 提交于 2020-02-21 06:12:23
问题 I am looking for applications or methods for performing sanity checks of php code. I hope to to avoid finding out about the coding mistakes the hard way, but instead find them before publishing the website. display_errors = on and similar run-time methods find the problems too late. So far I have found the following ways, which I think are not thorough enough: php_check_syntax() from within php php -l from the command line ioncube php encoder netbeans and eclipse as editors What better way is

Is it possible to check PHP file syntax from PHP?

青春壹個敷衍的年華 提交于 2020-01-02 00:58:08
问题 I load dynamically PHP class files with autoload. And those files could be missing or corrupted by some reason. Autoload will successfully report missing files so application logic could handle that. But if those files are corrupted, then the whole processing halts with blank screen for the user and "PHP Parse error: syntax error" in error log. Is it possible to check syntax of PHP file from PHP code? I've looked here: http://us.php.net/manual/en/function.php-check-syntax.php - it's

math syntax checker written in python

放肆的年华 提交于 2020-01-01 04:48:06
问题 All I need is to check, using python, if a string is a valid math expression or not. For simplicity let's say I just need + - * / operators ( + - as unary too) with numbers and nested parenthesis. I add also simple variable names for completeness. So I can test this way: test("-3 * (2 + 1)") #valid test("-3 * ") #NOT valid test("v1 + v2") #valid test("v2 - 2v") #NOT valid ("2v" not a valid variable name) I tried pyparsing but just trying the example: "simple algebraic expression parser, that

How can I check the syntax of Python script without executing it?

旧城冷巷雨未停 提交于 2019-12-28 01:38:08
问题 I used to use perl -c programfile to check the syntax of a Perl program and then exit without executing it. Is there an equivalent way to do this for a Python script? 回答1: You can check the syntax by compiling it: python -m py_compile script.py 回答2: You can use these tools: PyChecker Pyflakes Pylint 回答3: import sys filename = sys.argv[1] source = open(filename, 'r').read() + '\n' compile(source, filename, 'exec') Save this as checker.py and run python checker.py yourpyfile.py . 回答4: Here's

Python syntax check in ace editor

青春壹個敷衍的年華 提交于 2019-12-24 11:28:28
问题 What I am trying to develop is a web-environment app which will let user write and syntax check his own python code. To the moment, I have embedded ACE editor to my app using the python mode. My problem is that ace does not include a javascript lib for python syntax check in order to implement it by using workers as described here How to integrate syntax check in Ace Editor using custom mode?. Through my search I have found modules like pyflakes or pylint. for syntax check which are both

Check if a string is valid PHP code

▼魔方 西西 提交于 2019-12-23 02:58:06
问题 I want to do: $str = "<? echo 'abcd'; ?>"; if (is_valid_php($str)){ echo "{$str} is valid"; } else { echo "{$str} is not valid PHP code"; } Is there a simple way to do the is_valid_php check? All I can find is online php syntax checkers and command-line ways to check syntax, or php_check_syntax which only works for a file, and I don't want to have to write to a file to check if the string is valid. I'd rather not use system() / exec() or eval() Related Question - It's old, so I'm hoping there

PHP syntax check on .html files in NetBeans

冷暖自知 提交于 2019-12-22 00:53:14
问题 I am using NetBeans IDE 8.0.1 for my PHP development. I like the syntax check feature in netbeans. But the problem that I have is that it only works with files that have .php extension . I am using a lot of php code in files with .html extension, and no php syntax checking is being available in NetBeans for those files. Is it possible to enable php syntax checking for .html files? 回答1: One hacky way to do that: go to Tools|Options|Miscellanous select Files tab from File extensions, select

Can Visual Studio target earlier C# syntax in addition to earlier .NET framework versions?

冷暖自知 提交于 2019-12-21 04:50:13
问题 The easy part: Targeting the .NET 2.0 framework in a Visual Studio 2010 project using the dropdown. The hard part: Is it possible to target a specific syntax version - for example var s = "hello world" is valid syntactic sugar in VS2008 and above, but would not compile in VS2005. Can VS2010 be configured to flag this at compile time? 回答1: This can be done by specifying the language version in the project settings. To set the language version to C# 2.0 do the following Right Click on the

How can I check (My)SQL statements for syntactical correctness

狂风中的少年 提交于 2019-12-20 17:44:27
问题 we're currently setting up out integration server and during that process we've set up pre-commit hooks on the SVN so that our developers can't check in files that are syntactically invalid (primarily PHP and XML). We also have a bunch of .sql files (for MySQL) which I'd like to lint as well. Unfortunately, Google didn't turn up anything useful for this task. Any ideas? 回答1: The commercial version of MySQL Workbench has a syntax checker for MySQL statements, but of course that would only