|
Parsing a string with special characters
|
| |
I've this *grammar* which defines a rule for parsing strings ...It works really well for every string unless I'm parsing a string with special characters. The main problem appears when I've to parse a string like *%q("\\ \0 \" \t \n \r")* I expect to return *"\\ \0 \" \t \n \r",* but this rule stops when reads ".... more »
|
|
Help with interpretation
|
| |
Hello, all. This is my first time using Citrus, and I am having trouble. I don't know what the source of my problems is, so I'd love your help. I haven't worked at the grammar lexer/parser/interpreter problem for over ten years, so apologies for any egregious failures. I am attempting to create a language that will allow for users of the... more »
|
|
Repeating sections
|
| |
Citrus is awesome, but I have one question. I really need parse something like: key1 ... key2 ... key3 ...and get something like this: [ ...But I cannot realize how to parse such repeating. Can anybody please help me? Thanks.
|
|
infinite running
|
| |
Hi,
If I run below parsing code,
Citrus.eval (<<CITRUS)
grammar Good
rule inf
( [a-z]* "!"* )*
end
end
CITRUS
Good.parse("good!better!!best! !!", :root=>:inf), which runs and never
ends,
what's the problem root cause?
|
|
Citrus require
|
| |
Hi,
In the following example copied from
[link]
require 'ipv4address' # (1)
require 'ipv6address'
grammar IPAddress
include IPv4Address
include IPv6Address
rule IPaddress
IPv4address | IPv6address... more »
|
|
wired question mark
|
| |
grammar TestQ
rule test
/a/ " "+ | /(\s*\r\n)+/
end
end
str = " \r\n"
match = TestQ.parse(str)
The above code can parse the string, however, if I add a question mark
after /a/ to make it optional like this,
/a/? " "+ | /(\s*\r\n)+/
then it will fail, why is the problem?... more »
|
|
zero-or-one not works when used with ordered choice
|
| |
I tried below grammar and a simple testing code, can I say that the
question mark is not working when used with a followed ordered choice?
see the test result below.
...grammar Question
rule qm
/xyz/? | "issue"
end
end
------------------------------ ----
require "citrus"
Citrus.load "question"... more »
|
|
How to get more information about parse errors?
|
| |
Hi, Not trying to spam the list... honest! :) Another question: how do you tell what rule failed to match during the parse? Looking at the code, there's no way to get access to the parser state from the Citrus::SyntaxError instances. I apparently have a non-terminal rule that's ambiguous because Citrus doesn't seem to be treating an optional rule component as optional when marked with '?'. If I mark it with a '*' instead, it parses as I'd expect, but I'd really like to know/understand more about what's going on so I could possibly fix the input grammar to resolve the issue rather than having to deal with raising a parse error on multiple matches myself.... more »
|
|
Diagnosing issues with #resolve! method
|
| |
Hi folks, I've been playing around the last couple of days trying to translate a context-free grammar defined by an ISO specification into a Citrus grammar. I'm new to Citrus, and relatively new to PEGs, but I did implement a couple of simple grammars using Treetop in the past. About 17 years ago, I used to be relatively up to scratch with lex and yacc, but my compiler building and compiler theory chops are somewhat rusty these days... ;)... more »
|
|
Returning a curly brace in a value
|
| |
I'm just now learning Citrus, great stuff so far. I'm trying to set
the value of a rule to include a curly brace and it raises parsing
errors on the grammer. Example:
rule method
(def space method_name statements ends) {
"#{method_name.value} = function() { #{statements.value} }"... more »
|
|
|