This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
#region StateMachine | |
static ServiceController() | |
{ | |
Define(() => | |
{ | |
Initially( | |
When(OnStart) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Name: container_of | |
* Parameters: ptr - Pointer to the inner structure that you have. | |
* Parameters: type - The type of outer structure you want to have. | |
* Parameters: member - The member in the outer structure for the inner. | |
* Returns: type * - Pointer to the outer structure you wanted. | |
* Description: | |
* This is a macro used to get to a child structure when you have a pointer | |
* to the root structure. Notice that this makes no checks or validation. | |
* Use when you know what you have and what you want. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" When we fold or unfold a block of text determine the block | |
" delimiters via syntax. You can use 'za' to toggle a fold. | |
" There are several other commands as well. | |
" 'zM' to close all folds | |
" 'zR' to open all folds | |
set foldmethod=syntax | |
" Lets map 'za' to spacebar while in NORMAL mode | |
nnoremap <space> za<space> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[0-9]+ : | |
{token, {number, TokenLine, list_to_integer(TokenChars)}}. | |
[0-9]+\.[0-9]+ : | |
{token, {number, TokenLine, list_to_float(TokenChars)}}. | |
\+ : {token, {'+', TokenLine}}. | |
\- : {token, {'-', TokenLine}}. | |
/ : {token, {'/', TokenLine}}. | |
\* : {token, {'*', TokenLine}}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nonterminals expression. | |
Terminals number '+' '-' '/' '*' '(' ')'. | |
Rootsymbol expression. | |
Endsymbol '$end'. | |
Left 300 '+'. | |
Left 300 '-'. | |
Left 400 '*'. | |
Left 400 '/'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(generator). | |
-export([generate/1]). | |
generate([Root, Left, Right]) -> | |
LeftExp = generate(Left), | |
RightExp = generate(Right), | |
RootExp = generate(Root), | |
LeftExp ++ RightExp ++ RootExp; | |
generate({number, _Line, Value}) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ok, Tokens, _EndLine} = lexical:string("2 + 1 * 3"). | |
{ok, Ast} = grammar:parse(Tokens). | |
Program = generator:generate(Ast). | |
vm:start(). | |
vm:load(Program). | |
vm:stop(). | |
receive {return, Value} => Value end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class HtmlHelperExtensions | |
{ | |
public static PhoneHtmlBuilder<TModel> Phone(this HtmlHelper<TModel> helper) | |
{ | |
return new PhoneHtmlBuilder<TModel>(helper); | |
} | |
//... a bunch of other things | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PhoneHtmlBuilder<TModel> | |
{ | |
private HtmlHelper<TModel> _helper; | |
private Expression<Func<TModel, string>> _phoneNumber; | |
private Expression<Func<TModel, string>> _extension; | |
public PhoneHtmlBuilder(HtmlHelper<TModel> helper) | |
{ | |
_helper = helper; | |
} |
OlderNewer