Page MenuHomePhabricator

Convert Grammar related javascript to php in texvcjs
Closed, ResolvedPublic

Description

phpeg and similar modules like wikipeg can not convert or read javascript in
action blocks and introduction code of peg based grammar files.

To enable conversion of LaTeX to MML in the future in texvcjs, the already existing functionalities in javascript have to be converted.

To created a more readable form of the existing modules in php, understand the visitor-pattern and eventually use another pattern in the php based classes.

  • Convert the node modules referenced in parser.pegjs to php and in the render functionality: texutil, render and ast shall be refactored with the new classbased-implmnentation.
  • Convert the action blocks to php.
  • Create a php based grammar and ensure its functionality.
  • Write or convert some basic unit tests to check the functionality

Related Objects

StatusSubtypeAssignedTask
DeclinedStegmujo
OpenNone
ResolvedPhysikerwelt
ResolvedStegmujo
ResolvedStegmujo
ResolvedStegmujo
DuplicateNone
DeclinedNone
ResolvedPhysikerwelt
DeclinedNone
ResolvedPhysikerwelt
DeclinedNone
ResolvedNone
ResolvedStegmujo
ResolvedPhysikerwelt
ResolvedStegmujo
ResolvedPhysikerwelt
ResolvedStegmujo
ResolvedBUG REPORTStegmujo
ResolvedStegmujo
ResolvedStegmujo
ResolvedStegmujo
ResolvedStegmujo

Event Timeline

To created a more readable form of the existing modules in php, understand the visitor-pattern in MediaWiki and eventually use another pattern in the php based classes.

With visitor pattern I was referring to https://en.wikipedia.org/wiki/Visitor_pattern . I don't think it is conceptually a bad thing, but maybe we can use something less custom. In PHP it is less common to generate classes without the class keyword. Something like https://refactoring.guru/design-patterns/visitor/php/example#example-1 . Maybe we could also refactor the current JS code to make use of explicit classes rather than using generic objects. See also the reference for the this keyword in JS https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this

Change 817289 had a related patch set uploaded (by Stegmujo; author: Stegmujo):

[mediawiki/extensions/Math@master] WIP: Convert Grammar related javascript to php in texvcjs

https://gerrit.wikimedia.org/r/817289

Change 824207 had a related patch set uploaded (by Stegmujo; author: Stegmujo):

[mediawiki/extensions/Math@master] Add TexNode and a test.

https://gerrit.wikimedia.org/r/824207

Change 824208 had a related patch set uploaded (by Stegmujo; author: Stegmujo):

[mediawiki/extensions/Math@master] Add beginning of RenderUtil and Test.

https://gerrit.wikimedia.org/r/824208

Change 824211 had a related patch set uploaded (by Stegmujo; author: Stegmujo):

[mediawiki/extensions/Math@master] Add some basic nodes.

https://gerrit.wikimedia.org/r/824211

Change 824212 had a related patch set uploaded (by Stegmujo; author: Stegmujo):

[mediawiki/extensions/Math@master] Add Texutil and a test.

https://gerrit.wikimedia.org/r/824212

Change 817289 abandoned by Stegmujo:

[mediawiki/extensions/Math@master] WIP: Convert Grammar related javascript to php in texvcjs

Reason:

https://gerrit.wikimedia.org/r/817289

Change 824207 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Add TexNode

https://gerrit.wikimedia.org/r/824207

Change 824211 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Add some basic nodes and texUtil

https://gerrit.wikimedia.org/r/824211

Change 827463 had a related patch set uploaded (by Stegmujo; author: Stegmujo):

[mediawiki/extensions/Math@master] Add further nodes

https://gerrit.wikimedia.org/r/827463

Change 827463 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Add further nodes

https://gerrit.wikimedia.org/r/827463

Change 829812 had a related patch set uploaded (by Stegmujo; author: Stegmujo):

[mediawiki/extensions/Math@master] Add final nodes

https://gerrit.wikimedia.org/r/829812

Change 829812 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Add final nodes

https://gerrit.wikimedia.org/r/829812

Change 830178 had a related patch set uploaded (by Stegmujo; author: Stegmujo):

[mediawiki/extensions/Math@master] Add Parser

https://gerrit.wikimedia.org/r/830178

@Stegmujo I have been reviewing your patch.

I have added more tests to the AllTests.php and converted it to use the dataProvider pattern rather than a foreach loop. It does take a while to run, though. Longer than the JS equivalent. I don't know why. There are a few failures and errors as well which I haven't had time to investigate yet.

I also wrote a maintenance script where you can test the parser from the command line (based on bin/texvcjs).

Patch below. If you like it, you can include it in your current patch or I can create a different patch. Whichever is easier for you.

Hey @dom_walden thanks for the patch for AllTests. I had a check with the current WIP state (https://gerrit.wikimedia.org/r/830178), and I applied the dataProvider from the patch instead of loop, great suggestion.
I could fix all cases of the tests locally in WIP state (except the unicode testcase, skipped atm) through debugging the PHP grammar.

Change 824212 abandoned by Stegmujo:

[mediawiki/extensions/Math@master] Add Texutil

Reason:

it is added in TexVC-PHP relation chain.

https://gerrit.wikimedia.org/r/824212

Change 830178 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Add Builder for creating Parser.php

https://gerrit.wikimedia.org/r/830178

Change 824208 abandoned by Stegmujo:

[mediawiki/extensions/Math@master] Add beginning of RenderUtil

Reason:

already done somewhere else

https://gerrit.wikimedia.org/r/824208