Commit Graph

20323 Commits

Author SHA1 Message Date
Daniel Bertalan
22195d965f DevTools: Add StateMachineGenerator utility
This program turns a description of a state machine that takes its input
byte-by-byte into C++ code. The state machine is described in a custom
format as specified below:

```
// Comments are started by two slashes, and cause the rest of the line
// to be ignored

@name ExampleStateMachine // sets the name of the generated class
@namespace Test           // sets the namespace (optional)
@begin Begin              // sets the state the parser will start in

// The rest of the file contains one or more states and an optional
// @anywhere directive. Each of these is a curly bracket delimited set
// of state transitions. State transitions contain a selector, the
// literal "=>" and a (new_state, action) tuple. Examples:
//     0x0a => (Begin, PrintLine)
//     [0x00..0x1f] => (_, Warn)      // '_' means no change
//     [0x41..0x5a] => (BeginWord, _) // '_' means no action

// Rules common to all states. These take precedence over rules in the
// specific states.
@anywhere {
    0x0a         => (Begin, PrintLine)
    [0x00..0x1f] => (_, Warn)
}

Begin {
    [0x41..0x5a] => (Word, _)
    [0x61..0x7a] => (Word, _)
    // For missing values, the transition (_, _) is implied
}

Word {
    // The entry action is run when we transition to this state from a
    // *different* state. @anywhere can't have this
    @entry IncreaseWordCount
    0x09 => (Begin, _)
    0x20 => (Begin, _)

    // The exit action is run before we transition to any *other* state
    // from here. @anywhere can't have this
    @exit EndOfWord
}
```

The generated code consists of a single class which takes a
`Function<Action, u8>` as a parameter in its constructor. This gets
called whenever an action is to be done. This is because some input
might not produce an action, but others might produce up to 3 (exit,
state transition, entry). The actions allow us to build a more
advanced parser over the simple state machine.

The sole public method, `void advance(u8)`, handles the input
byte-by-byte, managing the state changes and requesting the appropriate
Action from the handler.

Internally, the state transitions are resolved via a lookup table. This
is a bit wasteful for more complex state machines, therefore the
generator is designed to be easily extendable with a switch-based
resolver; only the private `lookup_state_transition` method needs to be
re-implemented.

My goal for this tool is to use it for implementing a standard-compliant
ANSI escape sequence parser for LibVT, as described on
<https://vt100.net/emu/dec_ansi_parser>
2021-05-16 11:50:56 +02:00
Nicholas Baron
aa4d41fe2c
AK+Kernel+LibELF: Remove the need for IteratorDecision::Continue
By constraining two implementations, the compiler will select the best
fitting one. All this will require is duplicating the implementation and
simplifying for the `void` case.

This constraining also informs both the caller and compiler by passing
the callback parameter types as part of the constraint
(e.g.: `IterationFunction<int>`).

Some `for_each` functions in LibELF only take functions which return
`void`. This is a minimal correctness check, as it removes one way for a
function to incompletely do something.

There seems to be a possible idiom where inside a lambda, a `return;` is
the same as `continue;` in a for-loop.
2021-05-16 10:36:52 +01:00
Ali Mohammad Pur
bbaa463032 LibLine: Make line management less broken when at the last line
Previously, all sorts of weird stuff would happen when the editor was at
the last line of the terminal (or when the printed line would be at the
last line), this commit makes the editor scroll the terminal up before
trying to write to a row that doesn't actually exist (yet).
This fixes ^R search making a mess when initiated at the last line
(especially with multiline prompts).
2021-05-16 10:11:56 +01:00
Idan Horowitz
3f08e957d4 Meta: Add a check for periods on the end of titles to commit linter 2021-05-16 01:25:24 +01:00
spigwitmer
04f26183cb
Debugger: Add basic backtrace support
This adds the "bt" command to the debugger which displays a backtrace
of the current thread.
2021-05-16 00:47:01 +01:00
Stephan Unverwerth
f70a6ff712 LibGL: Implement color blending
This implements different blend modes in the SoftwareRasterizer by
first setting up the blend factors then rendering the pixels into a
temporary buffer and finally mixing the contents of the temporary buffer
with the contents of the backbuffer based on the blend factors.
2021-05-16 00:44:31 +01:00
Stephan Unverwerth
d6e9b433cf LibGL: Add support for GL_BLEND in glEnable() and glDisable() 2021-05-16 00:44:31 +01:00
Stephan Unverwerth
279737642c LibGL: Add defines and stubs for glBlendFunc() 2021-05-16 00:44:31 +01:00
Stephan Unverwerth
1b358d3b94 LibGL: Add missing GLAPI function specifiers 2021-05-16 00:44:31 +01:00
Linus Groh
84b4b06c4b Meta: Discourage commit subject lines ending with a period 2021-05-16 00:33:47 +01:00
Andreas Kling
10ea84a815 PixelPaint: Wrap the layer list in a GUI::GroupBox and tweak width 2021-05-16 01:11:56 +02:00
Andreas Kling
6c2c3b920e PixelPaint: Style the application name as "Pixel Paint" :^) 2021-05-16 01:11:56 +02:00
Andreas Kling
c7244e37eb PixelPaint: Start with a smaller new image (and smaller window)
We started this app with an overwhelmingly huge window. Shrink it.
2021-05-16 01:11:56 +02:00
Andreas Kling
4c186d1f44 PixelPaint: Stop creating two blue and yellow layers on startup
This was nice for testing, but let's start the app with just a white
background layer instead. :^)
2021-05-16 01:11:56 +02:00
Andreas Kling
5579ec767e PixelPaint: Add a statusbar to the main window 2021-05-16 01:11:56 +02:00
Andreas Kling
864392254e PixelPaint: Tweak height of palette widget 2021-05-16 01:11:56 +02:00
Andreas Kling
01d88f1b31 PixelPaint: Wrap the toolbox widget in a GUI::ToolbarContainer
This makes it consistent with the main toolbar and looks quite nice.
2021-05-16 01:11:56 +02:00
Andreas Kling
c7c273c31d PixelPaint: Add a toolbar to the main UI :^) 2021-05-16 01:11:56 +02:00
Andreas Kling
5b6d879721 PixelPaint: Tweak placement of current colors in palette widget 2021-05-16 01:11:56 +02:00
Andreas Kling
8c044d4f52 PixelPaint: Convert main UI to GML :^) 2021-05-16 01:11:56 +02:00
Andreas Kling
afc3ed228d PixelPaint: Make the color palette widgets smaller and square 2021-05-16 01:11:56 +02:00
Andreas Kling
ad2752276a PixelPaint: Use GUI::Toolbar inside the toolbox widget
We don't need to implement our own toolbar and tool button classes
when the ones from LibGUI work just fine. :^)
2021-05-16 01:11:56 +02:00
Andreas Kling
0ee7991dca LibGUI: Tweak GUI::Button::on_context_menu_event hook signature
Pass the ContextMenuEvent as a mutable reference, so that clients
want to accept/ignore the event.
2021-05-16 01:11:56 +02:00
Andreas Kling
5daf7bd2ef LibGUI: Make GUI::Toolbar::add_action() return the toolbar button
Previously there was no easy way for clients to access the button.
2021-05-16 01:11:56 +02:00
Brendan Coles
a6ec024352 Utilities: Add errno utility 2021-05-15 23:51:50 +01:00
Sahan Fernando
cbc845c8a8 Kernel: Reorder VirtIODevice PCI initialization steps
We can't reset the device before we've read the PCI configuration
space, because we read the reset register location from the
configuration space.
2021-05-15 23:29:03 +01:00
Sahan Fernando
7cf34b5549 Kernel: Rename VirtIODevice::clear_status_bit to mask_status_bits 2021-05-15 23:29:03 +01:00
Itamar
35d28b29b3 CppLanguageServer: Fix syntax of a test case program 2021-05-15 23:28:50 +02:00
Itamar
c54238f65c CppLanguageServer: Make autocomplete logic consider scopes
When returning autocomplete suggestions, we now consider the scope of
the name that is being completed.

For example, when requested to complete an expression like
'MyNamespace::', we will only suggest things that are in the
'MyNamespace' namespace.

This commit also has some general refactoring of the autocomplete
logic.
2021-05-15 23:28:50 +02:00
Itamar
0e51aea781 LibCpp: Modify parsing of a Name's scope
A Name node can now have a non-empty scope and a null name.

For example, "AK::" has a non-empty scope and a null name component.
2021-05-15 23:28:50 +02:00
Itamar
9408013177 CppLanguageServer: Only re-create DocumentData in file_opened if needed 2021-05-15 23:28:50 +02:00
Itamar
84e41c4565 LibCpp: Modify logic of Parser::index_of_node_at
After this commit, Parser::index_of_node_at will prefer to return nodes
with greater indices.

Since the parsing logic ensures that child nodes come after parent
nodes, this change makes this function return child nodes when possible.
2021-05-15 23:28:50 +02:00
Itamar
f9b8e9c01c CppLanguageServer: Autocomplete namespaces 2021-05-15 23:28:50 +02:00
Itamar
f89f4af0b3 CppLanguageServer: Don't suggest inaccessible declarations
Previously, declarations that are not available in the global
namespace, such as member functions of a class, would also appear in
the autocomplete suggestions list.

To fix this, we now only recurse into scopes of namespaces and classes
when fetching declarations if we want to retrieve all the available
declarations in the document (For the use of Locator & ClassView).
2021-05-15 23:28:50 +02:00
Alexander Richards
ab8aa591f9
Documentation: Add my machine to hardware compatibility list (#7152) 2021-05-15 22:55:23 +02:00
Luke
4b61062785 Documentation: Add a working notebook to Hardware Compatibility List
This notebook started working with the recent AHCI fixes.
2021-05-15 22:53:06 +02:00
Idan Horowitz
227b1d4133 Documentation: Add a tested motherboard to Hardware Compatibility list
This motherboard and cpu combo now boots correctly into graphical mode
as a result of the recent fixes for AHCI and HPET.
2021-05-15 20:44:29 +01:00
Andreas Kling
4d429ba9ea Kernel: Unbreak profiling all processes
Regressed in 8a4cc735b9.
We stopped generating "process created" when enabling profiling,
which led to Profiler getting confused about the missing events.
2021-05-15 21:25:54 +02:00
Andreas Kling
19a696e397 ImageViewer: Use GUI::CommonActions for zoom related actions 2021-05-15 20:36:41 +02:00
Andreas Kling
c6b44e215a PixelPaint: Use GUI::CommonActions for zoom related actions 2021-05-15 20:36:41 +02:00
Andreas Kling
55dead60b5 LibGUI: Add CommonActions helpers for "zoom in/out" and "reset zoom" 2021-05-15 20:36:41 +02:00
Luke
57277d8a5c Kernel/AHCI: Fix "received" => "recovered" typo in communication error
The error is actually "Recovered communications error" instead of
"Received communications error".
2021-05-15 19:45:44 +02:00
Luke
174fdddc2b Kernel/AHCI: Get BOH and NVMP from extended capabilities
It was accidentally getting it from the regular capabilities.
2021-05-15 19:45:44 +02:00
Alexander Richards
88a997871e
AHCIController: Fix off-by-one mistake (#7144)
Fixes off-by-one caused by reading the register directly
without adding a 1 to it, because AHCI reports 1 less port than
the actual number of ports supported.
2021-05-15 19:45:23 +02:00
Linus Groh
0fb96e6cbf GameOfLife: Spell about action app name as "Game Of Life" 2021-05-15 17:55:49 +01:00
Linus Groh
9f9f54a9ad GameOfLife: Add separator before quit menu action 2021-05-15 17:55:27 +01:00
Linus Groh
310ec73550 GameOfLife: Add alt shortcuts to menus 2021-05-15 17:54:50 +01:00
Linus Groh
2225e18749 GameOfLife: Rename primary menu to just "Game" 2021-05-15 17:52:58 +01:00
Andres Crucitti
d99991e39c Games: Add GameOfLife
This patch introduces a new game based on Conway's Game of Life.
2021-05-15 17:44:21 +01:00
Sahan Fernando
e4f61c6f28 Kernel: Fix return values of BXVGADevice::read/write 2021-05-15 17:43:45 +01:00