Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to ignore a folder we directly add in the same commit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a deterrant, changes to this directory will have warnings, and developers will need to force add new files

Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,6 @@ _Pvt_Extensions/
ModelManifest.xml

.cache/

# Visual Studio Code
.vscode/
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"ms-vscode.cmake-tools", // CMake for Debugging C/C++
"llvm-vs-code-extensions.vscode-clangd", // Optional intellisense-like features with LLVM/clangd
"theodevelop.bison-flex-lang", // For flex/bison source files
],
}
34 changes: 34 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "lldb",
"request": "launch",
// Resolved by CMake Tools:
"program": "${command:cmake.launchTargetPath}",
// "--header-file=<output_header>", "-o<output_source>", "<input_source>"
"args": [],
"cwd": "${workspaceFolder}",
"terminal": "integrated",
"stopOnEntry": false,
// Non-Windows is unnecessary but it helps to ensure PATH correctly
"env": {
"PATH": "${env:PATH}:${command:cmake.launchTargetDirectory}"
},
"windows": {
// Warning: CodeLLDB is still slower than WinDbg (cppvsdbg) in Windows
// and don't support C++ (string/vector) for MSVC ABI - this codebase is C99
"env": {
"PATH": "${env:PATH};${command:cmake.launchTargetDirectory}"
}
},
"initCommands": [
"settings set target.process.follow-fork-mode parent"
]
},
]
}
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems those settings would best be user-scope, not specific to this workspace.
Please share your reasoning if your disagree.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workspace is the appropriate place for codebase consistency settings, unless that is something we don't want...

First is editor settings, most users have different settings which will make the codebase inconsistent, the proper way to have consistent code is clang-format, but that will format the whole code instead being just limited to the addtional lines introduced by developers; and will probably make it more difficult to sync with upstream.
Trailing whitespace is undesirable, for consistency and nothing much to explain further

Ruler indicator is just a mindful/useful indicator, I see GNU have an unwritten rule of 80 character line limit, but some codes go up to 120 chars in flex/bison, I'll say this is optional, I can remove this if you don't like to see these lines

The git operations are minimal and good to have for new developers, it helps to ensure git pull in vscode don't branch and merge, prune is optional as it helps to cleanup deleted branches in origin just that the code base is not super active at the moment

CMake preferred generator won't mess up the system as it only uses Ninja if its installed, although the codebase is small, it approximately halves the compilation time for debugging

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workspace is the appropriate place for codebase consistency settings, unless that is something we don't want...

Usually you don't want this, since users will mess with that around and accidentally push private & personal settings / metadata.

the proper way to have consistent code is clang-format, but that will format the whole code instead being just limited to the addtional lines introduced by developers

It doesn't necessarily format the whole base, you can just configure it to only format modified lines. And it's totally in the scope of the contributing developer.

@jonnysoe jonnysoe Mar 19, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Febbe ,

accidentally push private & personal settings / metadata

Personal settings stay within their user directory settings.json by default when changes are made from the GUI, so if the contributor manually does questionable changes for the code base, then catching questionable changes or they're justifiable is what reviewers are here for

It doesn't necessarily format the whole base

I don't recall git clang-format limits changes to the modified lines back in llvm 15

@Febbe Febbe Mar 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve been using git clang-format for much longer, and its sole purpose is to only operate on the modified lines.
There used to be a run-clang-format.py script that formatted everything.
Additionally, you can configure clangd in VS Code as the formatter for C/C++, and restrict it to formatting only modified lines. That has the same effect as git-clang-format as clangd linked clang-format into its server.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know of the extension being able to format by lines, I just couldn't get it to work when I use command line...

"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.detectIndentation": true,
"files.trimTrailingWhitespace": true,
"[markdown]": {
"files.trimTrailingWhitespace": false,
},
"editor.rulers": [80,120],
"git.rebaseWhenSync": true,
"git.pruneOnFetch": true,
// "cmake.preferredGenerators": ["Ninja Multi-Config"],
"cmake.generator": "Ninja Multi-Config",
"cmake.options.statusBarVisibility": "compact",
"cmake.useCMakePresets": "never",
"C_Cpp.intelliSenseEngine": "disabled",
}
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endforeach()
message(STATUS "Using /MT STATIC runtime")
endif ()

# MSVC's incremental linking is offering little to no benefit,
# disable it for faster link times (and prevent ilk binary bloat).
# NOTE: Frequent build with vscode is hitting resource busy for the the ilk files.
add_link_options("/INCREMENTAL:NO")
endif ()
endif ()

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ The release page includes the full Changelog but you may also see the [changelog

## HowTo

You may use win_flex and win_bison directly on the command line or [use them via CustomBuildRules in VisualStudio](custom_build_rules/README.md).
You may use `win_flex` and `win_bison`:
- directly on the command line
- [via CustomBuildRules in VisualStudio](custom_build_rules/README.md).
- via [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) in [vscode-like editors](vscode/README.md).


## Example flex/bison files
Expand Down
Binary file added vscode/1_compiler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/2_target.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/3_build.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/4_breakpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/5_launch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vscode/6_pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions vscode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

# How to setup vscode-like editors for debugging win_flex/win_bison

Here is a simple guide (based on the [MS documentation](https://code.visualstudio.com/docs/cpp/cmake-linux)):
1. Make sure the [Prerequisites](https://code.visualstudio.com/docs/cpp/cmake-linux#_prerequisites) are installed.
2. [Select a compiler kit](https://code.visualstudio.com/docs/cpp/cmake-linux#_select-a-kit), any of the native `amd64` version of MSVC is recommended for compatibility - any of the rest with `x86` is cross-compiling a 32-bit version of `win_flex`/`win_bison`.

![Select a compiler kit](./1_compiler.png)

NOTE: Click `Scan for kits` when setting up C/C++ debugging for the first time if there is no compiler kits found yet.

3. Due to `win_flex`/`win_bison` being separate executables/targets, debugging will need to [select a launch target](https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/debug-launch.md#select-a-launch-target).

![Select a launch targe](./2_target.png)

4. Optionally switch between build types - usually between `Release` or `Debug` builds, make sure `Debug` is selected when debugging or there will be no debug symbols to hit breakpoints.

![Debug build type](./3_build.png)

5. Both `win_flex` and `win_bison` requires arguments for the target input/output source files, just add the arguments as how `win_flex` or `win_bison` was called from the command line where each space-separated argument is an element in [.vscode/launch.json](.vscode/launch.json)'s `args` array separated by commas, based on [flex-bison-example](https://github.com/meyerd/flex-bison-example),
- here is a sample for `win_flex` target:
```json
"args": [
"calc.l",
],
```
- here is a sample for `win_bison` target:
```json
"args": [
"-d",
"calc.y",
],
```
- NOTE: This example uses source files without full path was achieved by setting `cwd`
```json
"cwd": "${workspaceFolder}/../flex-bison-example",
```

6. Setup the codebase for inspection [debugging](https://code.visualstudio.com/docs/editor/debugging), eg. breakpoints (with `F9`), [logpoints](https://github.com/vadimcn/codelldb/blob/master/MANUAL.md#logpoints).

![Breakpoint](./4_breakpoint.png)

7. Hit `F5` to start debugging, or click the `launch` button.

![Launch](./5_launch.png)

8. Here is how it looks like when the program pauses at a breakpoint, refer to the official [Debugging guide](https://code.visualstudio.com/docs/debugtest/debugging#_debugger-user-interface) for more information.

![Pause](./6_pause.png)
Loading