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...
Annunciate asked 26/12, 2019 at 1:43

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...
Underbid asked 20/12, 2019 at 13:38

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. ...
Eulogia asked 29/9, 2019 at 18:25

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...
Mesa asked 27/8, 2019 at 9:45

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 :)
Imbroglio asked 17/12, 2015 at 15:52

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...

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...
Rotgut asked 28/7, 2019 at 20:46

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...
Tekla asked 15/7, 2019 at 20:1

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 ...
Robertoroberts asked 20/9, 2012 at 17:31

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...
Staphylococcus asked 1/7, 2019 at 7:33

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...
Heedful asked 1/7, 2019 at 10:11

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...
Egregious asked 25/6, 2019 at 8:9

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 ...

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...
Quail asked 3/6, 2019 at 6:8

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...
Dreddy asked 1/6, 2019 at 8:59

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...
Reach asked 15/5, 2019 at 21:25

4

Solved

Is there an existing POSIX sh grammar available or do I have to figure it out from the specification directly? Note I'm not so much interested in a pure sh; an extended but conformant sh is also m...
Weymouth asked 24/3, 2013 at 13:11

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...
Garage asked 16/9, 2011 at 10:26

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?

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...
Nephew asked 8/4, 2019 at 9:12

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.