Questions tagged [tatsu]

Use the [tatsu] tag for all questions related to the TatSu or Grako parser generators.

TatSu (the successor to Grako) is a tool that takes grammars in a variation of EBNF as input, and outputs memoizing (Packrat) PEG parsers in Python.

TatSu can also compile a grammar stored in a string into a tatsu.grammars.Grammar object that can be used to parse any given input, much like the re module does with regular expressions.

46 questions
0
votes
1 answer

I have a problem replacing ebnf rules with regex in a Tatsu grammar

I have developed a syntax checker for the Gerber format, using Tatsu. It works fine, my thanks to the Tatsu developers. However, it is not overly fast, and I am now optimizing the grammar. The Gerber format is a stream of commands, and this is…
0
votes
1 answer

Tatsu parser: lookahead syntax does not work in my case

Using Tatsu 5.7.0 Python package. I have a very simple structure to parse. Following is an example of text: AC 2092 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim…
robob
  • 1,739
  • 4
  • 26
  • 44
0
votes
1 answer

Float in Tatsu Python

I use TatSu as a python parser library (as intended) and used the "CalcMiniTutorial" to help to understand the buildup. Sadly I don't find a solution to declare float numbers. The tutorial uses number = /\d+/ ; for normal numbers but that wont work…
Kaneros
  • 13
  • 4
0
votes
1 answer

Reporting as many distinct syntax errors as there are in TatSu

I'm trying to implement an interpreter for a language that is first parsed by TatSu and then interpreted. I'd like to deliver to my end-users the functionality that my interpreter reports as many potential errors contained in the source of the…
apio
  • 154
  • 11
0
votes
1 answer

How do I get Tatsu to not consume the right bracket in the identifier name?

I have identifier defined as: identifier = /[A-zA-Z][A-zA-Z0-9_]*/ ; and arrayType as: arrayType = ARRAY LBRACK ~ typeList RBRACK OF componentType; so why is Tatsu deciding that 'ASCIIcode]' is an identifier and not an identity + right bracket in…
guidoism
  • 7,820
  • 8
  • 41
  • 59
0
votes
1 answer

Tatsu grammar parser and codegen producing two very different results

I'm working with TatSu, and the results I get from the codegen parser is very different from the one I get from when the parser is build directly. Consider the fairly simple grammar for dice notation: start = expression $; int = /-?\d+/ ; dice =…
0
votes
1 answer

How to implement the priority of expressions Bakus-Naur Form

There is a grammar of this kind described in the documentation: grammar = | ['()'] ['$'] {'#' &'#'} '#' | ['()'] {'#' &'#'} '#%' | ['()'] ['$'] {'0' &'0'} '0' | ['()'] {'0' &'0%'} '0%' | ['()'] ['$'] {'#' &'0'} {'0' &'0'}…
MadInc
  • 1
  • 3
0
votes
1 answer

AttributeError: 'tuple' object has no attribute 'asjson'

When I would like to test my EBNF grammar, I have the error : AttributeError: 'tuple' object has no attribute 'asjson' Code : if not filename or filename == '-': text = sys.stdin.read() else: with open(filename) as f: text =…
0
votes
1 answer

Use Generator CodeGen in Tatsu

I have generated Model code and parser from my Grammar but I can't modify model to generated code in python. My EBNF grammar is a script code like "C" syntax for translate file in XML or ANSI X12. It's a language specific and I would like to…
0
votes
1 answer

TatSu: yaml.representer.RepresenterError when dumping to YAML

I have a object model generated by TatSu after doing a successful parse. The model dumps to stdout using JSON format OK. But when I try to dump it to YAML, I get a RepresenterError exception. I am not sure how to solve this. The object model is…
user4979733
  • 3,181
  • 4
  • 26
  • 41
0
votes
1 answer

How to build preprocessor solution with Tatsu?

I'm writing a transpiler for Tiny C code to Python code, but I need to build a preprocessor solution to replace #define and manage compilator C directive (#ifdef, #else, #define...) I choose to use a pcpp module in Python but with no success... is a…
0
votes
1 answer

how define default rule in EBNF/Tatsu?

I have a problem in my EBNF and Tatsu implementation extract grammar EBNF for Tatsu : define ='#define' constantename [constante] ; constante = CONSTANTE ; CONSTANTE = ( Any | ``true`` ) ; Any = /.*/ ; constantename = (/[A-Z0-9_()]*/) ; When…
0
votes
1 answer

Parsing code with caseless keyword with Tatsu / grako

I try to parse Fortran code with keyword which are caseless with Tatsu h! Is there a smarter way to define the keyword caseless than these : @@ keyword :: integer INTEGER etc... Thanks
-1
votes
1 answer

How to get user id of a member in discord using javascript?

I have a discord server, i used tatsu bot to allow points members of my server based on how active they are. For that tatsu provides an api : https://dev.tatsu.gg/api/guilds#get-guild-member-points. But for that we need to get the member's discord…
Rio
  • 39
  • 1
-1
votes
1 answer

How to build YAML parser using tatsu python parser generator

How to build YAML parser using tatsu python parser generator? Parsing indent-based language like YAML is difficult, so I cannot achieve this.
Conao3
  • 171
  • 1
  • 3
  • 17