Add support for the pan language #22

Closed
wants to merge 10 commits into
from

Projects

None yet

2 participants

@jrha
jrha commented Dec 14, 2012

Add pan http://en.wikipedia.org/wiki/Pan_(programming_language) as a supported language.
There is a collision with file extension for smarty templates, so make sure that is handled nicely.

I have written test cases but can't check them at the moment due to the following error:

run_tests: test/unit/detector_test.h:119: test_detector_detect_polyglot: Assertion `lang' failed.
Aborted
jrha commented Jan 8, 2013

Added test cases after firing up a Scientific Linux box to check them on.
Still no idea why Ubuntu doesn't work.

Thanks @jrha. Ohcount classifies languages in 3 categories - Logic, Build, Markup. Is Pan a logic language?

@jrha Wikipedia page says .tpl extension is deprecated. Do you feel strongly that disambiguating .tpl is needed? I am wondering if ^\s*(object|structure|unique|declaration)?\s+template\s+ regex is strong enough to guard against false positives.

jrha commented Mar 18, 2013

Hi @amujumdar, thanks for looking at this, I suppose pan is a logic language.

While tpl is deprecated it is still heavily used in the community, which is why I thought it was worth disambiguating.

As to whether the regex is strong enough, it was based on the assumption that we are only disambiguating against Smarty templates (which is what drove .tpl to be deprecated in favour of .pan). In this case a line must either be valid HTML and/or Smarty so should have at least a { or < (or another delimiter) before any other characters on a line (see http://www.smarty.net/docs/en/language.basic.syntax.tpl). This assumption may well break down if multi-line comments are present, I will take a look.

jrha commented Mar 18, 2013

@amujumdar I can confirm that the regex does indeed break down for multi-line comments.
I will have a look at whether it can be made more robust and if not will considering ditching the disambiguation.

jrha commented Mar 18, 2013

@amujumdar I've re-written the disambiguation and extended the test cases.
My C is a little rusty so please complain about any ugliness you see.

@jrha sorry it took me so long to respond. I can't verify if this works correctly (unless I am missing something, which is possible). You mentioned in the comments that To be a valid Pan file the first non-blank, non-comment line must be a template declaration. So I added a couple of blank and comments line to test/src_dir/pan.tpl


# This is a comment
# Another comment

object template pantest;

# Very simple pan test file

"/x1" = 1;

"/x2" = 2;

"/x3" = 1 + 2;

and ASSERT_DETECT(LANG_PAN, "pan.tpl"); test failed.

@amujumdar amujumdar closed this Dec 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment