3,299 questions
-1
votes
0
answers
22
views
How can I write an unambiguous grammar for arithmetic expressions without nested parentheses?
I would like to write a YACC/Bison parser for arithmetic expressions with the usual round parentheses but excluding the possibility of nested parenthesis and using an unambiguous grammar.
Examples of ...
1
vote
1
answer
85
views
Dart multiple generic type evaluation
I saw an article about the Result pattern on the official flutter site(https://docs.flutter.dev/app-architecture/design-patterns/result), and I thought it was a good structure, so I tried to apply it ...
3
votes
1
answer
91
views
Is it possible to understand, when do semantic predicates work and when they don't?
Below are two grammars.
In this grammar, semantic predicates do "work". I.e. if they are false, rules don't match and if they are true, rules do match:
expr
: term
| expr asterisk ...
0
votes
0
answers
24
views
Is this correct grammar for Nearley?
Is the following good grammar for Nearley.js? It describes logical expressions with variables, negation, conjunction and parentheses.
It's a bit convoluted (?), but I didn't know other way how to make ...
1
vote
1
answer
41
views
S/R conflict in Bison
I have a problem with a [relatively simple] grammar, a distilled version of a much bigger grammar. Bison reports one shift/reduce conflict, which is resolved incorrectly: the resulting parser fails to ...
5
votes
3
answers
131
views
I need a Raku grammar to change itself based on a different match
I want to write a Raku grammar to check a monthly report about work contribution factors, written in Racket/Scribble.
The report is divided, at the highest level, into monthly sections, and beneath ...
1
vote
1
answer
56
views
Issue with parse order in ANTLR4 grammar
Below is a very simplified grammar to illustrate the problem. I likely can handle the existing result in generated code, but suspect there is some more elegant way to instead control the parser. ...
2
votes
1
answer
49
views
Can an SLR(1) Parser Have Accept/Reduce Conflicts?
Consider the following grammar:
S → A
A → S | a
This grammar would have an accept/reduce conflict in the SLR(1) parsing table in the state with the following kernel when reading the end symbol($):
...
1
vote
0
answers
34
views
Transform grammar of functional language to LL(1)
I am trying to transform a grammar for a functional language into an LL(1) one. I am erasing left recursion in favor of right recursion and then the first condition on non overlapping firstsets is ...
0
votes
2
answers
40
views
How to Restrict return Statements to Function Declarations in ANTLR Grammar?
Question:
I'm working on a custom parser using ANTLR to define a small programming language. One of the requirements is that return statements can only appear inside the body of a function. If a ...
1
vote
0
answers
52
views
How do you parse a Synchronous Context Free Grammar?
I am trying to parse a grammar of this type:
g = """
S -> A{1} B{2}, S -> B{2} A{1}
A -> A{1} A{2}, A -> A{2} A{1}
B -> B{1} A{2}, B -> A{2} B{1}
A -> a, A -> e
...
0
votes
1
answer
152
views
What do reduce/reduce and shift/reduce conflicts mean in terms of the grammar structure? [closed]
I have to construct LR(0) table to know if there are any sort of conflicts? Is there a way to look at the grammar and tell if there's a conflict without constructing the table? So yeah, the question ...
0
votes
1
answer
65
views
Parsing extended lambda calculus using recursive descent
I'm writing interpreter for simple lambda calculus based language in C. EBNF for language is
S ::= E
E ::= 'fn' var '->' E | T {'+' T} | T {'-' T}
T ::= F {'*' F} | F {'/' F}
F ::= P {P}
P ::= var |...
1
vote
1
answer
66
views
define equality predicate Lambda-Calculus nltk
I am trying to define a Lambda-Calculus representation of the word 'are', which is an equality predicate for this ccg:
ccg = '''
# CCG grammar
# complete the lexical entries with their categories and ...
0
votes
1
answer
26
views
Issue with LL(1) Grammar Transformation – Parser Generator Error
I am working on transforming a grammar into LL(1) form, but when I try to use an online LL(1) Parser Generator, it reports an error. I have followed the standard procedure for the transformation, but ...