Questions tagged [pest]

Pest.rs is a parser in Rust that accepts PEG grammars

You can find more information on Pest.rs on their website.

50 questions
4
votes
1 answer

Using Pest.rs how can I manage a multi-line syntax where a line ends in "\"?

A common idiom for bash is is to use \ to escape the newline at the end of the line, If a \ pair appears, and the backslash is not itself quoted, the \ is treated as a line continuation (that is, it is removed from the input…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
4
votes
1 answer

Using Pest.rs, how can I allow non-significant whitespace after a keyword?

I have the following Pest (https://pest.rs) grammar name = {ASCII_ALPHA+} fragment = { "fragment" ~ name } When I try to parse fragment name using this I get this error: --> 1:9 | 1 | fragment name | ^--- | = expected name
Teymour
  • 1,832
  • 1
  • 13
  • 34
3
votes
1 answer

Is it possible to pass a variable from a beforeEach/beforeAll function to my tests? (Pest php)

Right now I'm rewriting some unit tests to use Pest and noticed every test creates a new user. The tests need the id that creating the user returns. I would like to know if it is possible to put this in the beforeEach function Pest provides so I can…
3
votes
1 answer

Using Pest.rs, how can I specify that comments are to be anchored and whole line?

Exim uses a really awkward comment syntax, Blank lines in the file, and lines starting with a # character (ignoring leading white space) are treated as comments and are ignored. Note: A # character other than at the beginning of a line is not…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
3
votes
1 answer

Using Pest.rs, is there a way to store comments as tokens?

Pest.rs gives us a method of doing comments, COMMENT - runs between rules and sub-rules But if we're building a linter we may want the comments. Is there a way to have them saved on the tree?
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
2
votes
1 answer

Building a grammar for variables with pest parser

Using pest parser I am trying to build a grammar that can recognize variable names, but I can't get the variables to end at the next space/non-alpha character. I tried using... var_name = {!reserved ~ ASCII_ALPHA+} which works perfectly for…
2
votes
0 answers

Using Pest.rs, how can I dump the contents of the stack?

Pest.rs provides different stack functions like PUSH. These seem to work for me, but I would like to know if there is a way to debug the stack operations? If things aren't going as planned, is there an easy way to trigger a debug operation such that…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
2
votes
1 answer

PEG parser in pest to match regex within triple quotes, tried at https://pest.rs/

I am writing a PEG file to be used in pest for our dsl. There is need where i need to parse a key value where value is a regex within triple quote. I am unable to write a pest rule for it. The value is """Some regex here""" Rule I defined is: TQ =…
manu
  • 223
  • 1
  • 2
  • 12
2
votes
1 answer

Pest doesn't parse a recursive grammar as I would expect

I'm using the pest crate to implement a recursive grammar in Rust: id = _{ ASCII_ALPHA_LOWER ~ (ASCII_ALPHANUMERIC|"_")* } integer = _{ (ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*)|"0" } real = _{ ((integer ~ "." ~ ASCII_DIGIT*) | (integer? ~ "." ~…
Woody1193
  • 7,252
  • 5
  • 40
  • 90
2
votes
1 answer

Parser expression grammar - how to match any string excluding a single character?

I'd like to write a PEG that matches filesystem paths. A path element is any character except / in posix linux. There is an expression in PEG to match any character, but I cannot figure out how to match any character except one. The peg parser I'm…
marathon
  • 7,881
  • 17
  • 74
  • 137
1
vote
1 answer

Testing with PEST

I am a complete novice in testing and I wanted to know if someone could guide me on what I'm doing wrong. I want to test the following function in my php laravel project: public static function getFlatSupplierAddress($supplier_address_id): string …
1
vote
1 answer

Laravel - Make a check before the command "php artisan test"

I need to do a check before launching the php artisan test command. I need this because I currently have 2 databases for DEV, one local and one shared with my collaborators. I want to prevent the tests from running on the shared database. I already…
PewixG3
  • 13
  • 3
1
vote
0 answers

Matching nested bocks with PUSH and POP in Pest/Rust

I'm encountering a hurdle in parsing nested blocks. Specifically, I would like to parse (a small, defined subset of) LaTeX, and I'm having an issue at properly parsing nested \begin{} and \end{} pairs: \begin{document} Some text. \begin{quote} A…
pierre
  • 151
  • 8
1
vote
0 answers

Laravel Tests are getting failed on laravel 9.4 and php 8.1 (Filament Form error)

Recently I updated the Php version of my app, and now the tests are getting failed. it is giving me the following error: Declaration of Filament\Support\Components\ViewComponent::view(string $view): static must be compatible with…
Faizan
  • 33
  • 10
1
vote
0 answers

Php laravel test not loading relationships

I've got the following method in my controller: public function assignCustomer(string $orderID) : JsonResponse { $customersID = \request()->get('customers_id'); try { $order =…
MrCujo
  • 1,218
  • 3
  • 31
  • 56
1
2 3 4