Skip to content
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

Upgrading APDL lexer #2314

Merged
merged 5 commits into from Jan 30, 2023
Merged

Upgrading APDL lexer #2314

merged 5 commits into from Jan 30, 2023

Conversation

germa89
Copy link
Contributor

@germa89 germa89 commented Jan 4, 2023

Fixing some parsing issues (dots mainly).

Upgraded theme.

/batch,list !list = elafune,
!batch 
/title,upf-py1s, test usermat.py with 3D elements
/COM, asdf.ad fasdfasf
/prep7
/upf,usermat.py
/upf, 'asdf'
/com, %asdf%
/com, $
/prep7$
/title,adfs %asdf% asdf
tb,user,1,,2
tbdata,1,1e5, 0.3    ! E, Poisson
adsf = 123/13
adf = adsfsa*adfasdf
asd= (212*12)/123
et,1,185

/eof

/com, expected results: Sx=-1000, epel_x=-1e-2
finish
/exit,nosave

Before:
image

After:
image

Close #2315

Copy link
Contributor

@jeanas jeanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails the CI as you need to run pytest --update-goldens tests/snippets/apdl to update the golden test output.

pygments/lexers/apdlexer.py Outdated Show resolved Hide resolved
pygments/lexers/apdlexer.py Outdated Show resolved Hide resolved
pygments/lexers/apdlexer.py Outdated Show resolved Hide resolved
pygments/lexers/apdlexer.py Outdated Show resolved Hide resolved
@germa89
Copy link
Contributor Author

germa89 commented Jan 16, 2023

@jean-abou-samra I have implemented the new changes. Feel free to re-trigger CI.

Btw, I was trying that the keywords are only at the beginning of each line. I tried to add r"^\s*" to each hardcoded keyword, but it didn't work. Any suggestions?

@jeanas
Copy link
Contributor

jeanas commented Jan 29, 2023

@germa89

Btw, I was trying that the keywords are only at the beginning of each line. I tried to add r"^\s*" to each hardcoded keyword, but it didn't work. Any suggestions?

You would need (?m) for ^ to work. However, you don't want the whitespace to be part of the keyword token. I've pushed a commit that takes one possible approach for this. Let me know if I understood this correctly. Otherwise, the rest looks fine to me.

@germa89
Copy link
Contributor Author

germa89 commented Jan 30, 2023

You would need (?m) for ^ to work. However, you don't want the whitespace to be part of the keyword token. I've pushed a commit that takes one possible approach for this. Let me know if I understood this correctly. Otherwise, the rest looks fine to me.

Hi @jean-abou-samra, I'm not sure if I explained myself correctly. I would like that the keywords are only matched when they are at the beginning of the line.
I believe that (?m) are for setting multiline flag. I'm not caring about having ^ in the keywords.

@jeanas
Copy link
Contributor

jeanas commented Jan 30, 2023

You said you tried to add r"^\s* as prefix on each keyword. I explained that one reason this does not work is that ^ only matches at the very beginning unless you use (?m).

@germa89
Copy link
Contributor Author

germa89 commented Jan 30, 2023

You said you tried to add r"^\s* as prefix on each keyword. I explained that one reason this does not work is that ^ only matches at the very beginning unless you use (?m).

Ohhh... ok ok... Let's add it then.

@jeanas
Copy link
Contributor

jeanas commented Jan 30, 2023

Nope. Because if you do words(..., prefix=r"^\s*"), it mostly works (with some additional changes), but the whitespace is included in the token.

Please, check the commit that I pushed. It's not the only approach, but it should work.

@germa89
Copy link
Contributor Author

germa89 commented Jan 30, 2023

Nope. Because if you do words(..., prefix=r"^\s*"), it mostly works (with some additional changes), but the whitespace is included in the token.

Please, check the commit that I pushed. It's not the only approach, but it should work.

I see....

I checked the lastest commits and I'm happy with the result :). I'm happy to merge it.

Thank a lot!

@jeanas jeanas merged commit 558d6b6 into pygments:master Jan 30, 2023
@germa89 germa89 deleted the fix/apdl-lexer-syntax branch January 30, 2023 11:45
@Anteru Anteru added this to the 2.15.0 milestone Mar 25, 2023
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.

APDL lexer fails
3 participants