grammar Questions
1
Solved
In the process of writing a translator of one music language to another (ABC to Alda) as an excuse to learn Raku DSL-ability, I noticed that there doesn't seem to be a way to terminate a .parse! He...
1
For a chat bot I'm writing, I want to make its parser customizable so people don't need to modify the bot itself to add hooks for whatever types of chat messages they want to. The parser uses a gra...
2
Solved
I'm trying to create a grammar to parse some Excel-like formulas I have devised, where a special character in the beginning of a string signifies a different source. For example, $ can signify a st...
Creodont asked 17/11, 2019 at 0:14
1
Solved
Although the docs state that calling a token/rule/regex as <.foo> instead of <foo> makes them non-capturing, it seems there is a difference in scope, but I'm not sure if it's intended.
...
2
I am having a problem while parsing some SQL typed string with ANTLR4.
The parsed string is :
WHERE a <> 17106
AND b BETWEEN c AND d
AND e BTW(f, g)
Here is a snippet of my grammar :
wher...
3
Solved
I created my grammar using antlr4 but I want to test robustess
is there an automatic tool or a good way to do that fast
Thanks :)
2
Solved
In C++, if I have a class:
class Example {
static int s_One, s_Two;
...
};
Does the language clearly define that s_Two is also static?
In other words, does the static keyword extent go ever...
Austronesia asked 5/8, 2019 at 16:38
20
Solved
I often hear claims that C++ is a context-sensitive language. Take the following example:
a b(c);
Is this a variable definition or a function declaration? That depends on the meaning of the symb...
Sclerenchyma asked 29/1, 2013 at 18:5
2
Solved
Passing variables to token or regex or rule is fairly straightfoward. For example, the output of
grammar Foo {
token TOP { (.) {} <bar($0)> }
token bar($s) { {say ~$s} .+ }
}
Foo.parse("xy...
2
Solved
Reading the N1570 draft of the C11 standard, it says on p. 121 about the _Atomic keyword:
If the _Atomic keyword is immediately followed by a left parenthesis,
it is interpreted as a type speci...
5
Solved
Is there a parser generator that also implements the inverse direction, i.e. unparsing domain objects (a.k.a. pretty-printing) from the same grammar specification? As far as I know, ANTLR does not ...
3
Solved
The example for sym shows * (WhateverCode) standing in for a single symbol
grammar Foo {
token TOP { <letter>+ }
proto token letter {*}
token letter:sym<P> { <sym> }
token le...
5
Solved
I would like to write a lexer generator to convert a basic subset of the MATLAB language to C#, C++, etc. To help me do this, I would like to find a document containing the formal grammar for MATLA...
Hahnert asked 6/3, 2012 at 12:0
1
Solved
In theory, and according to the documentation, you can use any argument for methods in grammar actions.
grammar G {
token TOP { \w+ }
}
class Action-Arg {
method TOP ($match) { $match.make: ~$m...
2
Solved
The syntactical grammar of hardly any programming language is regular, as they allow arbitrarily deeply nested parenthesis. Rust does, too:
let x = ((((()))));
But is Rust's syntactical grammar ...
Bonny asked 28/4, 2017 at 10:13
1
I have a problem with transforming parsed JSON-like string, which contains nested arrays, to structured object. I am using parslet to do this.
I created parser and transformer, presented below. B...
3
Solved
I have recently had the need to create an ANTLR language grammar for the purpose of a transpiler (Converting one scripting language to another). It occurs to me that Google Translate does a pretty ...
Smoke asked 15/5, 2019 at 2:8
2
Solved
I have a string like "39 3A 3B 9:;" and i want to extract "39, 3A, 3B"
I have tried
my $a = "39 3A 3B 9:;";
grammar Hex {
token TOP { <hex_array>+ .* }
token hex_array { <[0..9 A..F]&g...
1
Solved
According to the documentation, you can redefine the ws token in a grammar, this token is called automatically in some cases, such as this:
grammar Numbers { rule TOP { \d \d } };
my $result = Nu...
1
Solved
How does perl6 decide which proto token to match against first?
The below code works as expected, it matches the string 1234, and Grammar::Tracer shows that the first token matched against is s:sy...
4
Solved
7
Going through the NLTK book, it's not clear how to generate a dependency tree from a given sentence.
The relevant section of the book: sub-chapter on dependency grammar gives an example figure but...
4
I have the following grammar, which I'm told is LR(1) but not SLR(1):
S ::= a A | b A c | d c | b d a
A ::= d
I don't understand why this is. How would you prove this?
Wray asked 8/5, 2012 at 20:7
1
Solved
I am using Grammar::Tracer with the following setup:
p.p6
use v6;
use lib '.';
use MyGrammar;
my $res = MyGrammar.parse('hello 6 9 bye');
say $res;
MyGrammar.pm6:
unit grammar MyGrammar;
use G...
6
Solved
I'm trying to implement a language (or family of languages) whose grammar can be changed dynamically. I have found no examples that serve as study cases.
Can you give me some reference to an...
Chellman asked 23/9, 2010 at 20:36
© 2022 - 2024 — McMap. All rights reserved.