Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
1 answer
57 views

I am trying to parse code into AST. I want to keep minimum keywords and delimiters in the AST while keeping the semantics. In Python function definition def foo():, the last : is syntactically ...
xuehao-049's user avatar
5 votes
1 answer
139 views

Since we have no parentheses () in rust if and while conditions, there may be some ambiguous situations, e.g. while 0 > n {} {} is either parsed to be while (0 > n) {} and {} (2 statements), or ...
Mike Li's user avatar
  • 81
0 votes
0 answers
79 views

Having trouble understanding the ambiguity reported by Antlr4 (4.7.1): grammar Temp; start: expr; expr: IDENTIFIER '(' expr (',' expr)* ')' // function call | expr '.' slice2 ...
Slayer's user avatar
  • 111
0 votes
0 answers
84 views

I am trying to implement a parser for first-order logic formulas in Rust using pest (which seems to be the reference in Rust). Apparently, this library is not based on context-free grammars but on ...
Weier's user avatar
  • 1,439
0 votes
0 answers
329 views

I have individual verbs in a collection of String objects (thanks to How to find whether a word is a noun or a verb using Stanford parser?). Now for each, I would like to obtain the appropriate noun ...
velw's user avatar
  • 221
1 vote
0 answers
69 views

In the "Compiler Design in C" book, below is a table on a simple expression grammar. According to the below excerpts: Note that the grammar is recursive. For example, Production 2 has ...
yapkm01's user avatar
  • 3,811
3 votes
1 answer
99 views

Below code tokenises the text and identifies the grammar of each tokenised word. import nltk from nltk.tokenize import sent_tokenize, word_tokenize from nltk.corpus import wordnet as wn #nltk....
Ali's user avatar
  • 31
2 votes
1 answer
79 views

I wrote this grammar to describe a simple patch procedure we use at work, operating on source code files. Engineers check in files of the form: {ignored space} //find_start {possible comment or ...
Ryan Brothers's user avatar
0 votes
1 answer
81 views

how to remove this warning : warning(180): AlgoGrammar.g4:54:13: chars a-z used multiple times in set [A-Za-z_] warning(180): AlgoGrammar.g4:54:23: chars a-z used multiple times in set [A-Za-z0-9_] ...
elhinchi ammar's user avatar
1 vote
1 answer
113 views

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 ...
asci's user avatar
  • 11
3 votes
1 answer
103 views

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 ...
Dims's user avatar
  • 51.8k
0 votes
0 answers
31 views

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 ...
zaa's user avatar
  • 113
1 vote
1 answer
56 views

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 ...
DYZ's user avatar
  • 57.3k
5 votes
3 answers
153 views

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 ...
sailortailorson's user avatar
1 vote
1 answer
78 views

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. ...
Nils Kronqvist's user avatar
2 votes
1 answer
109 views

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($): ...
Missge8urt's user avatar
1 vote
0 answers
46 views

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 ...
minzl's user avatar
  • 11
0 votes
2 answers
59 views

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 ...
hdz1412's user avatar
1 vote
0 answers
77 views

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 ...
nic's user avatar
  • 115
1 vote
1 answer
535 views

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 ...
Pavel Averin's user avatar
0 votes
1 answer
92 views

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 |...
Dendrit's user avatar
1 vote
1 answer
80 views

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 ...
Julius's user avatar
  • 49
0 votes
1 answer
42 views

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 ...
Lucas Broering's user avatar
2 votes
0 answers
76 views

I am writing an antl4 grammar for splitting semicolon-separated statements. Below is a minimal version of the grammar. The full grammar has multiple types of comments, strings, identifiers, etc. The ...
Jeff B's user avatar
  • 141
0 votes
1 answer
28 views

In the following example, the input token 'AX' seems to cause errors for an unknown reason. The parse tree shows that other rule matches that contain register tokens such as 'DX' are working fine. I'...
Scooteroy's user avatar
1 vote
0 answers
50 views

When reading the field-content grammar specified in RFC9110 field-content = field-vchar [ 1*( SP / HTAB / field-vchar ) field-vchar ] I came to the conclusion that this grammar does allow the field ...
eRatio's user avatar
  • 11
1 vote
1 answer
66 views

Below is my pyparsing grammar for parsing the method signature of a Solidity function, and an example signature to parse: from pyparsing import Word, alphas, alphanums, oneOf, Group, Forward, ...
aram10's user avatar
  • 23
2 votes
2 answers
140 views

I have a processor trace output that has the following format: Time Cycle PC Instr Decoded instruction Register and memory contents 905ns 86 00000e36 00a005b3 c.add ...
ex1led's user avatar
  • 479
1 vote
1 answer
355 views

I am fairly new to the ANTLR grammar. Here is what I have in my g4 file: tptp_file : tptp_input* EOF; tptp_input : annotated_formula | include; annotated_formula : ...
apache's user avatar
  • 44
0 votes
0 answers
59 views

I need to define a grammar to parse the code below: P1 ATTACKS p2 // P1 represents a pawn in chess game and p2 represents an opponent pawn OR P1 DEFENDS P2 OR P1 IATTACKS p2,p3 OR P1 IDEFENDS P2,P3 ...
Luis Bueno's user avatar
0 votes
1 answer
89 views

I am trying to generate a parser using antlr4. My content seems quite simple. But let's have a look at my grammar first: Lexer: DOLLAR: '$' -> pushMode(VAR_MODE); // as soon as there's an "$&...
andre's user avatar
  • 1,768
2 votes
0 answers
91 views

I've written a C# program that takes a list of "Productions" (LHS nonterminal, RHS "recipe"), of a grammar, and applies these transformations on it to reduce the grammar to another ...
TheUbMunster's user avatar
1 vote
0 answers
62 views

I'm trying to update the default ANTLR TypeScript grammar since it seems to support only TypeScript up to version 2.7. One of the new constructions is the conditional types, which demanded me to alter ...
bczup's user avatar
  • 21
1 vote
1 answer
638 views

I would like to build a cpp parser using cpp and I'm using ANTLR4. I notice there is this 'grammar' section from the official github antlr grammar github and I've downloaded it. While opening the CPP ...
EggDi's user avatar
  • 13
0 votes
1 answer
89 views

Need to know, is it possible to generate parsers, lexers, listeners, etc, by importing subset-grammars? I see that the supergrammar subgrammar pattern is possible, but I'm not sure I see a true class ...
Michael W. Powell's user avatar
3 votes
1 answer
86 views

I have the following grammar defined in ANTLR4 (g4): grammar SimpleExpr2; expr: entityName '(' paramList ')' SEMICOLON; entityName: ENTITY_NAME; paramList: param (SEPARATOR param)*; param: ...
Cristian Jacob Jimenez's user avatar
0 votes
1 answer
108 views

I am developing a Fortran 2018 grammar in ANTLR4 using the ISO standard. I am encountering an issue during the lexing phase with some of the lexer rules. Specifically, certain keywords are being ...
Akhil Akkapelli's user avatar
0 votes
1 answer
107 views

"Suppose we have a grammar like this, where alpha could be any sequence of terminals and nonterminals: A -> A alpha | B We can rewrite this grammar as: A -> B A' A' -> alpha A' | ...
Will Ponczak's user avatar
0 votes
1 answer
127 views

I am writing a TextMate grammar for a syntax highlighting extension in VS Code, and I discovered that if I define match rules for constants, it matches them multiple times in a row. More specifically, ...
ERSUCC's user avatar
  • 70
2 votes
2 answers
169 views

In Postgres, does the EXISTS operator have the highest precedence of all? For example: SELECT 1 + EXISTS (SELECT 1)::int; It seems to be missing from the manual page. Though the highest one is ::, ...
David542's user avatar
  • 112k
0 votes
1 answer
48 views

In the following SQL statement: SELECT 1, myField, myField+1 FROM myTbl The third column is often referred to as an "operator expression". Is there a name for the type of ...
David542's user avatar
  • 112k
1 vote
1 answer
309 views

This is my Grammar: S → (S)S | ε while my input string, which I want to parse using SLR(1): ()() I tried making DFA with the method specified in this question, but I wasn't able to parse it :( SLR(1) ...
Abhishek upadhyay's user avatar
1 vote
0 answers
112 views

Python Pydantic models and EBNF (context free grammar) are two competing ways to have a LLM generate structured, sensible output. Although the links reference the Outlines library, I am also curious ...
b_dev's user avatar
  • 2,616
1 vote
1 answer
241 views

I want to take a group of words, ideally at least 100, and then get sentences that actually make sense. Any grammar check API I've seen can correct sentences if they are in a form that at least ...
user24883689's user avatar
1 vote
1 answer
116 views

I'm new to Bison and I'm trying to write a parser. I already wrote a scanner in flex. I came up with the following grammar for the parser: %token NUMBER %token IDENTIFIER %start Program %% Program: ...
flying_pinguin's user avatar
0 votes
0 answers
36 views

I am currently trying to write a parser in lex and yacc to parse all valid time formats. The relevant .l and .y codes are included below. ^[0-9]{1,2} { printf("HOUR: %s\n", yytext); return ...
Ash Ketchum's user avatar
0 votes
0 answers
84 views

I'm trying to modifying this grammar to parse Solidity comments. I want to obtain two type of comment: multi-line comment, that is in the form '/* any string */', and the single-line comment, that is ...
Stefano Cappai's user avatar
0 votes
1 answer
62 views

This is something I tried out in ipython the behavior is quite clear: when creating the dictionary in lines 3 and 6, the dictionaries are created as if invoked by dict(**kwargs) and the kwargs are ...
pbhowmick's user avatar
  • 1,123
0 votes
1 answer
105 views

I have been working this grammar for several days now, with various improvements, but I am now parsing many files, some with syntax errors and stack overflow errors (which I or AI has fixed). Now I'...
John Carlson's user avatar
0 votes
1 answer
361 views

I am doing a problem where I am applying pumping lemma to the CFL L = {a^nb^nc^n : n >= 0}. Here is the start of a proof I was looking at: Assume L is a CFL, so there exists a pumping length p for ...
papayaaa's user avatar

1
2 3 4 5
67