sueden.social ist einer von vielen unabhängigen Mastodon-Servern, mit dem du dich im Fediverse beteiligen kannst.
Eine Community für alle, die sich dem Süden hingezogen fühlen. Wir können alles außer Hochdeutsch.

Serverstatistik:

1,8 Tsd.
aktive Profile

#parser

2 Beiträge2 Beteiligte0 Beiträge heute

#commonLisp host language simple #parser #programming of #emacs #orgmode orgfiles.

I suspect I've got several things grievously wrong. For one, my parser is #typetheory -etic. And the recursion is more of an ascent than a descent.

screwlisp.small-web.org/progra

Still, it's interesting to see what an s-expression-ised org file is and is not.

Also some notes on the Karl Voit interview on org versus markdown this Sunday morning (Europe)

Comments solicited @dougmerritt @mdhughes @kentpitman and all.

screwlisp.small-web.orgWIP common lisp org-file parser (is this a parser? What kind of parser?)

I'm starting a series of blog posts, in which I write a #bytecode #compiler and a #virtualMachine for arithmetic in #Haskell. We explore the following topics in the series:

- Parsing arithmetic expressions to ASTs.
- Compiling ASTs to bytecode.
- Interpreting ASTs.
- Efficiently executing bytecode in a VM.
- Disassembling bytecode and decompiling opcodes for debugging and testing.
- Unit testing and property-based testing for our compiler and VM.
- Benchmarking our code to see how the different passes perform.
- All the while keeping an eye on performance.

The first post of the series that focuses on writing the #parser is now out: abhinavsarkar.net/posts/arithm

abhinavsarkar.net · A Bytecode VM for Arithmetic: The Parser
Mehr von Abhinav 🌏

Tạo trình phân tích từ vựng (lexical parser) bằng Flex. Cài đặt: `sudo apt update && sudo apt upgrade && sudo apt install flex`. Hướng dẫn tạo file .l, định nghĩa quy tắc và hàm `main()` để nhận diện số, chuỗi,... Biên dịch và chạy. #lex #flex #parser #trìnhphântíchtừvựng #lập_trình #programming #code #dev

dev.to/taey/implement-a-lexica

DEV CommunityImplement a lexical parserTo implement a lexical parser, we will use a tool called Fast Lexical Analyzer Generator (flex or...

Okay, added a few more features and I'm really liking the results. I added the `-` operator for `dice_groups` which was a bit more tricky than I thought it'd be. I also added the ability to roll a dice group multiple times via a `x`|`*` operator. I removed the requirement that a dice group has to have a damage type associated with it since the only way you can roll something like `1d4-1` is in a dice group since there is a minimum value of 1 associated with it.

The code lives here: codeberg.org/JamesTheBard/dice

#python#lark#parser

Okay, _now_ I'm done. Fixed a few parser errors and implemented a skew option (the `^` value) that will push the average value towards either 1 or the maximum of the dice. I like that once you get the parser up and running that it's easy to add stuff to it. I now am the official owner of a completely overkill dice running program.

For the example below, the skew is `2.0`. The random value is raised to the `1/skew` power before being multiplied by the number of sides of the die. If skew goes up, so do the results. If skew goes down, well, so do the results.

```
$ python main.py "^2 (2d6+2d8+12)[fire]+1d8[piercing]" | jq .
{
"results": {
"fire": 37,
"piercing": 7
}
}
```

#python#statistics#ttrpgs

QapGen: Создаём мощные парсеры на C++

QapDSLv2 — это язык который транслируется в обычный C++ код. Он позволяет удобно и компактно задавать грамматики/правила разбора кода программ, значительно упрощая разработку компиляторов/анализаторов/трансляторов. QapGen — это генератор дерева_лексеров /парсеров описанных на QapDSLv2. Сама грамматика QapDSLv2 описана на QapDSLv2 на 100%. Поэтому QapGen как основной читатель этой грамматики сам генерирует часть своего кода(весь парсер QapDSLv2). Основные фишки QapDSLv2 + QapGen — это: 1) Отсутствие этапа токенизации — дерево лексеров разбивает входной поток на лексемы и сохраняет их в строго типизированных древовидных С++ структурах пропуская этап токенизации. 2) Генерация оптимизированного кода полиморфных лексеров . 3) Полное сохранение всех лексем(даже разделители сохраняются, такие как пробелы/переходы на новую строку и комментарии) в результирующем дереве. 4) Возможность сохранить как оригинальное дерево , так и модифицированное обратно в код/текст без потери разделителей/комментариев . 5) Автоматическая генерация кода посетителей (это такой паттерн проектирования). А теперь пример самой сочной части(рекурсивно самоописывающийся код): struct t_target_struct:i_target_item{ struct t_keyword{ string kw=any_str_from_vec(split("struct,class",",")); " "? // optional separator }; struct t_body_semicolon:i_struct_impl{";"}; struct t_body_impl:i_struct_impl{ "{" // жрём скобочку vector<TAutoPtr<i_target_item>> nested?; // рекурсия! " "? vector<TAutoPtr<i_struct_field>> arr?; // парсим поля " "? TAutoPtr<t_cpp_code> c?; // остальной С++ код " "? "}" }; struct t_parent{ string a_or_c=any_str_from_vec(split("=>,:",",")); " "? t_name name; }; //точка входа в парсер: TAutoPtr<t_keyword> kw?; //парсим struct/class t_name name; //парсим имя " "? TAutoPtr<t_parent> parent?; " "? TAutoPtr<i_struct_impl> body; };

habr.com/ru/articles/925420/

#parser #parsergenerator #lexers #c++ #tree #ast #gamedev #dsl #compiler

ХабрQapGen: Создаём мощные парсеры на C++QapDSLv2 — это язык который транслируется в обычный C++ код. Он позволяет удобно и компактно задавать грамматики/правила разбора, значительно упрощая разработку компиляторов и анализаторов. QapGen —...