ebnf

Scala Parser Combinators tricks for recursive bnf?

送分小仙女□ 提交于 2021-02-05 20:36:41
问题 Im trying to match this syntax: pgm ::= exprs exprs ::= expr [; exprs] expr ::= ID | expr . [0-9]+ My scala packrat parser combinator looks like this: import scala.util.parsing.combinator.PackratParsers import scala.util.parsing.combinator.syntactical._ object Dotter extends StandardTokenParsers with PackratParsers { lexical.delimiters ++= List(".",";") def pgm = repsep(expr,";") def expr :Parser[Any]= ident | expr~"."~num def num = numericLit def parse(input: String) = phrase(pgm)(new

How to parse Prometheus data

爱⌒轻易说出口 提交于 2021-02-04 21:43:08
问题 I have been able to obtain the metrices by sending an HTTP GET as follows: # TYPE net_conntrack_dialer_conn_attempted_total untyped net_conntrack_dialer_conn_attempted_total{dialer_name="federate",instance="localhost:9090",job="prometheus"} 1 1608520832877 Now I need to parse this data and obtain control over every piece of data so that I can convert tand format like json. I have been looking into the ebnf package in Go: ebnf package Can somebody point me the right direction to parse the

How to parse Prometheus data

不羁的心 提交于 2021-02-04 21:42:32
问题 I have been able to obtain the metrices by sending an HTTP GET as follows: # TYPE net_conntrack_dialer_conn_attempted_total untyped net_conntrack_dialer_conn_attempted_total{dialer_name="federate",instance="localhost:9090",job="prometheus"} 1 1608520832877 Now I need to parse this data and obtain control over every piece of data so that I can convert tand format like json. I have been looking into the ebnf package in Go: ebnf package Can somebody point me the right direction to parse the

How to denote at least one repetition in EBNF?

有些话、适合烂在心里 提交于 2020-04-18 06:27:10
问题 https://en.wikipedia.org/wiki/Extended_Backus–Naur_form The above article mentions that curly braces denote repetition of arbitrary times (incl. zero), while square brackets denote at most one repetition. What I want however, is at least one repetition - that is, a terminal or a nonterminal must appear at least once. Well I can describe it like that: production = nonterminal, { nonterminal }; But I thought the point of EBNF over BNF was to avoid the need of this kind of "hacks". The Wikipedia

AS3 Grammar: Most accurate

房东的猫 提交于 2020-01-31 05:12:19
问题 I'm looking for an accurate AS3 grammar (format in not an issue, but I presume ANTLR will feature the most) to use for a practice grammar I'm making. What is the most accurate grammar available for AS3? 回答1: I think this one is pretty accurate if you are looking for an ANTLR grammar: AS3.g This grammar has been originally developed a couple of years ago by Martin Schnable and then extended for the Meta-AS project. There are of course other ActionScript 3 parsers available as well, but they do

Is ANTLR an appropriate tool to serialize/deserialize a binary data format?

泪湿孤枕 提交于 2020-01-13 08:03:09
问题 I need to read and write octet streams to send over various networks to communicate with smart electric meters. There is an ANSI standard, ANSI C12.19, that describes the binary data format. While the data format is not overly complex the standard is very large (500+ pages) in that it describes many distinct types. The standard is fully described by an EBNF grammar. I am considering utilizing ANTLR to read the EBNF grammar or a modified version of it and create C# classes that can read and

What does the phrase “binds stronger” mean?

折月煮酒 提交于 2019-12-31 03:36:29
问题 I know this might be a newbie question, but I'm trying to make sense of this sentence(from a paper on a meta language that uses EBNF): Logical and (&) binds stronger than logical or (|). Before that it says: Conditions are: condition ::= condition (`&´ | `|´ ) condition | `!´ condition | relation relation ::= expression ( `=´ | `#´ | `<´ | `<=´ | `>´ | `>=´ ) expression thanks 回答1: This refers to precedence. In other words, if you have A & B | C , you really have (A & B) | C . Operations with

What does the phrase “binds stronger” mean?

社会主义新天地 提交于 2019-12-31 03:36:12
问题 I know this might be a newbie question, but I'm trying to make sense of this sentence(from a paper on a meta language that uses EBNF): Logical and (&) binds stronger than logical or (|). Before that it says: Conditions are: condition ::= condition (`&´ | `|´ ) condition | `!´ condition | relation relation ::= expression ( `=´ | `#´ | `<´ | `<=´ | `>´ | `>=´ ) expression thanks 回答1: This refers to precedence. In other words, if you have A & B | C , you really have (A & B) | C . Operations with

EBNF whitespacing in meta identifiers

孤街醉人 提交于 2019-12-25 06:40:51
问题 I looked at the ISO spec pdf for EBNF here (I couldn't find the official one except on the ISO website, where it appears to cost money), and I don't quite understand the whitespace. Does anyone know whether the official standards allow spaces in meta identifiers? Based off the meta identifier in the standards document (section 8.1), I would say no, but if you take a look at that same example in that same standards document, it appears to be saying yes. In the comment at the top of 8.1 in that

Project on flex and bison

旧城冷巷雨未停 提交于 2019-12-25 03:36:24
问题 I have used flex and bison in order to make a lexical analyzer and a parser for an EBNF grammar . This work is done! I mean, when i put a file with a program I write, I can see if the program has mistakes. If it doesn't, I can see the whole program in my screen based on the grammar i have used. I have no problem in this. Now, I want to use loop handling and loop unrolling. Which part should I change? The lexical analyzer? The parser? Or the main after the parser? And how? 回答1: Introduction As