Skip to content

Improvements to the debugging show method of PGML. #1223

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

Open
wants to merge 1 commit into
base: PG-2.20
Choose a base branch
from

Conversation

drgrice1
Copy link
Member

This was something that was useful for me while I was working on writing the CodeMirror 6 PGML parser. It just formats the things in the PGML stack that are hashes in a nicer way, actually showing the contents instead of something like HASH(0x5d3919403d78) as it previously did.

The script in the attached zip can be used to test this:
pgml-parse.zip

The script requires that the PG_ROOT environment variable be set to the PG root directory. Execute the script by running ./pgml-parse.pl -f path/to/problem.pg. The script works with any version of PG that has PGML, but you can see the difference in the output. The combine entries (which almost any problem will have) will be output as HASH(0x...) with the develop branch, and will show the hash in a "prettier" way with this pull request.

This does not affect normal PGML usage in problems at all.

Just cleaning up local branches.

@drgrice1 drgrice1 force-pushed the pgml-show-improvements branch from d3250bb to 8f5b91f Compare April 8, 2025 23:09
@drgrice1 drgrice1 force-pushed the pgml-show-improvements branch from 8f5b91f to 3a45da6 Compare April 16, 2025 02:17
@pstaabp
Copy link
Member

pstaabp commented Apr 26, 2025

A couple of things. First, I'm getting some uninitialized string errors when running this on problems. Doesn't see to affect the output.

Also, would it be useful to put the pgml-parse.pl script in the bin or make a bin/dev directory for this?

@drgrice1
Copy link
Member Author

I am not seeing any warnings when using the script. Do you have the PG_ROOT environment variable set? If so, the warnings are probably actually coming from the problem you are testing. You are testing with a problem that has BEGIN_PGML/END_PGML in it right? You probably will get uninitialized string warnings from the script if not.

The script is not really that versatile and was rather quickly thrown together. I don't know if it is worth adding to the repository.

@pstaabp
Copy link
Member

pstaabp commented Apr 27, 2025

I do have PG_ROOT defined.

I'm seeing Use of uninitialized value in concatenation (.) or string at /opt/webwork/pg/lib/PGalias.pm line 34. for every problem. Maybe the pg_environment is not loading.

Other errors that I'm seeing are some of my problems like: /Contrib/Fitchburg/Algebra/intervals/interval_notation.pg and I'm getting the following:

Use of uninitialized value $string in substitution (s///) at (eval 233) line 1005.
Use of uninitialized value $string in substitution (s///) at (eval 233) line 1006.
Use of uninitialized value in concatenation (.) or string at (eval 233) line 996.
Use of uninitialized value $string in substitution (s///) at (eval 233) line 1005.
Use of uninitialized value $string in substitution (s///) at (eval 233) line 1006.
Use of uninitialized value in concatenation (.) or string at (eval 233) line 996.
Use of uninitialized value $string in substitution (s///) at (eval 233) line 1005.
Use of uninitialized value $string in substitution (s///) at (eval 233) line 1006.
Use of uninitialized value in concatenation (.) or string at (eval 233) line 996.

@drgrice1
Copy link
Member Author

The PGalias.pm warnings are because of a change in the code with the security vulnerability fixes in #1219 that the script doesn't account for.

The other warnings are actually expected. What is happening is that the PG_restricted_eval is encountering variables that are not defined because the script doesn't do a full render of the problem. It only parses the PGML section. For my tests that I worked with for development of the PG CodeMirror 6 editor I actually implemented special handling for this to define the needed variables.

Here is a hacked up version of the script that will remove the warnings, although will be less accurate for the actual result.
pgml-parse.zip

Note that this script really is not the point of this pull request. The PGML show method has been there pretty much since PGML was created and this is just a minor tweak on its output. A script that utilizes it is something different entirely. @dpvc probably has scripts that do so as well.

@drgrice1 drgrice1 changed the base branch from develop to PG-2.20 April 29, 2025 12:27
This was something that was useful for me while I was working on writing
the CodeMirror 6 PGML parser.  It just formats the things in the PGML
stack that are hashes in a nicer way, actually showing the contents
instead of something like `HASH(0x5d3919403d78)` as it previously did.

This does not affect normal PGML usage in problems at all.
@drgrice1 drgrice1 force-pushed the pgml-show-improvements branch from 3a45da6 to f70cc07 Compare April 29, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants