41 questions
0
votes
0
answers
18
views
Inconsistent behaviour by textx in reading a variable
While coding a language in textx, I have the following rules:
'has input format ' format=FormatType
FormatType:
"hh:mm:ss AM/PM" | "YYYY-MM-DD HH:mm:ss"
While specifying the ...
1
vote
1
answer
26
views
Unexpected behaviour of numeric value conversion
I have the following rule in textx:
IsLessThanOrEqualToRule:
'is <= ' reference_value_input = FLOAT | INT
;
This rule allows the DSL user to specify a reference numeric value as a float or an ...
0
votes
1
answer
36
views
TextX Grammer Rule for CStyle Comments
I'm trying to make a textx grammar that will include a the ability to have single line comments like a c/c++ source file. e.g.
//this is a comment
This is the grammar I have developed to test this. ...
1
vote
1
answer
74
views
typechecking for textx models
I am trying out a prototype for a language using the textx module for python that can interpret grammars.
I am creating a model like this:
from textx import metamodel_from_str
funl_grammar = "&...
0
votes
1
answer
43
views
Trouble with Island Grammar parsing unordered network configuration using Python textx
Using Python's textx library I am having trouble capturing exactly what I want from a network configuration file. I can capture the interface and its attribute information, but I want textx to do ...
0
votes
2
answers
197
views
How to make python textx parse Island Grammars
I am trying to parse a network device configuration file, and though I would be going through the whole file, I will not want to include all the terms of the file, but only a subset.
So assume that ...
0
votes
1
answer
77
views
Grammar file for key=value pairs
I’m attempting to define a grammar file that parses the following:
Section0:
Key0 = “Val0”
Key1 = “Val1”
…
My attempts thus far have just resulted in one long concatenation string with no real ...
0
votes
1
answer
58
views
textX Ignore Text Before First Record
I'm working on writing a parser for an existing file format, and the trouble is that the syntax does not have a way of indicating what is a comment other than the fact that everything that is not a ...
1
vote
1
answer
98
views
TextX state machine model not getting parsed properly
I am trying to build a state machine for microwave oven. I am designing it such that it has only two functionalities as of now : bake and clean. It will have 3 states: idle, baking and cleaning. While ...
0
votes
1
answer
166
views
Why does TextX ignore \n in string literal, but not in regex?
TL;DR: The issue will be fixed in version 3.0 of TextX. The workaround is to use regex for matching escaped (\) characters, such as \n.
FULL QUESTION: Using TextX, I am parsing a homegrown mark-up ...
1
vote
1
answer
123
views
How to parse a Windows file path in textX?
I need to parse through a file path in Windows, make sure I have provided a csv file. I have tested the regex in an online regex generator and made sure it matches the text I provide it.
Program.tx:
...
1
vote
1
answer
82
views
How to use a link rule reference in an ordered choice expression in a TextX grammar?
I am new to TextX. I am trying to create a grammar for defining data types that have fields that could be of a simple type or of the type of another data type. The grammar description is:
Library:
...
1
vote
1
answer
278
views
How to make a textX grammar recognize normal strings and special keywords
I feel like I am missing something very simple. I am trying to create a textX grammar that would make my parser to recognize normal text tokens vs special keywords. In the following grammar, I cannot ...
1
vote
1
answer
51
views
How to get textX model to treat fifth test case as separate line
Sample code that is failing when adding the fifth test line to the input variable. Leave the fifth line out and the model works.
from textx import metamodel_from_str
mm = metamodel_from_str('''
File:
...
0
votes
1
answer
118
views
How to parse keywords and strings from a line of text
Have a file keywords.tx with
Commands:
keywords = 'this' & 'way'
;
StartWords:
keywords = 'bag'
;
Then a file mygram.tx with
import keywords
MyModel:
keyword*=StartWords[' ']
...
1
vote
1
answer
104
views
textx Grammar, Use Whitespace as Repetition Modifier
I'm trying to write a parser for input files used by Fire Dynamics Simulator using textx. For the most part, ignoring the whitespace is perfect as most parameters and values should be separated by ...
0
votes
1
answer
275
views
Python Typing: How to Reference Dynamically Created Class in Type Hints
I'm trying to have an iterable of TextXClass instances for the implementation part of my meta-model but since that class is created dynamically, I'm out of luck. Is there still some clever way to type ...
2
votes
2
answers
148
views
Python method for rapidly producing custom synthesized tonal sequences from a terminal window
I'm trying to design a method for generating audio signals rapidly. I need this for electrophysiological experiments in which I will play tone sequences for the purpose of examining neuronal responses ...
0
votes
1
answer
56
views
Reference attribute in parent
I'm trying to write a small DSL for translating classes from one domain to another where the classes and attributes are mostly the same but with some attribute names may be different. For example, the ...
1
vote
1
answer
38
views
How does TextX defines boundaries between words?
Consider the following made up example with 3 rules.
Model: id_1=Ident 'is' id_2=Ident;
Keyword: 'is';
Ident: !Keyword ID;
It seems like TextX cannot parse inputs where id_2 starts with "is",...
3
votes
1
answer
118
views
TextX retreiving object parent types
Assume that we have two rules like this in our grammar:
Value: AttributeReference | PrimitiveValue;
PrimitiveValue: BoolValue | StringValue | IntValue;
I want to implement a code generator for this ...
1
vote
1
answer
119
views
How to limit repetitions in textx grammar?
I'm trying to create a grammar in textx.
The syntax should look like this:
name_a
name_a, name_b
name_a, name_b: name_c, *
name_a, name_b: name_c, *, name_d
*, name_d
*
Where asterisk (*) means "...
-1
votes
1
answer
61
views
Parsed TextX Model does not have `commands` attribute
I parsed text using TextX. When I want to process the commands using a for loop, I get THIS:
grammar.tx
Traceback (most recent call last):
File "C:/Users/user/SomerandomIDE/program/program/parser....
1
vote
1
answer
289
views
MemoryError when loading model
When I try to load the model (input, not meta-model), it returns a MemoryError about 30 seconds after executing.
Expected: List of tree: [{'type':'func', 'callee':'print', 'args':[['Hello']]}]
Actual:...
2
votes
1
answer
126
views
Nested expressions causes stack overflow
I am facing a problem that you guys can probably help me solve.
I am trying to parse a grammar that contains this :
Expr: BinOp | Name | Constant ;
Name: id=ID ;
Constant: value=INT ;
BinOp: left=...
1
vote
1
answer
116
views
How do you correctly mix textx skipws/non-skipws?
I want to use textx to parse "foo bar." differently to "foo bar ." (tying the '.' to the last word if there's no space, but still parsing the '.' separately).
I would have thought the following would ...
1
vote
1
answer
109
views
Is it possible to use a link rule reference in a lookahead fashion?
I am attempting to use textx in order to parse a language similar to SQL. I would like to use link rule references in order to reference aliases before they are declared.
I get an "Unknown Object of ...
2
votes
1
answer
127
views
textX: How to generate object names with ObjectProcessors?
I have a simple example model where I would like to generate names for the objects of the Position rule that were not given a name with as <NAME>. This is needed so that I can find them later ...
2
votes
0
answers
72
views
How to semantically validate textX models?
I have a set of quite complex textX meta-models that I use for parsing files and creating models with. This involves using different custom scope providers.
I would like to verify the produced model ...
0
votes
1
answer
76
views
Lookahead inside or clause failing in textx
The following throws an exception for me (on line 9), complaining that Expected '.' at position (5, 15) => 'k foo bar *end '.:
mm = metamodel_from_str('''
File: Line*;
Line: Block | Sentence;
...
1
vote
1
answer
395
views
How to parse expression with parenthesis?
I would like to parse an expression with parenthesis in python using textx.
For example the following DSL :
CREATE boby = sacha - ( boby & tralaa) ;
CREATE boby = sacha & boby - ( david &...
0
votes
1
answer
428
views
How to write a textx grammar rule to detect standard datatypes without modifying them?
I want to write a textx grammar rule that can consists of either another defined rule or any kind of standard datatype (Int, Float, String etc.).
This is for a simple textx DSL which should have the ...
0
votes
1
answer
84
views
Re-generating model file with textx
I'm new with DSL and I'm not sure if it's possible the tasks that I want to do with textx:
I already have language description textX (ex: hello.tx)
Load an initial model file for this language (ex: ...
1
vote
1
answer
241
views
Methods of creating syntax highlighting in textX?
As I cannot find any guidelines about syntax highlighting, I decided to prepare simple write-as-plain-text-and-then-highlight-everything-in-html-preview, which is enough for my scope at the moment.
...
0
votes
1
answer
305
views
How to adapt java POJO generator for Django model with custom methods?
I am done with this tutorial which shows how to use textX to write a java POJO.
I am thinking of adapting this to write Django model classes.
The issue is when I have to add custom model methods to ...
1
vote
2
answers
107
views
ModuleNotFoundError when running functional python tests despite that textX command works
I followed the set of instructions for this open source.
At step 3, I am supposed to run
py.test tests/functional/
When I do so, I get
ModuleNotFoundError: No module named 'textx'
However, when I ...
0
votes
1
answer
173
views
Is it possible to add comments to .tx files for textx? If so, how?
Was working through the hello-world example in the docs.
I then realized I wanted to add comments to help me learn the textX syntax better.
There's no indication that this is possible in the first ...
2
votes
1
answer
939
views
Parsing dhcpd.conf with textX
I'm using https://github.com/igordejanovic/textX to parse dhcpd.conf file (no, https://pypi.org/project/iscconf/ does not work for me, it crashes on my dhcpd.conf file), specifically extract hosts ...
0
votes
1
answer
116
views
Read literal from meta model
I want to ask if it is possible to read - from my Python code - a literal which I have defined in the meta model. This may be best explained with an example. Lets say this is my meta model (inspired ...
1
vote
2
answers
487
views
Overcoming infinite left recursion in TextX parser
I am writing a parser for an existing language, using the TextX Python Library (based on the Arpeggio PEG parser)
But when I try to use it to parse a file, I get the exception:
RecursionError: ...
0
votes
1
answer
147
views
How to Reuse Textx Model
I'm using textx (documentation) as DSL parser and my application would greatly benefit from re-use of both textx metamodels and models.
I tried with pickle, but I realized I can't pickle textx ...