Update to M2 lexer in pygments.lexers.pascal.py

Issue #1090 resolved
trijezdci
created an issue

I had contributed the M2 lexer to Pygments several years ago. Meanwhile I have made some updates to my working copy. How do I contribute this? I do not have write access to your repo. The updated file is in my bitbucket repo at:

https://bitbucket.org/trijezdci/m2r10/src/tip/_GRAMMAR/pygments.lexers.pascal.py#cl-508

With this update, the lexer gets a fallback mode in which it recognises the combined reserved words and builtins of several dialects where before it defaulted to an outdated dialect that has not been maintained since 1984. In fact, the option selection did not work.

Comments (4)

  1. trijezdci reporter

    I have now made further enhancements to the modula-2 lexer class.

    The lexer now supports several more dialects and it can recognise dialect tags embedded as comments in source files since sites like Bitbucket and Github do not provide any means to pass options to Pygments.

    It also supports Algol presentations style in combination with a pygments style sheet called algol. When style=algol is passed, reserved words and builtin names are converted to lowercase, the style sheet then causes them to be rendered boldface and boldface italic respectively.

    Please can you fetch the latest version of these files from our repo (also at bitbucket)

    https://bitbucket.org/trijezdci/m2r10/src/tip/_GRAMMAR/pygments.lexers.pascal.py#cl-508

    https://bitbucket.org/trijezdci/m2r10/src/tip/_GRAMMAR/pygments.styles.algol.py

    thank you in advance

  2. trijezdci reporter

    during a chat on IRC with georg yesterday we agreed to split out the modula2 lexer from pascal.py and move it into its own file modula2.py. We further agreed that I consolidate all my test cases into a single input file and submit that, too.

    I have now split the m2 lexer from pascal.py into a separate modula2.py, consolidated the test cases into a modula2_test_cases.def file and rerun all the test cases.

    At that point I felt it would be nice if operators and punctuation not valid for the active dialect could be rendered as errors in their entirety, so I added that and tested it on all dialects.

    I further made two versions of the Algol publication mode style file, algol.py and algol_nu.py, the former underlines keywords, the latter does not. I tried to make the latter a subclass of the former and only change the one style, inherit all the others but pygments complained it could not find the file when I did so, thus two almost identical style sheets.

    I then added documentation to the style files and updated the docstring of the modula2 lexer as well.

    This is all well tested and nicely polished now and can be found in our repo in the grammar directory:

    https://bitbucket.org/trijezdci/m2r10/src/tip/_GRAMMAR/

    If you would be so kind and commit this to pygments.

    PS: I had to manually edit the mappings file after splitting out the m2 lexer, the make mapfile command didn't work.

    PPS: The documentation in the algol style sheet mentions the algol lexer which I am still working on and will upload in the coming days, perhaps even at the end of this weekend.

    thanks in advance

  3. Log in to comment