diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index fdc6f5f9..26749926 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -575,7 +575,7 @@
-
+
diff --git a/releases/v1.0/Linux & Mac/alki.sh b/releases/v1.0/Linux & Mac/alki.sh
new file mode 100755
index 00000000..1b2339bb
--- /dev/null
+++ b/releases/v1.0/Linux & Mac/alki.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+jardir="$(dirname "../$BASH_SOURCE")"
+# echo $jardir
+
+java -jar $jardir/alk.jar ${@:1}
+exit 0
diff --git a/releases/v1.0/Windows/alki.bat b/releases/v1.0/Windows/alki.bat
new file mode 100644
index 00000000..2ad154e5
--- /dev/null
+++ b/releases/v1.0/Windows/alki.bat
@@ -0,0 +1 @@
+java -jar %~dp0\..\alk.jar %*
diff --git a/releases/v1.0/alk.jar b/releases/v1.0/alk.jar
new file mode 100644
index 00000000..7314baf8
Binary files /dev/null and b/releases/v1.0/alk.jar differ
diff --git a/releases/v1.0/doc/C.g4 b/releases/v1.0/doc/C.g4
new file mode 100644
index 00000000..99db66a1
--- /dev/null
+++ b/releases/v1.0/doc/C.g4
@@ -0,0 +1,948 @@
+/*
+ [The "BSD licence"]
+ Copyright (c) 2013 Sam Harwell
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/** C 2011 grammar built from the C11 Spec */
+grammar C;
+
+primaryExpression
+ : Identifier
+ | Constant
+ | StringLiteral+
+ | '(' expression ')'
+ | genericSelection
+ | '__extension__'? '(' compoundStatement ')' // Blocks (GCC extension)
+ | '__builtin_va_arg' '(' unaryExpression ',' typeName ')'
+ | '__builtin_offsetof' '(' typeName ',' unaryExpression ')'
+ ;
+
+genericSelection
+ : '_Generic' '(' assignmentExpression ',' genericAssocList ')'
+ ;
+
+genericAssocList
+ : genericAssociation
+ | genericAssocList ',' genericAssociation
+ ;
+
+genericAssociation
+ : typeName ':' assignmentExpression
+ | 'default' ':' assignmentExpression
+ ;
+
+postfixExpression
+ : primaryExpression
+ | postfixExpression '[' expression ']'
+ | postfixExpression '(' argumentExpressionList? ')'
+ | postfixExpression '.' Identifier
+ | postfixExpression '->' Identifier
+ | postfixExpression '++'
+ | postfixExpression '--'
+ | '(' typeName ')' '{' initializerList '}'
+ | '(' typeName ')' '{' initializerList ',' '}'
+ | '__extension__' '(' typeName ')' '{' initializerList '}'
+ | '__extension__' '(' typeName ')' '{' initializerList ',' '}'
+ ;
+
+argumentExpressionList
+ : assignmentExpression
+ | argumentExpressionList ',' assignmentExpression
+ ;
+
+unaryExpression
+ : postfixExpression
+ | '++' unaryExpression
+ | '--' unaryExpression
+ | unaryOperator castExpression
+ | 'sizeof' unaryExpression
+ | 'sizeof' '(' typeName ')'
+ | '_Alignof' '(' typeName ')'
+ | '&&' Identifier // GCC extension address of label
+ ;
+
+unaryOperator
+ : '&' | '*' | '+' | '-' | '~' | '!'
+ ;
+
+castExpression
+ : '(' typeName ')' castExpression
+ | '__extension__' '(' typeName ')' castExpression
+ | unaryExpression
+ | DigitSequence // for
+ ;
+
+multiplicativeExpression
+ : castExpression
+ | multiplicativeExpression '*' castExpression
+ | multiplicativeExpression '/' castExpression
+ | multiplicativeExpression '%' castExpression
+ ;
+
+additiveExpression
+ : multiplicativeExpression
+ | additiveExpression '+' multiplicativeExpression
+ | additiveExpression '-' multiplicativeExpression
+ ;
+
+shiftExpression
+ : additiveExpression
+ | shiftExpression '<<' additiveExpression
+ | shiftExpression '>>' additiveExpression
+ ;
+
+relationalExpression
+ : shiftExpression
+ | relationalExpression '<' shiftExpression
+ | relationalExpression '>' shiftExpression
+ | relationalExpression '<=' shiftExpression
+ | relationalExpression '>=' shiftExpression
+ ;
+
+equalityExpression
+ : relationalExpression
+ | equalityExpression '==' relationalExpression
+ | equalityExpression '!=' relationalExpression
+ ;
+
+andExpression
+ : equalityExpression
+ | andExpression '&' equalityExpression
+ ;
+
+exclusiveOrExpression
+ : andExpression
+ | exclusiveOrExpression '^' andExpression
+ ;
+
+inclusiveOrExpression
+ : exclusiveOrExpression
+ | inclusiveOrExpression '|' exclusiveOrExpression
+ ;
+
+logicalAndExpression
+ : inclusiveOrExpression
+ | logicalAndExpression '&&' inclusiveOrExpression
+ ;
+
+logicalOrExpression
+ : logicalAndExpression
+ | logicalOrExpression '||' logicalAndExpression
+ ;
+
+conditionalExpression
+ : logicalOrExpression ('?' expression ':' conditionalExpression)?
+ ;
+
+assignmentExpression
+ : conditionalExpression
+ | unaryExpression assignmentOperator assignmentExpression
+ | DigitSequence // for
+ ;
+
+assignmentOperator
+ : '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|='
+ ;
+
+expression
+ : assignmentExpression
+ | expression ',' assignmentExpression
+ ;
+
+constantExpression
+ : conditionalExpression
+ ;
+
+declaration
+ : declarationSpecifiers initDeclaratorList ';'
+ | declarationSpecifiers ';'
+ | staticAssertDeclaration
+ ;
+
+declarationSpecifiers
+ : declarationSpecifier+
+ ;
+
+declarationSpecifiers2
+ : declarationSpecifier+
+ ;
+
+declarationSpecifier
+ : storageClassSpecifier
+ | typeSpecifier
+ | typeQualifier
+ | functionSpecifier
+ | alignmentSpecifier
+ ;
+
+initDeclaratorList
+ : initDeclarator
+ | initDeclaratorList ',' initDeclarator
+ ;
+
+initDeclarator
+ : declarator
+ | declarator '=' initializer
+ ;
+
+storageClassSpecifier
+ : 'typedef'
+ | 'extern'
+ | 'static'
+ | '_Thread_local'
+ | 'auto'
+ | 'register'
+ ;
+
+typeSpecifier
+ : ('void'
+ | 'char'
+ | 'short'
+ | 'int'
+ | 'long'
+ | 'float'
+ | 'double'
+ | 'signed'
+ | 'unsigned'
+ | '_Bool'
+ | '_Complex'
+ | '__m128'
+ | '__m128d'
+ | '__m128i')
+ | '__extension__' '(' ('__m128' | '__m128d' | '__m128i') ')'
+ | atomicTypeSpecifier
+ | structOrUnionSpecifier
+ | enumSpecifier
+ | typedefName
+ | '__typeof__' '(' constantExpression ')' // GCC extension
+ | typeSpecifier pointer
+ ;
+
+structOrUnionSpecifier
+ : structOrUnion Identifier? '{' structDeclarationList '}'
+ | structOrUnion Identifier
+ ;
+
+structOrUnion
+ : 'struct'
+ | 'union'
+ ;
+
+structDeclarationList
+ : structDeclaration
+ | structDeclarationList structDeclaration
+ ;
+
+structDeclaration
+ : specifierQualifierList structDeclaratorList? ';'
+ | staticAssertDeclaration
+ ;
+
+specifierQualifierList
+ : typeSpecifier specifierQualifierList?
+ | typeQualifier specifierQualifierList?
+ ;
+
+structDeclaratorList
+ : structDeclarator
+ | structDeclaratorList ',' structDeclarator
+ ;
+
+structDeclarator
+ : declarator
+ | declarator? ':' constantExpression
+ ;
+
+enumSpecifier
+ : 'enum' Identifier? '{' enumeratorList '}'
+ | 'enum' Identifier? '{' enumeratorList ',' '}'
+ | 'enum' Identifier
+ ;
+
+enumeratorList
+ : enumerator
+ | enumeratorList ',' enumerator
+ ;
+
+enumerator
+ : enumerationConstant
+ | enumerationConstant '=' constantExpression
+ ;
+
+enumerationConstant
+ : Identifier
+ ;
+
+atomicTypeSpecifier
+ : '_Atomic' '(' typeName ')'
+ ;
+
+typeQualifier
+ : 'const'
+ | 'restrict'
+ | 'volatile'
+ | '_Atomic'
+ ;
+
+functionSpecifier
+ : ('inline'
+ | '_Noreturn'
+ | '__inline__' // GCC extension
+ | '__stdcall')
+ | gccAttributeSpecifier
+ | '__declspec' '(' Identifier ')'
+ ;
+
+alignmentSpecifier
+ : '_Alignas' '(' typeName ')'
+ | '_Alignas' '(' constantExpression ')'
+ ;
+
+declarator
+ : pointer? directDeclarator gccDeclaratorExtension*
+ ;
+
+directDeclarator
+ : Identifier
+ | '(' declarator ')'
+ | directDeclarator '[' typeQualifierList? assignmentExpression? ']'
+ | directDeclarator '[' 'static' typeQualifierList? assignmentExpression ']'
+ | directDeclarator '[' typeQualifierList 'static' assignmentExpression ']'
+ | directDeclarator '[' typeQualifierList? '*' ']'
+ | directDeclarator '(' parameterTypeList ')'
+ | directDeclarator '(' identifierList? ')'
+ | Identifier ':' DigitSequence // bit field
+ | '(' typeSpecifier? pointer directDeclarator ')' // function pointer like: (__cdecl *f)
+ ;
+
+gccDeclaratorExtension
+ : '__asm' '(' StringLiteral+ ')'
+ | gccAttributeSpecifier
+ ;
+
+gccAttributeSpecifier
+ : '__attribute__' '(' '(' gccAttributeList ')' ')'
+ ;
+
+gccAttributeList
+ : gccAttribute (',' gccAttribute)*
+ | // empty
+ ;
+
+gccAttribute
+ : ~(',' | '(' | ')') // relaxed def for "identifier or reserved word"
+ ('(' argumentExpressionList? ')')?
+ | // empty
+ ;
+
+nestedParenthesesBlock
+ : ( ~('(' | ')')
+ | '(' nestedParenthesesBlock ')'
+ )*
+ ;
+
+pointer
+ : '*' typeQualifierList?
+ | '*' typeQualifierList? pointer
+ | '^' typeQualifierList? // Blocks language extension
+ | '^' typeQualifierList? pointer // Blocks language extension
+ ;
+
+typeQualifierList
+ : typeQualifier
+ | typeQualifierList typeQualifier
+ ;
+
+parameterTypeList
+ : parameterList
+ | parameterList ',' '...'
+ ;
+
+parameterList
+ : parameterDeclaration
+ | parameterList ',' parameterDeclaration
+ ;
+
+parameterDeclaration
+ : declarationSpecifiers declarator
+ | declarationSpecifiers2 abstractDeclarator?
+ ;
+
+identifierList
+ : Identifier
+ | identifierList ',' Identifier
+ ;
+
+typeName
+ : specifierQualifierList abstractDeclarator?
+ ;
+
+abstractDeclarator
+ : pointer
+ | pointer? directAbstractDeclarator gccDeclaratorExtension*
+ ;
+
+directAbstractDeclarator
+ : '(' abstractDeclarator ')' gccDeclaratorExtension*
+ | '[' typeQualifierList? assignmentExpression? ']'
+ | '[' 'static' typeQualifierList? assignmentExpression ']'
+ | '[' typeQualifierList 'static' assignmentExpression ']'
+ | '[' '*' ']'
+ | '(' parameterTypeList? ')' gccDeclaratorExtension*
+ | directAbstractDeclarator '[' typeQualifierList? assignmentExpression? ']'
+ | directAbstractDeclarator '[' 'static' typeQualifierList? assignmentExpression ']'
+ | directAbstractDeclarator '[' typeQualifierList 'static' assignmentExpression ']'
+ | directAbstractDeclarator '[' '*' ']'
+ | directAbstractDeclarator '(' parameterTypeList? ')' gccDeclaratorExtension*
+ ;
+
+typedefName
+ : Identifier
+ ;
+
+initializer
+ : assignmentExpression
+ | '{' initializerList '}'
+ | '{' initializerList ',' '}'
+ ;
+
+initializerList
+ : designation? initializer
+ | initializerList ',' designation? initializer
+ ;
+
+designation
+ : designatorList '='
+ ;
+
+designatorList
+ : designator
+ | designatorList designator
+ ;
+
+designator
+ : '[' constantExpression ']'
+ | '.' Identifier
+ ;
+
+staticAssertDeclaration
+ : '_Static_assert' '(' constantExpression ',' StringLiteral+ ')' ';'
+ ;
+
+statement
+ : labeledStatement
+ | compoundStatement
+ | expressionStatement
+ | selectionStatement
+ | iterationStatement
+ | jumpStatement
+ | ('__asm' | '__asm__') ('volatile' | '__volatile__') '(' (logicalOrExpression (',' logicalOrExpression)*)? (':' (logicalOrExpression (',' logicalOrExpression)*)?)* ')' ';'
+ ;
+
+labeledStatement
+ : Identifier ':' statement
+ | 'case' constantExpression ':' statement
+ | 'default' ':' statement
+ ;
+
+compoundStatement
+ : '{' blockItemList? '}'
+ ;
+
+blockItemList
+ : blockItem
+ | blockItemList blockItem
+ ;
+
+blockItem
+ : statement
+ | declaration
+ ;
+
+expressionStatement
+ : expression? ';'
+ ;
+
+selectionStatement
+ : 'if' '(' expression ')' statement ('else' statement)?
+ | 'switch' '(' expression ')' statement
+ ;
+
+iterationStatement
+ : While '(' expression ')' statement
+ | Do statement While '(' expression ')' ';'
+ | For '(' forCondition ')' statement
+ ;
+
+// | 'for' '(' expression? ';' expression? ';' forUpdate? ')' statement
+// | For '(' declaration expression? ';' expression? ')' statement
+
+forCondition
+ : forDeclaration ';' forExpression? ';' forExpression?
+ | expression? ';' forExpression? ';' forExpression?
+ ;
+
+forDeclaration
+ : declarationSpecifiers initDeclaratorList
+ | declarationSpecifiers
+ ;
+
+forExpression
+ : assignmentExpression
+ | forExpression ',' assignmentExpression
+ ;
+
+jumpStatement
+ : 'goto' Identifier ';'
+ | 'continue' ';'
+ | 'break' ';'
+ | 'return' expression? ';'
+ | 'goto' unaryExpression ';' // GCC extension
+ ;
+
+compilationUnit
+ : translationUnit? EOF
+ ;
+
+translationUnit
+ : externalDeclaration
+ | translationUnit externalDeclaration
+ ;
+
+externalDeclaration
+ : functionDefinition
+ | declaration
+ | ';' // stray ;
+ ;
+
+functionDefinition
+ : declarationSpecifiers? declarator declarationList? compoundStatement
+ ;
+
+declarationList
+ : declaration
+ | declarationList declaration
+ ;
+
+Auto : 'auto';
+Break : 'break';
+Case : 'case';
+Char : 'char';
+Const : 'const';
+Continue : 'continue';
+Default : 'default';
+Do : 'do';
+Double : 'double';
+Else : 'else';
+Enum : 'enum';
+Extern : 'extern';
+Float : 'float';
+For : 'for';
+Goto : 'goto';
+If : 'if';
+Inline : 'inline';
+Int : 'int';
+Long : 'long';
+Register : 'register';
+Restrict : 'restrict';
+Return : 'return';
+Short : 'short';
+Signed : 'signed';
+Sizeof : 'sizeof';
+Static : 'static';
+Struct : 'struct';
+Switch : 'switch';
+Typedef : 'typedef';
+Union : 'union';
+Unsigned : 'unsigned';
+Void : 'void';
+Volatile : 'volatile';
+While : 'while';
+
+Alignas : '_Alignas';
+Alignof : '_Alignof';
+Atomic : '_Atomic';
+Bool : '_Bool';
+Complex : '_Complex';
+Generic : '_Generic';
+Imaginary : '_Imaginary';
+Noreturn : '_Noreturn';
+StaticAssert : '_Static_assert';
+ThreadLocal : '_Thread_local';
+
+LeftParen : '(';
+RightParen : ')';
+LeftBracket : '[';
+RightBracket : ']';
+LeftBrace : '{';
+RightBrace : '}';
+
+Less : '<';
+LessEqual : '<=';
+Greater : '>';
+GreaterEqual : '>=';
+LeftShift : '<<';
+RightShift : '>>';
+
+Plus : '+';
+PlusPlus : '++';
+Minus : '-';
+MinusMinus : '--';
+Star : '*';
+Div : '/';
+Mod : '%';
+
+And : '&';
+Or : '|';
+AndAnd : '&&';
+OrOr : '||';
+Caret : '^';
+Not : '!';
+Tilde : '~';
+
+Question : '?';
+Colon : ':';
+Semi : ';';
+Comma : ',';
+
+Assign : '=';
+// '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '&=' | '^=' | '|='
+StarAssign : '*=';
+DivAssign : '/=';
+ModAssign : '%=';
+PlusAssign : '+=';
+MinusAssign : '-=';
+LeftShiftAssign : '<<=';
+RightShiftAssign : '>>=';
+AndAssign : '&=';
+XorAssign : '^=';
+OrAssign : '|=';
+
+Equal : '==';
+NotEqual : '!=';
+
+Arrow : '->';
+Dot : '.';
+Ellipsis : '...';
+
+Identifier
+ : IdentifierNondigit
+ ( IdentifierNondigit
+ | Digit
+ )*
+ ;
+
+fragment
+IdentifierNondigit
+ : Nondigit
+ | UniversalCharacterName
+ //| // other implementation-defined characters...
+ ;
+
+fragment
+Nondigit
+ : [a-zA-Z_]
+ ;
+
+fragment
+Digit
+ : [0-9]
+ ;
+
+fragment
+UniversalCharacterName
+ : '\\u' HexQuad
+ | '\\U' HexQuad HexQuad
+ ;
+
+fragment
+HexQuad
+ : HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit
+ ;
+
+Constant
+ : IntegerConstant
+ | FloatingConstant
+ //| EnumerationConstant
+ | CharacterConstant
+ ;
+
+fragment
+IntegerConstant
+ : DecimalConstant IntegerSuffix?
+ | OctalConstant IntegerSuffix?
+ | HexadecimalConstant IntegerSuffix?
+ | BinaryConstant
+ ;
+
+fragment
+BinaryConstant
+ : '0' [bB] [0-1]+
+ ;
+
+fragment
+DecimalConstant
+ : NonzeroDigit Digit*
+ ;
+
+fragment
+OctalConstant
+ : '0' OctalDigit*
+ ;
+
+fragment
+HexadecimalConstant
+ : HexadecimalPrefix HexadecimalDigit+
+ ;
+
+fragment
+HexadecimalPrefix
+ : '0' [xX]
+ ;
+
+fragment
+NonzeroDigit
+ : [1-9]
+ ;
+
+fragment
+OctalDigit
+ : [0-7]
+ ;
+
+fragment
+HexadecimalDigit
+ : [0-9a-fA-F]
+ ;
+
+fragment
+IntegerSuffix
+ : UnsignedSuffix LongSuffix?
+ | UnsignedSuffix LongLongSuffix
+ | LongSuffix UnsignedSuffix?
+ | LongLongSuffix UnsignedSuffix?
+ ;
+
+fragment
+UnsignedSuffix
+ : [uU]
+ ;
+
+fragment
+LongSuffix
+ : [lL]
+ ;
+
+fragment
+LongLongSuffix
+ : 'll' | 'LL'
+ ;
+
+fragment
+FloatingConstant
+ : DecimalFloatingConstant
+ | HexadecimalFloatingConstant
+ ;
+
+fragment
+DecimalFloatingConstant
+ : FractionalConstant ExponentPart? FloatingSuffix?
+ | DigitSequence ExponentPart FloatingSuffix?
+ ;
+
+fragment
+HexadecimalFloatingConstant
+ : HexadecimalPrefix HexadecimalFractionalConstant BinaryExponentPart FloatingSuffix?
+ | HexadecimalPrefix HexadecimalDigitSequence BinaryExponentPart FloatingSuffix?
+ ;
+
+fragment
+FractionalConstant
+ : DigitSequence? '.' DigitSequence
+ | DigitSequence '.'
+ ;
+
+fragment
+ExponentPart
+ : 'e' Sign? DigitSequence
+ | 'E' Sign? DigitSequence
+ ;
+
+fragment
+Sign
+ : '+' | '-'
+ ;
+
+DigitSequence
+ : Digit+
+ ;
+
+fragment
+HexadecimalFractionalConstant
+ : HexadecimalDigitSequence? '.' HexadecimalDigitSequence
+ | HexadecimalDigitSequence '.'
+ ;
+
+fragment
+BinaryExponentPart
+ : 'p' Sign? DigitSequence
+ | 'P' Sign? DigitSequence
+ ;
+
+fragment
+HexadecimalDigitSequence
+ : HexadecimalDigit+
+ ;
+
+fragment
+FloatingSuffix
+ : 'f' | 'l' | 'F' | 'L'
+ ;
+
+fragment
+CharacterConstant
+ : '\'' CCharSequence '\''
+ | 'L\'' CCharSequence '\''
+ | 'u\'' CCharSequence '\''
+ | 'U\'' CCharSequence '\''
+ ;
+
+fragment
+CCharSequence
+ : CChar+
+ ;
+
+fragment
+CChar
+ : ~['\\\r\n]
+ | EscapeSequence
+ ;
+
+fragment
+EscapeSequence
+ : SimpleEscapeSequence
+ | OctalEscapeSequence
+ | HexadecimalEscapeSequence
+ | UniversalCharacterName
+ ;
+
+fragment
+SimpleEscapeSequence
+ : '\\' ['"?abfnrtv\\]
+ ;
+
+fragment
+OctalEscapeSequence
+ : '\\' OctalDigit
+ | '\\' OctalDigit OctalDigit
+ | '\\' OctalDigit OctalDigit OctalDigit
+ ;
+
+fragment
+HexadecimalEscapeSequence
+ : '\\x' HexadecimalDigit+
+ ;
+
+StringLiteral
+ : EncodingPrefix? '"' SCharSequence? '"'
+ ;
+
+fragment
+EncodingPrefix
+ : 'u8'
+ | 'u'
+ | 'U'
+ | 'L'
+ ;
+
+fragment
+SCharSequence
+ : SChar+
+ ;
+
+fragment
+SChar
+ : ~["\\\r\n]
+ | EscapeSequence
+ | '\\\n' // Added line
+ | '\\\r\n' // Added line
+ ;
+
+ComplexDefine
+ : '#' Whitespace? 'define' ~[#]*
+ -> skip
+ ;
+
+// ignore the following asm blocks:
+/*
+ asm
+ {
+ mfspr x, 286;
+ }
+ */
+AsmBlock
+ : 'asm' ~'{'* '{' ~'}'* '}'
+ -> skip
+ ;
+
+// ignore the lines grammar by c preprocessor
+// sample line : '#line 1 "/home/dm/files/dk1.h" 1'
+LineAfterPreprocessing
+ : '#line' Whitespace* ~[\r\n]*
+ -> skip
+ ;
+
+LineDirective
+ : '#' Whitespace? DecimalConstant Whitespace? StringLiteral ~[\r\n]*
+ -> skip
+ ;
+
+PragmaDirective
+ : '#' Whitespace? 'pragma' Whitespace ~[\r\n]*
+ -> skip
+ ;
+
+Whitespace
+ : [ \t]+
+ -> skip
+ ;
+
+Newline
+ : ( '\r' '\n'?
+ | '\n'
+ )
+ -> skip
+ ;
+
+BlockComment
+ : '/*' .*? '*/'
+ -> skip
+ ;
+
+LineComment
+ : '//' ~[\r\n]*
+ -> skip
+ ;
diff --git a/releases/v1.0/doc/README.md b/releases/v1.0/doc/README.md
new file mode 100644
index 00000000..584b6154
--- /dev/null
+++ b/releases/v1.0/doc/README.md
@@ -0,0 +1,8 @@
+# Documentation
+This repository includes documentation about the Java implementation of the Alk language and its associated tools.
+
+##Contents
+
+`alk.pdf` -- Alk Primer, a quick introduction to Alk language.
+
+`kinterpreter.md` -- directions to install the K interpreter.
diff --git a/releases/v1.0/doc/alk.pdf b/releases/v1.0/doc/alk.pdf
new file mode 100644
index 00000000..0f659561
Binary files /dev/null and b/releases/v1.0/doc/alk.pdf differ
diff --git a/releases/v1.0/doc/alk.tex b/releases/v1.0/doc/alk.tex
new file mode 100644
index 00000000..818dd93c
--- /dev/null
+++ b/releases/v1.0/doc/alk.tex
@@ -0,0 +1,1066 @@
+\documentclass[a4paper]{report}
+\usepackage[left=1.45in, right=1in, top=01in, bottom=1in, includefoot, textwidth = 5.77in, textheight=9.4in]{geometry}
+\usepackage{amsthm}
+\usepackage{amsmath}
+\usepackage{url}
+\usepackage{color}
+
+
+\newtheorem*{remark}{Remark}
+
+\newtheorem*{todo}{TODO}
+
+\title{Alk Primer \medskip\\ [2ex]
+\large (Draft)\\[3ex]
+\large Java-Semantics Version
+}
+
+\author{Dorel Lucanu}
+
+
+\begin{document}
+
+\maketitle
+
+\chapter{Introduction}
+
+\section{Motivation}
+
+Alk is an algorithmic language intended to be used for teaching data structures and algorithms using an abstraction notation (independent of programming language).
+
+The goal is to have a language that:
+\begin{itemize}
+\item is simple to be easily understood;
+\item is expressive enough to describe a large class of algorithms from various problem domains;
+\item is abstract: the algorithm description must make abstraction of implementation details, e.g., the low-level representation of data;
+\item is a good mean for learning how to algorithmically think;
+\item supply a rigorous computation model suitable to analyse algorithms;
+\item is executable: the algorithm can be executed, even if they are partially designed;
+\item is accompanied by a set of tools helping to analyse the algorithm correctness and the efficiency;
+\item input and output are given as abstract data types, ignoring implementation details.
+\end{itemize}
+
+As a starting example we consider the Alk description of the Euclid algorithm:
+\begin{verbatim}
+ gcd(a, b)
+ {
+ while (a != b) {
+ if (a > b) a = a - b;
+ if (b > a) b = b - a;
+ }
+ return a;
+ }
+\end{verbatim}
+The algorithm is described using a C++-like notation. The name of the alghorithm is \texttt{gcd} and its input parameters are \texttt{a} and \texttt{b}. There is no need to declare the type of parameters and/or the type of the return value.
+In order to execute the \texttt{gcd} algorithm, just add a single line algorithm
+\begin{verbatim}
+print(gcd(12, 8));
+\end{verbatim}
+and execute it ("gcd.alk" is the file including the above code):\footnote{In this document "alki" denotes one of the two scripts running the Alk interpretes: "alki.bat" (for Windows platform), respectively "alki.sh" (for linux, Mac OS).}
+\begin{verbatim}
+> alki gcd.alk
+ 4
+\end{verbatim}
+%The output is the final configuration of the execution, that includes the values of the global variables (here {\tt x}).
+An alternative is to write a general call of the algorithm
+\begin{verbatim}
+print(gcd(u, v));
+\end{verbatim}
+and mention the initial values of the global variables {\tt u} and {\tt v} in the command line
+\begin{verbatim}
+> alki gcd.alk "u |-> 28 v |-> 35"
+7
+\end{verbatim}
+or in an input file, say "gcd.in":
+\begin{verbatim}
+u |-> 42 v |-> 56
+\end{verbatim}
+and give it as a parameter of the command line:
+\begin{verbatim}
+> alki gcd.alk gcd.in
+ 14
+\end{verbatim}
+
+A more complex algorithm is the DFS traversal of a digraph represented with external adjacent lists:
+\begin{verbatim}
+dfsRec(D, i, out S) {
+ if (S[i] == 0) {
+ // visit i
+ S[i] = 1;
+ p = D.a[i];
+ while (p.size() > 0) {
+ j = p.topFront();
+ p.popFront();
+ dfsRec(D, j, S);
+ }
+ }
+}
+
+// the calling algorithm
+dfs(D, i0) {
+ i = i0;
+ while (i < D.n) {
+ S[i] = 0;
+ i = i + 1;
+ }
+ dfsRec(D, i0, S);
+ return S;
+}
+print(dfs(D, i0));
+\end{verbatim}
+To execute the above algorithm on the digraph:
+\begin{align*}
+&D.n = 3,\\
+&D.a[0] = \langle 1,2\rangle\\
+&D.a[1] = \langle2, 0\rangle\\
+&D.a[2] = \langle0\rangle
+\end{align*}
+create a file "dfs.in" with the following contents:
+\begin{verbatim}
+D |-> { n -> 3
+ a -> [ < 1, 2 >, < 2, 0 >, < 0 > ] }
+ i0 |-> 1
+\end{verbatim}
+and then execute the algorithm with this input:
+\begin{verbatim}
+> alki dfsrec.alk dfs.in
+[1, 1, 1]
+\end{verbatim}
+
+
+%\section{Executing Alk Algorithms with Java Tools}
+%
+%TO BE UPDATED
+%
+%\begin{verbatim}
+%> alki gcd.alk
+%State:
+% x |-> 4
+%\end{verbatim}
+%Notice that the output is also simplified. A non-empty initial state is specified as follows:
+%\begin{verbatim}
+%> alki dfsrec.alk --init="D |-> { n -> 3
+% a -> [ < 1, 2 >, < 2, 0 >, < 0 > ] }
+% i0 |-> 1"
+%State:
+%
+% D |-> { (n -> 3) (a -> ([ (< 1, 2 >), (< 2, 0 >), (< 0 >) ])) }
+% i0 |-> 1
+% reached |-> [ 1, 1, 1 ]
+%\end{verbatim}
+
+\begin{remark}
+This is a in progress document that is incrementally updated.
+\end{remark}
+
+\chapter{Language Description}
+
+The examples used in this manual can be found in the folder "doc/examples-from-manual".
+
+\section{Variables and their Values}
+
+Alk includes two categories of values:
+\begin{list}{}{3ex}
+\item[\it Scalars (primitive values).] Here are included the booleans, integers, rationals (floats), and strings.
+\item[\it Structured values.] Here are included the sequences (linear lists), arrays, structures.
+\end{list}
+Note that a data can be as complex as possible, i.e, we may have arrays of sequences, arrays of arrays, sequences of arrays of structures, structures of arrays and lists, and so on.
+
+\subsection{Scalars}
+
+The scalars are written using a syntax similar to that from the most popular programming languages:
+\begin{verbatim}
+index = 234;
+isEven = true;
+radius = 21.468;
+name = "john";
+\end{verbatim}
+The execution of the above algorithm produces an output as expected:
+\begin{verbatim}
+> alki scalars.alk
+234
+true
+21.468
+john
+\end{verbatim}
+
+
+\subsection{Arrays}
+
+An array value is written as a sequence surrounded by square brackets: $[v_0,\ldots,v_{n-1}]$, where $v_i$ is a value, for $i=0,\ldots,n-1$.
+Here is a very simple algorithm handling arrays:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.35\textwidth}
+\begin{verbatim}
+a = [3, 5, 6, 4];
+i = 1;
+x = a[i];
+a[i+1] = x;
+print(x);
+print(a);
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.3\textwidth}
+\begin{verbatim}
+> alki arrays.alk
+5
+[3, 5, 5, 4]
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+The multi-dimensional arrays are represented a arrays of arrays:
+\begin{verbatim}
+a = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ];
+b = a[1];
+c = a[1][2];
+a[0] = b;
+a[1][1] = 89;
+print(a); // [[4, 5, 6], [4, 89, 6]]
+w = [ [ [ 1, 2], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ];
+x = w[1];
+y = w[1][0];
+z = w[1][0][1];
+w[0][1][0] = 99;
+print(x); // [[5, 6], [7, 8]]
+print(y); // [5, 6]
+print(z); // 6
+print(w); // [[[1, 2], [99, 4]], [[5, 6], [7, 8]]]
+\end{verbatim}
+The output is indeed the expected one:
+\begin{verbatim}
+> alki arraysofarrays.alk
+[[4, 5, 6], [4, 89, 6]]
+[[5, 6], [7, 8]]
+[5, 6]
+6
+[[[1, 2], [99, 4]], [[5, 6], [7, 8]]]
+\end{verbatim}
+
+\subsection{Sequences (linear lists)}
+
+A sequence value is written in a similar to an array, but using angle brackets: $\langle v_0,\ldots,v_{n-1}\rangle$, where $v_i$ is a value, for $i=0,\ldots,n-1$.
+The list of operations over sequences includes:
+\begin{center}
+\begin{tabular}{|l|l|}
+\hline
+\texttt{emptyList()}
+&
+returns the empty list $\langle\,\rangle$\\
+\hline
+$L$\texttt{.topFront()}
+&
+returns $v_0$\\
+\hline
+$L$\texttt{.topBack()}
+&
+returns $v_{n-1}$\\
+\hline
+$L$\texttt{.at($i$)}
+&
+returns $v_i$\\
+\hline
+$L$\texttt{.insert($i$,$x$)}
+&
+returns $\langle\ldots v_{i-1},x,v_i,\ldots\rangle$\\
+\hline
+$L$\texttt{.removeAt($i$)}
+&
+returns $\langle\ldots v_{i-1},v_{i+1},\ldots\rangle$\\
+\hline
+$L$\texttt{.removeAllEqTo($x$)}
+&
+returns $L$, where all elements $v_i$ equal to $x$ were removed\\
+\hline
+$L$\texttt{.size()}
+&
+returns $n$\\
+\hline
+ $L$\texttt{.popFront()}
+&
+returns $\langle v_1,\ldots,v_{n-1}\rangle$\\
+\hline
+$L$\texttt{.popBack()}
+&
+returns $\langle v_0,\ldots,v_{n-2}\rangle$\\
+\hline
+$L$\texttt{.pushFront($x$)}
+&
+returns $\langle x,v_0,\ldots,v_{n-1}\rangle$\\
+\hline
+$L$\texttt{.pushBack($x$)}
+&
+\^{\i}ntoarce $\langle v_0,\ldots,v_{n-1},x\rangle$\\
+\hline
+$L$\texttt{.update($i$,$x$)}
+&
+returns $\langle\ldots v_{i-1},x,v_{i+1},\ldots\rangle$\\
+\hline
+\end{tabular}
+\end{center}
+Example:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.55\textwidth}
+\begin{verbatim}
+ll = < 8, 3, 9, 4, 5, 4 >;
+i = 1;
+x = ll.at(i + 1);
+y = ll.topFront();
+print(x); // 9
+print(y); // 8
+ll.insert(2, 22);
+ll.update(3, 33);
+print(ll); // < 8, 3, 22, 33, 4, 5, 4 >
+l2 = ll;
+l2.removeAt(0);
+l2.removeAt(3);
+print(l2); // < 3, 22, 33, 5, 4 >
+l2.removeAllEqTo(4);
+print(l2); // < 3, 22, 33, 5 >
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki seq.alk
+9
+8
+[8, 3, 22, 33, 4, 5, 4]
+[3, 22, 33, 5, 4]
+[3, 22, 33, 5]
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+Now we may define sequences of arrays:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.55\textwidth}
+\begin{verbatim}
+l = < [1, 2, 3], [4, 5] >;
+a = l.at(1);
+l.pushBack(a);
+print(a); // [4, 5]
+print(l); // <[1, 2, 3], [4, 5], [4, 5]>
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki sequencesofarrays.alk
+[ 4, 5 ]
+< [ 1, 2, 3 ], [ 4, 5 ], [ 4, 5 ] >
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+and arrays of structures:
+\begin{center}
+\begin{tabular}{l}
+Algorithm \\
+\hline
+\\
+\begin{minipage}{.8\textwidth}
+\begin{verbatim}
+a = [ { x -> 1 y -> 2 }, { x -> 4 y -> 5 } ];
+b = a[1];
+c = a[1].y;
+a[1].x = 77;
+print(a); // [{x -> 1, y -> 2}, {x -> 77, y -> 5}]
+print(b); // {x -> 4, y -> 5}
+print(c); // 5
+\end{verbatim}
+\end{minipage}
+\\
+~\\
+Output \\
+\hline
+\\
+\begin{minipage}{.8\textwidth}
+\begin{verbatim}
+> alki arraysofstructures.alk
+[{x -> 1, y -> 2}, {x -> 77, y -> 5}]
+{x -> 4, y -> 5}
+5
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+\subsection{Structures}
+
+A structure value is of the form $\{ f_1\to v_1\ldots f_n\to v_n\}$, where $f_i$ is a field name and $v_i$ is a value, for $i=1,\ldots,n$.
+
+Example:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+s = { x -> 12 y -> 45 };
+a = s.x;
+s.y = 99;
+b.x = 22;
+print(s); // {x -> 12, y -> 99}
+print(b); // {x -> 22}
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki structures.alk
+{ (x -> 12) (y -> 99) }
+{ x -> 22 }
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+Note that the structure \texttt{b} has been created with only one field, because there is no information about its type, which is deduced on the fly during the execution.
+
+We may have structures of arrays
+\begin{center}
+\begin{tabular}{l}
+Algorithm\\
+\hline
+\\
+\begin{minipage}{.65\textwidth}
+\begin{verbatim}
+s = { x -> [ 1, 2, 3 ] y -> [ 4, 5, 6 ] };
+b = s.y;
+s.x[1] = 11;
+print(b); // [4, 5, 6]
+print(s); // {x -> [1, 11, 3], y -> [4, 5, 6]}
+\end{verbatim}
+\end{minipage}
+\\
+\\
+Output\\
+\hline
+\\
+\begin{minipage}{.65\textwidth}
+\begin{verbatim}
+> alki structuresofarrays.alk
+[ 4, 5, 6 ]
+{ (x -> ([ 1, 11, 3 ])) (y -> [ 4, 5, 6 ]) }
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+sequences of structures
+\begin{center}
+\begin{tabular}{l}
+Algorithm \\
+\hline
+\\
+\begin{minipage}{.85\textwidth}
+\begin{verbatim}
+l = < { x -> 12 y -> 56 }, { x -> -43 y -> 98 }, { x -> 33 y -> 66 } >;
+u = l.topFront();
+l.pushBack({ x -> -100 y -> 200 });
+print(u);
+print(l);
+\end{verbatim}
+\end{minipage}
+\\
+\\
+Output\\
+\hline
+\\
+\begin{minipage}{.85\textwidth}
+\begin{verbatim}
+> alki seqofstructures.alk
+{x -> 12, y -> 56}
+<{x -> 12, y -> 56}, {x -> -43, y -> 98}, {x -> 33, y -> 66}, {x -> -100, y -> 200}>
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+and so on.
+
+
+\subsection{Sets}
+
+A set value is written as $\{ v_0,\ldots,v_{n-1}\}$, where $v_i$ is a value, for $i=0,\ldots,n-1$. The operations over sets include the union \verb|U|, the intersection \verb|^|, the difference \verb|\|, and the membership test \verb|_ in _|.
+Example:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.55\textwidth}
+\begin{verbatim}
+s1 = { 1 .. 5 };
+s2 = { 2, 4, 6, 7 };
+a = s1 U s2 ;
+b = s1 ^ s2;
+c = s1 \ s2;
+print(a); // {1, 2, 3, 4, 5, 6, 7}
+print(b); // {2, 4}
+print(c); // {1, 3, 5}
+t = 2 in b ^ c;
+print(t); // false
+x = 0;
+forall y in s2 x = x + y;
+print(x); // 19
+d = emptySet;
+forall y in { 1 .. 6 }
+ if (y in s2) d = d U singletonSet(y);
+print(d); // {7}
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki sets.alk
+{1, 2, 3, 4, 5, 6, 7}
+{2, 4}
+{1, 3, 5}
+false
+19
+{2, 4, 6}
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+Obviously, we may have sets of arrays, sequences of sets, and so on.
+
+\begin{remark}
+The current implementation does check if a set value assigned to a variable is indeed a set. But the operations returns sets whenever the arguments are sets.
+\end{remark}
+
+\subsection{Specification of values}
+
+Alk includes several sugar syntax mechanisms for specifying values in a more compact way:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+p = 3;
+q = 9;
+a = [ i | i in p .. q ];
+p = 2;
+b = [ a[i] | i in p .. p+3 ];
+l = < b[i] * 2 | i in p-2 .. p >;
+print(a);
+print(b);
+print(l);
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki specs.alk
+[3, 4, 5, 6, 7, 8, 9]
+[5, 6, 7, 8]
+<10, 12, 14>
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+%\subsection{Flexibility in Using Data Structures}
+%
+%Even if each data structure has its own operations with specific notations, these operations and notations can be "exported" to the other data structures as sugar syntax. For instance, if \texttt{L} is a sequence, then we may use ${\tt L}[i]$ for ${\tt L.at}(i)$.
+%
+%Example:
+%\begin{center}
+%\begin{tabular}{ll}
+%Algorithm & Output\\
+%\hline
+%\\
+%\begin{minipage}{.4\textwidth}
+%\begin{verbatim}
+%L = < 8, 3, 9, 4 >;
+%x = ll[2];
+%L[3] = 33;
+%L[4] = 44;
+%\end{verbatim}
+%\end{minipage}
+%&
+%\begin{minipage}{.35\textwidth}
+%\begin{verbatim}
+%L |-> < 8, 3, 9, 33, 44 >
+%x |-> 9
+%\end{verbatim}
+%\end{minipage}
+%\end{tabular}
+%\end{center}
+%
+%If {\tt S} is a set, then we can borrow the notations from sequences and array operations:
+%\begin{description}
+%\item[{\tt S}{$[i]$}] -- returns an element from $S$. The same do {\tt S.topFront()} and {\tt S.topBack()}. Note that the behaviour of these operations could be nondeterministic: for the same set vale, they could return different elements in different execution steps;
+%\item[{\tt S.insert}$(i,x)$] -- adds $x$ to $S$ (it is a short notation for {\tt S = S U }$(x)$);
+%\end{description}
+%
+%Example:
+%\begin{center}
+%\begin{tabular}{ll}
+%Algorithm & Output\\
+%\hline
+%\\
+%\begin{minipage}{.45\textwidth}
+%\begin{verbatim}
+%s = { 2, 4, 6, 7 };
+%z = s.topFront();
+%n = s.size();
+%s2 = s.pushBack(99);
+%a = s2[3];
+%s.insert(2, 22);
+%\end{verbatim}
+%\end{minipage}
+%&
+%\begin{minipage}{.45\textwidth}
+%\begin{verbatim}
+%a |-> 7
+%n |-> 4
+%s2 |-> { 2, 4, 6, 7, 99 }
+%s |-> { 2, 4, 22, 6, 7 }
+%z |-> 2
+%\end{verbatim}
+%\end{minipage}
+%\end{tabular}
+%\end{center}
+%Here is an example that shows that {\tt \_.topFron()} returns different values, even if it is called for equal sets:
+%\begin{center}
+%\begin{tabular}{ll}
+%Algorithm & Output\\
+%\hline
+%\\
+%\begin{minipage}{.45\textwidth}
+%\begin{verbatim}
+%s = { 2, 4, 6, 7 };
+%s2 = s;
+%a = s.topFront();
+%s2.popFront();
+%s2.pushBack(a);
+%b = s2.topFront();
+%t = s == s2;
+%\end{verbatim}
+%\end{minipage}
+%&
+%\begin{minipage}{.45\textwidth}
+%\begin{verbatim}
+%a |-> 2
+%b |-> 4
+%s2 |-> { 4, 6, 7, 2 }
+%s |-> { 2, 4, 6, 7 }
+%t |-> true
+%\end{verbatim}
+%\end{minipage}
+%\end{tabular}
+%\end{center}
+%We can see that {\tt s} and {\tt s2} are equal as sets, but {\tt a} and {\tt b} are different.
+
+\subsection{Lists with iterators}
+
+An iterator $p$ associated with a list $L$ if $p$ "refers" an element of $L$. With iterators one can call operation over the associated lists and/or traverse the associated list.
+
+Operations with ieterators:
+\begin{description}
+\item[$p\texttt{ + }i$] -- returns an iterator refering the $i$th element after $p$;
+\item[$p\texttt{ - }i$] -- returns an iterator refering the $i$th element in front of $p$;
+\item[$\texttt{++}p$] -- moves $p$ to the previous element (if any);
+\item[$\texttt{--}p$] -- moves $p$ to the next element (if any);
+\item[$L$\texttt{.first()}] -- returns an iterator that refers the first element of $L$;
+\item[$L$\texttt{.end()}] -- returns an invalid iterator for $L$
+\end{description}
+
+Using iterators, one can access the lements of the lists and/or execute operations on the associated list:
+\begin{description}
+\item[\texttt{*}$p$] -- returns the referred element;
+\item[$p$\texttt{->delete()}] -- remove the element referred by $p$ and move $p$ to the next element;
+\item[$p$\texttt{->insert(x)}] -- insert $x$ immediately after the element referred by $p$.
+\end{description}
+
+If $p$ refers the $i$th element in $L$, then $p$\texttt{->delete()} is equivalent to $L[i]$\texttt{.delete()} and $p$\texttt{->insert(x)} with $L[i]$\texttt{.insert(x)}.
+
+
+The following operators are useful to traverse circular lists:
+\begin{description}
+\item[$p\texttt{ +\% }i$] -- returns an iterator refering the $i$th element after $p$ modulo the length of the list;
+\item[$p\texttt{ -\% }i$] -- returns an iterator refering the $i$th element in front of $p$ modulo the length of the list;
+\item[$\texttt{++\%}p$] -- moves $p$ to the previous element modulo the length of the list;
+\item[$\texttt{--\%}p$] -- moves $p$ to the next element modulo the length of the list
+\end{description}
+
+Example 1:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+L = < 2, 5, 8 >;
+i = 0;
+A = [];
+for (p = L.first(); p != L.end(); ++p) {
+ A[i] = *p ;
+ ++i;
+}
+print(A);
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki it1.alk
+[2, 5, 8]
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+Example 2:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+L = < 2, 5, 8, 33 >;
+p = L.first();
+p = p + 3;
+a = *p;
+++% p;
+b = *p;
+q = L.first();
+c = *(--% q);
+print(a);
+print(b);
+print(c);
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki it3.alk
+33
+2
+33
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+\section{Expressions}
+
+Alk includes the basic operators over scalars with a C++-like syntax.
+
+Since Alk is designed with K Framework, it can be easily extended with new operators.
+
+\section{Statements}
+
+The syntax for the statements is similar to that of imperative C++.
+
+We already have seen examples of the assignment statement.
+The other statements include:
+
+\subsection{Block}
+
+Syntax: \verb'{' {\it Stmt} \verb'}'
+
+\subsection{\texttt{if}}
+
+
+Syntax: 1) \verb"if" \verb"(" {\it Exp} \verb")" {\it Stmt} \verb"else" {\it Stmt}\quad 2) \verb"if" \verb"(" {\it Exp} \verb")" {\it Stmt}
+
+
+\subsection{\texttt{while}}
+
+Syntax: \verb'while (' {\it Exp} \verb')' {\it Stmt}
+
+
+\subsection{\texttt{for}}
+
+Syntax: 1) \verb"forall" {\it Id} \verb"in" {\it Exp} {\it Stmt} \quad 2) \verb"for" \verb"(" {\it VarAssign} \verb";" {\it Exp} \verb";" {\it VarUpdate} \verb")" {\it Stmt}
+
+Examples:
+\begin{verbatim}
+ for (i= 2; i <= x / 2; ++i)
+ if (x % i == 0) return false;
+
+ forall y in { 1 .. 6 }
+ if (y in s2) d = d U singletonSet(y);
+\end{verbatim}
+
+
+
+\subsection{Sequential Composition}
+
+Syntax: {\it Stmt}~{\it Stmt}
+
+\section{Statements for Nondeterministic Algorithms}
+
+\subsection{\texttt{choose}}
+
+Syntax: \verb"choose" {\it Id} \verb"in" {\it Exp} \verb";" \quad 2) \verb"choose" Id \verb"in" {\it Exp} \verb"s.t." {\it Exp} \verb";"
+
+Example 1:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+choose x1 in { 1 .. 5 };
+choose x2 in { 1 .. 5 };
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+ x1 |-> 3
+ x2 |-> 1
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+Example 2:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+odd(x) {
+ return x % 2 == 1;
+}
+
+choose x1 in { 1 .. 5 } s.t. odd(x1);
+choose x2 in { 1 .. 5 } s.t. odd(x2);
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+ x1 |-> 5
+ x2 |-> 3
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+Example 3:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+choose x8 in { 1 .. 5 } s.t. x8 > 6;
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+Error at line 14: Choose can't find any
+suitable value.
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+
+\subsection{\texttt{success}}
+
+\textcolor{red}{TO BE REVISED. For now replace \texttt{success;} with \texttt{print("success");}}
+
+Syntax: \verb"success" \verb";"
+
+Example:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+odd(x) {
+ return x % 2 == 1;
+}
+
+choose x in { 1 .. 8 };
+if (odd(x)) print("success");
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki success.alk
+success
+x |-> 5
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+\subsection{\texttt{failure}}
+
+\textcolor{red}{TO BE REVISED. For now replace \texttt{failure;} with \texttt{print("failure");}}
+
+Syntax: \verb"failure" \verb";"
+
+Example:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+odd(x) {
+ return x % 2 == 1;
+}
+
+choose x in { 1 .. 8 };
+if (odd(x)) print("success");
+else print("failure");
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+> alki success.alk
+failure
+x |-> 8
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+\section{Functions/Procedures Describing Algorithms}
+
+Example:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output "\\
+\hline
+\\
+\begin{minipage}{.55\textwidth}
+\begin{verbatim}
+swap(out a, i, j) {
+ temp = a[i];
+ a[i] = a[j];
+ a[j] = temp;
+}
+
+partition(out a, p, q) {
+ x = a[p] ;
+ i = p + 1; j = q;
+ while (i <= j) {
+ if (a[i] <= x) i = i+1;
+ else if (a[j] >= x) j = j-1;
+ else if (a[i] > x && x > a[j]) {
+ swap(a, i, j);
+ i = i+1;
+ j = j-1;
+ }
+ }
+ k = i-1; a[p] = a[k]; a[k] = x;
+// if (k == q) --k;
+ return k;
+}
+
+qsort(out a, p, q) {
+ if (p < q) {
+ k = partition(a, p, q);
+ qsort(a, p, k-1);
+ qsort(a, k+1, q);
+ }
+}
+
+b = [5,1,3,2,4];
+n = 5;
+qsort(b, 0, n-1);
+print(b);
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.42\textwidth}
+\begin{verbatim}
+> alki qsort.alk
+[1, 2, 3, 4, 5]
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+Note that the output parameters and the input/output parameters are declared with the prefix {\tt out}.
+
+If a function modifies global variables, then these must be specified in a "modifies" clause.
+Example:
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output"\\
+\hline
+\\
+\begin{minipage}{.55\textwidth}
+\begin{verbatim}
+x = 3;
+y = 5;
+g(b) modifies x, y {
+ x = x + b;
+ y = y * b;
+ return x;
+}
+g(5);
+print(x); // 8
+print(y); // 25
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.42\textwidth}
+\begin{verbatim}
+> alki globals.alk
+8
+25
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+\end{document}
+
+\begin{center}
+\begin{tabular}{ll}
+Algorithm & Output\\
+\hline
+\\
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+
+\end{verbatim}
+\end{minipage}
+&
+\begin{minipage}{.45\textwidth}
+\begin{verbatim}
+
+\end{verbatim}
+\end{minipage}
+\end{tabular}
+\end{center}
+
+
diff --git a/releases/v1.0/doc/examples-from-manual/arrays.alk b/releases/v1.0/doc/examples-from-manual/arrays.alk
new file mode 100644
index 00000000..d9f3c0c8
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/arrays.alk
@@ -0,0 +1,6 @@
+a = [3, 5, 6, 4];
+i = 1;
+x = a[i];
+a[i+1] = x;
+print(x);
+print(a);
diff --git a/releases/v1.0/doc/examples-from-manual/arraysofarrays.alk b/releases/v1.0/doc/examples-from-manual/arraysofarrays.alk
new file mode 100644
index 00000000..8856f4cb
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/arraysofarrays.alk
@@ -0,0 +1,19 @@
+/*
+ arrays of arrays
+ alki arraysofarrays.alk
+*/
+a = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ];
+b = a[1];
+c = a[1][2];
+a[0] = b;
+a[1][1] = 89;
+print(a); // [[4, 5, 6], [4, 89, 6]]
+w = [ [ [ 1, 2], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ];
+x = w[1];
+y = w[1][0];
+z = w[1][0][1];
+w[0][1][0] = 99;
+print(x); // [[5, 6], [7, 8]]
+print(y); // [5, 6]
+print(z); // 6
+print(w); // [[[1, 2], [99, 4]], [[5, 6], [7, 8]]]
\ No newline at end of file
diff --git a/releases/v1.0/doc/examples-from-manual/arraysofstructures.alk b/releases/v1.0/doc/examples-from-manual/arraysofstructures.alk
new file mode 100644
index 00000000..0952aa6c
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/arraysofstructures.alk
@@ -0,0 +1,12 @@
+/*
+ arrays of structures
+ alki arraysofstructures.alk
+*/
+a = [ { x -> 1 y -> 2 }, { x -> 4 y -> 5 } ];
+b = a[1];
+c = a[1].y;
+a[1].x = 77;
+print(a); // [{x -> 1, y -> 2}, {x -> 77, y -> 5}]
+print(b); // {x -> 4, y -> 5}
+print(c); // 5
+
diff --git a/releases/v1.0/doc/examples-from-manual/choose.alk b/releases/v1.0/doc/examples-from-manual/choose.alk
new file mode 100644
index 00000000..2a8ba367
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/choose.alk
@@ -0,0 +1,9 @@
+choose x1 in { 1 .. 5 };
+/*
+choose x2 in { 1 .. 5 };
+choose x3 in { 1 .. 5 };
+choose x4 in { 1 .. 5 };
+choose x5 in { 1 .. 5 };
+choose x6 in { 1 .. 5 };
+choose x7 in { 1 .. 5 };
+*/
\ No newline at end of file
diff --git a/releases/v1.0/doc/examples-from-manual/choosest.alk b/releases/v1.0/doc/examples-from-manual/choosest.alk
new file mode 100644
index 00000000..93c39653
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/choosest.alk
@@ -0,0 +1,14 @@
+odd(x) {
+ return x % 2 == 1;
+}
+
+choose x1 in { 1 .. 5 } s.t. odd(x1);
+choose x2 in { 1 .. 5 } s.t. !odd(x2);
+/*
+choose x3 in { 1 .. 5 } s.t. odd(x3);
+choose x4 in { 1 .. 5 } s.t. odd(x4);
+choose x5 in { 1 .. 5 } s.t. odd(x5);
+choose x6 in { 1 .. 5 } s.t. odd(x6);
+choose x7 in { 1 .. 5 } s.t. odd(x7);
+*/
+choose x8 in { 1 .. 5 } s.t. x8 > 6;
\ No newline at end of file
diff --git a/releases/v1.0/doc/examples-from-manual/dfs.in b/releases/v1.0/doc/examples-from-manual/dfs.in
new file mode 100644
index 00000000..234bd481
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/dfs.in
@@ -0,0 +1,3 @@
+D |-> { n -> 3
+ a -> [ < 1, 2 >, < 2, 0 >, < 0 > ] }
+ i0 |-> 1
diff --git a/releases/v1.0/doc/examples-from-manual/dfsrec.alk b/releases/v1.0/doc/examples-from-manual/dfsrec.alk
new file mode 100644
index 00000000..e9d5836b
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/dfsrec.alk
@@ -0,0 +1,24 @@
+dfsRec(D, i, out S) {
+ if (S[i] == 0) {
+ // visit i
+ S[i] = 1;
+ p = D.a[i];
+ while (p.size() > 0) {
+ j = p.topFront();
+ p.popFront();
+ dfsRec(D, j, S);
+ }
+ }
+}
+
+// the calling algorithm
+dfs(D, i0) {
+ i = i0;
+ while (i < D.n) {
+ S[i] = 0;
+ i = i + 1;
+ }
+ dfsRec(D, i0, S);
+ return S;
+}
+print(dfs(D, i0));
diff --git a/releases/v1.0/doc/examples-from-manual/gcd.alk b/releases/v1.0/doc/examples-from-manual/gcd.alk
new file mode 100644
index 00000000..b27b45c9
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/gcd.alk
@@ -0,0 +1,10 @@
+gcd(a, b)
+ {
+ while (a != b) {
+ if (a > b) a = a - b;
+ if (b > a) b = b - a;
+ }
+ return a;
+ }
+// print(gcd(12, 8));
+print(gcd(u, v));
diff --git a/releases/v1.0/doc/examples-from-manual/gcd.in b/releases/v1.0/doc/examples-from-manual/gcd.in
new file mode 100644
index 00000000..01a0ddaa
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/gcd.in
@@ -0,0 +1 @@
+u |-> 42 v |-> 56
diff --git a/releases/v1.0/doc/examples-from-manual/globals.alk b/releases/v1.0/doc/examples-from-manual/globals.alk
new file mode 100644
index 00000000..56d6d04f
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/globals.alk
@@ -0,0 +1,11 @@
+x = 3;
+y = 5;
+g(b) modifies x, y {
+ x = x + b;
+ y = y * b;
+ return x;
+}
+print("g:");
+g(5);
+print(x); // 8
+print(y); // 25
diff --git a/releases/v1.0/doc/examples-from-manual/it1.alk b/releases/v1.0/doc/examples-from-manual/it1.alk
new file mode 100644
index 00000000..2d5c27f7
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/it1.alk
@@ -0,0 +1,9 @@
+L = < 2, 5, 8 >;
+i = 0;
+A = [];
+for (p = L.first(); p != L.end(); ++p) {
+ A[i] = *p ;
+ ++i;
+}
+print(A);
+
diff --git a/releases/v1.0/doc/examples-from-manual/it3.alk b/releases/v1.0/doc/examples-from-manual/it3.alk
new file mode 100644
index 00000000..22067942
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/it3.alk
@@ -0,0 +1,14 @@
+L = < 2, 5, 8, 33 >;
+p = L.first();
+p = p + 3;
+a = *p;
+++% p;
+b = *p;
+q = L.first();
+c = *(--% q);
+print(a);
+print(b);
+print(c);
+
+
+
diff --git a/releases/v1.0/doc/examples-from-manual/qsort.alk b/releases/v1.0/doc/examples-from-manual/qsort.alk
new file mode 100644
index 00000000..8a50ef36
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/qsort.alk
@@ -0,0 +1,53 @@
+
+swap(out a, i, j) {
+ temp = a[i];
+ a[i] = a[j];
+ a[j] = temp;
+}
+
+/*
+@input: a[p..q]
+@output: k si a[p..q] partitionat de k
+*/
+partition(out a, p, q) {
+ x = a[p] ;
+ i = p + 1; j = q;
+ while (i <= j) {
+ if (a[i] <= x) i = i+1;
+ else if (a[j] >= x) j = j-1;
+ else if (a[i] > x && x > a[j]) {
+ swap(a, i, j);
+ i = i+1;
+ j = j-1;
+ }
+ }
+ k = i-1; a[p] = a[k]; a[k] = x;
+// if (k == q) --k;
+ return k;
+}
+
+/*
+@input: a[p..q]
+@output: a[p..q] sortat
+*/
+qsort(out a, p, q) {
+ if (p < q) {
+ k = partition(a, p, q);
+ qsort(a, p, k-1);
+ qsort(a, k+1, q);
+ }
+}
+
+b = [5,1,3,2,4];
+n = 5;
+qsort(b, 0, n-1);
+print(b);
+
+
+/*
+alki qsort.alk
+*/
+
+
+
+
diff --git a/releases/v1.0/doc/examples-from-manual/scalars.alk b/releases/v1.0/doc/examples-from-manual/scalars.alk
new file mode 100644
index 00000000..ea1abcba
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/scalars.alk
@@ -0,0 +1,10 @@
+index = 234;
+isEven = true;
+radius = 21.468;
+name = "john";
+print(index);
+print(isEven);
+print(radius);
+print(name);
+
+
diff --git a/releases/v1.0/doc/examples-from-manual/seq.alk b/releases/v1.0/doc/examples-from-manual/seq.alk
new file mode 100644
index 00000000..70cc6f6b
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/seq.alk
@@ -0,0 +1,20 @@
+/*
+ linear lists (sequences)
+ alki seq.alk
+*/
+ll = < 8, 3, 9, 4, 5, 4 >;
+i = 1;
+x = ll.at(i + 1);
+y = ll.topFront();
+print(x); // 9
+print(y); // 8
+ll.insert(2, 22);
+ll.update(3, 33);
+print(ll); // < 8, 3, 22, 33, 4, 5, 4 >
+l2 = ll;
+l2.removeAt(0);
+l2.removeAt(3);
+print(l2); // < 3, 22, 33, 5, 4 >
+l2.removeAllEqTo(4);
+print(l2); // < 3, 22, 33, 5 >
+
diff --git a/releases/v1.0/doc/examples-from-manual/seqofstructures.alk b/releases/v1.0/doc/examples-from-manual/seqofstructures.alk
new file mode 100644
index 00000000..389712a5
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/seqofstructures.alk
@@ -0,0 +1,11 @@
+/*
+ lists of structures
+ alki listsofstructures.alk
+*/
+l = < { x -> 12 y -> 56 }, { x -> -43 y -> 98 }, { x -> 33 y -> 66 } >;
+u = l.topFront();
+l.pushBack({ x -> -100 y -> 200 });
+// l.at(2).x = 999;
+print(u);
+print(l);
+
diff --git a/releases/v1.0/doc/examples-from-manual/sequencesofarrays.alk b/releases/v1.0/doc/examples-from-manual/sequencesofarrays.alk
new file mode 100644
index 00000000..863c0ed0
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/sequencesofarrays.alk
@@ -0,0 +1,10 @@
+/*
+ arrays of lists
+ alki arraysoflists.alk
+*/
+l = < [1, 2, 3], [4, 5] >;
+a = l.at(1);
+l.pushBack(a);
+print(a); // [4, 5]
+print(l); // <[1, 2, 3], [4, 5], [4, 5]>
+
diff --git a/releases/v1.0/doc/examples-from-manual/sets.alk b/releases/v1.0/doc/examples-from-manual/sets.alk
new file mode 100644
index 00000000..60152a39
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/sets.alk
@@ -0,0 +1,22 @@
+/*
+ sets
+ alki sets.alk
+*/
+s1 = { 1 .. 5 };
+s2 = { 2, 4, 6, 7 };
+a = s1 U s2 ;
+b = s1 ^ s2;
+c = s1 \ s2;
+print(a); // {1, 2, 3, 4, 5, 6, 7}
+print(b); // {2, 4}
+print(c); // {1, 3, 5}
+t = 2 in b ^ c;
+print(t); // false
+x = 0;
+forall y in s2 x = x + y;
+print(x); // 19
+d = emptySet;
+forall y in { 1 .. 6 }
+ if (y in s2) d = d U singletonSet(y);
+print(d); // {2, 4, 6}
+
diff --git a/releases/v1.0/doc/examples-from-manual/specs.alk b/releases/v1.0/doc/examples-from-manual/specs.alk
new file mode 100644
index 00000000..e49e87b4
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/specs.alk
@@ -0,0 +1,10 @@
+p = 3;
+q = 9;
+a = [ i | i in p .. q ];
+p = 2;
+b = [ a[i] | i in p .. p+3 ];
+l = < b[i] * 2 | i in p-2 .. p >;
+
+print(a);
+print(b);
+print(l);
diff --git a/releases/v1.0/doc/examples-from-manual/structures.alk b/releases/v1.0/doc/examples-from-manual/structures.alk
new file mode 100644
index 00000000..28f4a315
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/structures.alk
@@ -0,0 +1,14 @@
+/*
+ structures
+ line 1 uncommented: alki structures.alk
+*/
+s = { x -> 12 y -> 45 };
+a = s.x;
+s.y = 99;
+b.x = 22;
+print(s); // {x -> 12, y -> 99}
+print(b); // {x -> 22}
+
+
+
+
diff --git a/releases/v1.0/doc/examples-from-manual/structuresofarrays.alk b/releases/v1.0/doc/examples-from-manual/structuresofarrays.alk
new file mode 100644
index 00000000..1ed3e542
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/structuresofarrays.alk
@@ -0,0 +1,11 @@
+/*
+ structures of arrays
+ line 1 uncommented: alki structuresofarrays.alk
+*/
+s = { x -> [ 1, 2, 3 ] y -> [ 4, 5, 6 ] };
+b = s.y;
+s.x[1] = 11;
+print(b); // [4, 5, 6]
+print(s); // {x -> [1, 11, 3], y -> [4, 5, 6]}
+
+
diff --git a/releases/v1.0/doc/examples-from-manual/success.alk b/releases/v1.0/doc/examples-from-manual/success.alk
new file mode 100644
index 00000000..f83b7f04
--- /dev/null
+++ b/releases/v1.0/doc/examples-from-manual/success.alk
@@ -0,0 +1,7 @@
+odd(x) {
+ return x % 2 == 1;
+}
+
+choose x in { 1 .. 8 };
+if (odd(x)) print("success");
+else print("failure");
diff --git a/releases/v1.0/examples/data-structures/arrays.alk b/releases/v1.0/examples/data-structures/arrays.alk
new file mode 100644
index 00000000..f4e6e0af
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/arrays.alk
@@ -0,0 +1,10 @@
+/*
+ arrays
+ line 1 uncommented: alki arrays.alk
+*/
+a = [3, 5, 6, 4];
+i = 1;
+x = a[i];
+a[i+1] = x;
+print(x); // 5
+print(a); // [3, 5, 5, 4]
diff --git a/releases/v1.0/examples/data-structures/arraysofarrays.alk b/releases/v1.0/examples/data-structures/arraysofarrays.alk
new file mode 100644
index 00000000..81f7eb21
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/arraysofarrays.alk
@@ -0,0 +1,19 @@
+/*
+ arrays of arrays
+ line 1 uncommented: alki arraysofarrays.alk
+*/
+a = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ];
+b = a[1];
+c = a[1][2];
+a[0] = b;
+a[1][1] = 89;
+print(a); // [[4, 5, 6], [4, 89, 6]]
+w = [ [ [ 1, 2], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ];
+x = w[1];
+y = w[1][0];
+z = w[1][0][1];
+w[0][1][0] = 99;
+print(x); // [[5, 6], [7, 8]]
+print(y); // [5, 6]
+print(z); // 6
+print(w); // [[[1, 2], [99, 4]], [[5, 6], [7, 8]]]
\ No newline at end of file
diff --git a/releases/v1.0/examples/data-structures/arraysofsequences.alk b/releases/v1.0/examples/data-structures/arraysofsequences.alk
new file mode 100644
index 00000000..cc2e691c
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/arraysofsequences.alk
@@ -0,0 +1,10 @@
+/*
+ arrays of lists
+ line 1 uncommented: alki arraysoflists.alk
+*/
+a = [ < 1, 2, 3 >, < 4, 5, 6 >, < 7, 8 > ];
+b = a[1];
+a[1].update(1, 11);
+a[0].insert(2,22);
+a[2] = a[1].pushBack(77);
+print(a); //[<1, 2, 22, 3>, <4, 11, 6, 77>, <4, 11, 6, 77>]
diff --git a/releases/v1.0/examples/data-structures/arraysofstructures.alk b/releases/v1.0/examples/data-structures/arraysofstructures.alk
new file mode 100644
index 00000000..049154c3
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/arraysofstructures.alk
@@ -0,0 +1,12 @@
+/*
+ arrays of structures
+ line 1 uncommented: alki arraysofstructures.alk
+*/
+a = [ { x -> 1 y -> 2 }, { x -> 4 y -> 5 } ];
+b = a[1];
+c = a[1].y;
+a[1].x = 77;
+print(a); // [{x -> 1, y -> 2}, {x -> 77, y -> 5}]
+print(b); // {x -> 4, y -> 5}
+print(c); // 5
+
diff --git a/releases/v1.0/examples/data-structures/intervals.alk b/releases/v1.0/examples/data-structures/intervals.alk
new file mode 100644
index 00000000..6c578d12
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/intervals.alk
@@ -0,0 +1,9 @@
+/*
+ alki intervals.alk
+*/
+a = [1..4];
+l = < 3..6 >;
+s = { 4..6 };
+print(a); // [1, 2, 3, 4]
+print(l); // < 3, 4, 5, 6 >
+print(s); // { 4, 5, 6 }
\ No newline at end of file
diff --git a/releases/v1.0/examples/data-structures/seq.alk b/releases/v1.0/examples/data-structures/seq.alk
new file mode 100644
index 00000000..90593e31
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/seq.alk
@@ -0,0 +1,25 @@
+/*
+ linear lists (sequences)
+ line 1 uncommented: alki seq.alk
+*/
+ll = < 8, 3, 9, 4, 5, 4 >;
+i = 1;
+x = ll.at(i + 1);
+y = ll.topFront();
+print(x); // 9
+print(y); // 8
+// z = ll.topBack();
+ll.insert(2, 22);
+ll.update(3, 33);
+print(ll); // < 8, 3, 22, 33, 4, 5, 4 >
+l2 = ll;
+l2.removeAt(0);
+l2.removeAt(3);
+print(l2); // < 3, 22, 33, 5, 4 >
+// l2.removeAt(2);
+// l3 = ll;
+// l3.update(2,4);
+l2.removeAllEqTo(4);
+print(l2); // < 3, 22, 33, 5 >
+//l3.removeAllEqTo(4);
+
diff --git a/releases/v1.0/examples/data-structures/seqofstructures.alk b/releases/v1.0/examples/data-structures/seqofstructures.alk
new file mode 100644
index 00000000..a454ca32
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/seqofstructures.alk
@@ -0,0 +1,14 @@
+/*
+ lists of structures
+ line 1 uncommented: alki listsofstructures.alk
+ line 1 commented: alki listsofstructures.alk listsofstructures.in
+ where, e.g., listsofstructures.in includes
+l |-> < { x -> 12 y -> 56 }, { x -> -43 y -> 98 }, { x -> 33 y -> 66 } >
+*/
+l = < { x -> 12 y -> 56 }, { x -> -43 y -> 98 }, { x -> 33 y -> 66 } >;
+u = l.topFront();
+l.pushBack({ x -> -100 y -> 200 });
+l.at(2).x = 999;
+print(u);
+print(l);
+
diff --git a/releases/v1.0/examples/data-structures/seqofstructures.in b/releases/v1.0/examples/data-structures/seqofstructures.in
new file mode 100644
index 00000000..35f6c3a9
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/seqofstructures.in
@@ -0,0 +1 @@
+l |-> < { x -> 12 y -> 56 }, { x -> -43 y -> 98 }, { x -> 33 y -> 66 } >
diff --git a/releases/v1.0/examples/data-structures/sequencesofarrays.alk b/releases/v1.0/examples/data-structures/sequencesofarrays.alk
new file mode 100644
index 00000000..718a0b5d
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/sequencesofarrays.alk
@@ -0,0 +1,10 @@
+/*
+ arrays of lists
+ line 1 uncommented: alki arraysoflists.alk
+*/
+l = < [1, 2, 3], [4, 5] >;
+a = l.at(1);
+l.pushBack(a);
+print(a); // [4, 5]
+print(l); // <[1, 2, 3], [4, 5], [4, 5]>
+
diff --git a/releases/v1.0/examples/data-structures/sets.alk b/releases/v1.0/examples/data-structures/sets.alk
new file mode 100644
index 00000000..8e9461ae
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/sets.alk
@@ -0,0 +1,25 @@
+/*
+ sets
+ line 1 uncommented: alki sets.alk
+ line 1 commented: alki sets.alk sets.in
+ where sets.in, e.g., includes
+s1 |-> { 1, 2, 3, 4, 5 } s2 |-> { 2, 4, 6, 7 }
+*/
+s1 = { 1 .. 5 };
+s2 = { 2, 4, 6, 7 };
+a = s1 U s2 ;
+b = s1 ^ s2;
+c = s1 \ s2;
+print(a); // {1, 2, 3, 4, 5, 6, 7}
+print(b); // {2, 4}
+print(c); // {1, 3, 5}
+t = 2 in b ^ c;
+print(t); // false
+x = 0;
+forall y in s2 x = x + y;
+print(x); // 19
+d = emptySet;
+forall y in { 1 .. 6 }
+ if (y in s2) d = d U singletonSet(y);
+print(d); // {2, 4, 6}
+
diff --git a/releases/v1.0/examples/data-structures/sets.in b/releases/v1.0/examples/data-structures/sets.in
new file mode 100644
index 00000000..130210a8
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/sets.in
@@ -0,0 +1 @@
+s1 |-> { 1, 2, 3, 4, 5 } s2 |-> { 2, 4, 6, 7 }
diff --git a/releases/v1.0/examples/data-structures/specs.alk b/releases/v1.0/examples/data-structures/specs.alk
new file mode 100644
index 00000000..7bd5576e
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/specs.alk
@@ -0,0 +1,10 @@
+p = 3;
+q = 9;
+a = [ i | i from [p .. q] ];
+p = 2;
+b = [ a[i] | i from [p .. p+3] ];
+l = < b[i] * 2 | i from [p-2 .. p] >;
+
+print(a);
+print(b);
+print(l);
diff --git a/releases/v1.0/examples/data-structures/structures.alk b/releases/v1.0/examples/data-structures/structures.alk
new file mode 100644
index 00000000..28f4a315
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/structures.alk
@@ -0,0 +1,14 @@
+/*
+ structures
+ line 1 uncommented: alki structures.alk
+*/
+s = { x -> 12 y -> 45 };
+a = s.x;
+s.y = 99;
+b.x = 22;
+print(s); // {x -> 12, y -> 99}
+print(b); // {x -> 22}
+
+
+
+
diff --git a/releases/v1.0/examples/data-structures/structuresofarrays.alk b/releases/v1.0/examples/data-structures/structuresofarrays.alk
new file mode 100644
index 00000000..1ed3e542
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/structuresofarrays.alk
@@ -0,0 +1,11 @@
+/*
+ structures of arrays
+ line 1 uncommented: alki structuresofarrays.alk
+*/
+s = { x -> [ 1, 2, 3 ] y -> [ 4, 5, 6 ] };
+b = s.y;
+s.x[1] = 11;
+print(b); // [4, 5, 6]
+print(s); // {x -> [1, 11, 3], y -> [4, 5, 6]}
+
+
diff --git a/releases/v1.0/examples/data-structures/structuresofstructures.alk b/releases/v1.0/examples/data-structures/structuresofstructures.alk
new file mode 100644
index 00000000..acd07fbd
--- /dev/null
+++ b/releases/v1.0/examples/data-structures/structuresofstructures.alk
@@ -0,0 +1,15 @@
+/*
+ structures of structures
+ line 1 uncommented: alki structuresofstructures.alk
+ line 1 commented: alki structuresofstructures.alk structuresofstructures.in
+ where structuresofstructures.in, e.g., includes
+s |-> { A -> { x -> 12 y -> 56 } B -> { x -> -43 y -> 98 } }
+*/
+s = { A -> { x -> 12 y -> 56 } B -> { x -> -43 y -> 98 } };
+u = s.B;
+v = s.B.x;
+s.B.y = 55;
+print(u); // {x -> -43, y -> 98}
+print(v); // -43
+print(s); // {A -> {x -> 12, y -> 56}, B -> {x -> -43, y -> 55}}
+
diff --git a/releases/v1.0/examples/language-features/arrofchars.alk b/releases/v1.0/examples/language-features/arrofchars.alk
new file mode 100644
index 00000000..4996b669
--- /dev/null
+++ b/releases/v1.0/examples/language-features/arrofchars.alk
@@ -0,0 +1,7 @@
+/*
+alki arrofchars.alk
+*/
+s = ["a", "b", "c"];
+s[1] = "z";
+if (s[0] == "a") s[0] = "A";
+print(s);
\ No newline at end of file
diff --git a/releases/v1.0/examples/language-features/assgns.alk b/releases/v1.0/examples/language-features/assgns.alk
new file mode 100644
index 00000000..65dbf6d8
--- /dev/null
+++ b/releases/v1.0/examples/language-features/assgns.alk
@@ -0,0 +1,13 @@
+x = 2;
+y = 3;
+z = 4;
+w = 5;
+a = 10;
+x += a;
+y *= a;
+z /= a;
+w -= a;
+print(x); // 12
+print(y); // 30
+print(z); // 0
+print(w); // -5
diff --git a/releases/v1.0/examples/language-features/boolops.alk b/releases/v1.0/examples/language-features/boolops.alk
new file mode 100644
index 00000000..17c40d59
--- /dev/null
+++ b/releases/v1.0/examples/language-features/boolops.alk
@@ -0,0 +1,11 @@
+/*
+ alki boolops.alk boolops.in
+ where, e.g., boolops.in includes
+ x |-> 1 y |-> 2
+ */
+
+b1 = x < y;
+b2 = b1 && ! (x < 0);
+b3 = !b1 || b1 && b2;
+print(b2);
+print(b3);
\ No newline at end of file
diff --git a/releases/v1.0/examples/language-features/boolops.in b/releases/v1.0/examples/language-features/boolops.in
new file mode 100644
index 00000000..6d159856
--- /dev/null
+++ b/releases/v1.0/examples/language-features/boolops.in
@@ -0,0 +1 @@
+x |-> -2 y |-> -1
diff --git a/releases/v1.0/examples/language-features/conv.alk b/releases/v1.0/examples/language-features/conv.alk
new file mode 100644
index 00000000..b7d4709a
--- /dev/null
+++ b/releases/v1.0/examples/language-features/conv.alk
@@ -0,0 +1,31 @@
+a = 2 / 3;
+b = 2.0 / 3;
+c = 2.0 / 3.0;
+print("2/3:");
+print(a);
+print(b);
+print(c);
+
+a = 2 + 3;
+b = 2.0 + 3;
+c = 2.0 + 3.0;
+print("2+3:");
+print(a);
+print(b);
+print(c);
+
+a = 2 * 3;
+b = 2.0 * 3;
+c = 2.0 * 3.0;
+print("2*3:");
+print(a);
+print(b);
+print(c);
+
+a = 2 - 3;
+b = 2.0 - 3;
+c = 2.0 - 3.0;
+print("2-3:");
+print(a);
+print(b);
+print(c);
diff --git a/releases/v1.0/examples/language-features/eq.alk b/releases/v1.0/examples/language-features/eq.alk
new file mode 100644
index 00000000..916b0ae0
--- /dev/null
+++ b/releases/v1.0/examples/language-features/eq.alk
@@ -0,0 +1,12 @@
+a = { x -> 2 y -> 3 };
+b = { x -> 2 y -> 3 };
+c = [ 2, 3];
+d = [ 2, 3];
+t1 = a == b;
+t2 = a != b;
+t3 = c == d;
+t4 = c != d;
+print(t1);
+print(t2);
+print(t3);
+print(t4);
diff --git a/releases/v1.0/examples/language-features/evenset.alk b/releases/v1.0/examples/language-features/evenset.alk
new file mode 100644
index 00000000..65696b17
--- /dev/null
+++ b/releases/v1.0/examples/language-features/evenset.alk
@@ -0,0 +1,11 @@
+/*
+ alki evenset.alk evenset.in
+ where, e.g., evenset.in includes
+ a |-> {1, 2, 3, 4}
+*/
+
+// s = emptySet;
+s = { 0 };
+ forall x in a // a is a input set
+ if (x % 2 == 0) s = s U singletonSet(x);
+ print(s);
diff --git a/releases/v1.0/examples/language-features/evenset.in b/releases/v1.0/examples/language-features/evenset.in
new file mode 100644
index 00000000..8bbcdf37
--- /dev/null
+++ b/releases/v1.0/examples/language-features/evenset.in
@@ -0,0 +1,2 @@
+a |-> {1, 2, 3, 4}
+
diff --git a/releases/v1.0/examples/language-features/fctcalls.alk b/releases/v1.0/examples/language-features/fctcalls.alk
new file mode 100644
index 00000000..292dd494
--- /dev/null
+++ b/releases/v1.0/examples/language-features/fctcalls.alk
@@ -0,0 +1,21 @@
+/*
+ function calls
+ alki fctcalls.alk
+*/
+f(a) { // a hides the global a
+ b = a + 1;
+ return b;
+}
+
+x = f(2);
+a = f(x);
+y = f(a);
+print("f:");
+print(x); // 3
+print(a); // 4
+print(y); // 5
+print(a); // 4
+
+
+
+
diff --git a/releases/v1.0/examples/language-features/floatops.alk b/releases/v1.0/examples/language-features/floatops.alk
new file mode 100644
index 00000000..95362f59
--- /dev/null
+++ b/releases/v1.0/examples/language-features/floatops.alk
@@ -0,0 +1,15 @@
+/*
+ float operations
+ alki floatops.alk
+*/
+
+a = 3.1415926535897932384626433832795028841971693993751058209749445923;
+// b = float(2);
+// c = sqrt(2);
+// d = sin(a / 2.0);
+print(a);
+// print(b);
+
+
+
+
diff --git a/releases/v1.0/examples/language-features/globals.alk b/releases/v1.0/examples/language-features/globals.alk
new file mode 100644
index 00000000..56d6d04f
--- /dev/null
+++ b/releases/v1.0/examples/language-features/globals.alk
@@ -0,0 +1,11 @@
+x = 3;
+y = 5;
+g(b) modifies x, y {
+ x = x + b;
+ y = y * b;
+ return x;
+}
+print("g:");
+g(5);
+print(x); // 8
+print(y); // 25
diff --git a/releases/v1.0/examples/language-features/outparam.alk b/releases/v1.0/examples/language-features/outparam.alk
new file mode 100644
index 00000000..ff6fdf72
--- /dev/null
+++ b/releases/v1.0/examples/language-features/outparam.alk
@@ -0,0 +1,24 @@
+f1(x) {
+ return x * x;
+}
+
+f2(out x) {
+ x = 7;
+}
+
+f3(x, out y) {
+ y = x + 3;
+ return y / x;
+}
+
+print(f1(5)); // 25
+b2 = 22;
+f2(b2);
+print(b2); // 7
+b3 = 33;
+a3 = f3(5, b3);
+print(a3); // 1
+print(b3); // 8
+
+
+
diff --git a/releases/v1.0/examples/miscelanea/dfs.alk b/releases/v1.0/examples/miscelanea/dfs.alk
new file mode 100644
index 00000000..34f6c5de
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/dfs.alk
@@ -0,0 +1,45 @@
+/*
+ This example includes the nonrecursive version of the DFS algorithm.
+ @input: a digraf D and a vertex i0
+ @output: the list S of the verices reachable from i0
+*/
+
+i = 0;
+while (i < D.n) {
+ p[i] = D.a[i];
+ S[i] = 0;
+ i = i + 1;
+}
+SB = emptyList;
+SB.pushFront(i0);
+S[i0] = 1;
+// visit i0
+while (SB.size() > 0) {
+ i = SB.topFront();
+ if (p[i].size() == 0) {
+ SB.popFront();
+ }
+ else {
+ j = p[i].topFront();
+ p[i].popFront();
+ if (S[j] == 0) {
+ // visit j;
+ S[j] = 1;
+ SB.pushFront(j);
+ }
+ }
+}
+print(S);
+/* Example of running command line
+ Assuming that the digraph D is given by
+ D.n = 3
+ D.a[0] = < 1,2 >
+ D.a[1] = < 2, 0 >
+ D.a[2] = < 0 >
+ and the vertex i0 is 1, then create a file dfs.in with the following contents:
+D |-> { n -> 3
+ a -> [ < 1, 2 >, < 2, 0 >, < 0 > ] }
+i0 |-> 1
+and execute the command
+alki dfs.alk dfs.in
+*/
diff --git a/releases/v1.0/examples/miscelanea/dfs.in b/releases/v1.0/examples/miscelanea/dfs.in
new file mode 100644
index 00000000..e127489d
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/dfs.in
@@ -0,0 +1,3 @@
+D |-> { n -> 3
+ a -> [ < 1, 2 >, < 2, 0 >, < 0 > ] }
+i0 |-> 1
diff --git a/releases/v1.0/examples/miscelanea/dfsrec.alk b/releases/v1.0/examples/miscelanea/dfsrec.alk
new file mode 100644
index 00000000..14b153f7
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/dfsrec.alk
@@ -0,0 +1,46 @@
+/*
+ This example includes the recursive version of the DFS algorithm.
+ @input: a digraf D and a vertex i0
+ @output: the list S of the verices reachable from i0
+*/
+
+// the recursive function
+dfsRec(out D, i, out S) {
+ if (S[i] == 0) {
+ // visit i
+ S[i] = 1;
+ p = D.a[i];
+ while (p.size() > 0) {
+ j = p.topFront();
+ p.popFront();
+ dfsRec(D, j, S);
+ }
+ }
+}
+
+// the calling algorithm
+dfs(out D, i0) {
+ i = i0;
+ while (i < D.n) {
+ S[i] = 0;
+ i = i + 1;
+ }
+ dfsRec(D, i0, S);
+ return S;
+}
+reached = dfs(D, i0);
+print(reached);
+
+/* Example of running command line
+ Assuming that the digraph D is given by
+ D.n = 3
+ D.a[0] = <1,2>
+ D.a[1] = <2, 0>
+ D.a[2] = <0>
+ and the vertex i0 is 1, then create a file dfs.in with the following contents:
+D |-> { n -> 3
+ a -> [ < 1, 2 >, < 2, 0 >, < 0 > ] }
+i0 |-> 1
+and execute the command
+alki dfsrec.alk dfs.in
+*/
diff --git a/releases/v1.0/examples/miscelanea/gcd-no-input.alk b/releases/v1.0/examples/miscelanea/gcd-no-input.alk
new file mode 100644
index 00000000..198cb617
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/gcd-no-input.alk
@@ -0,0 +1,17 @@
+/*
+ gcd
+ alki gcd.alk
+*/
+gcd(a, b)
+{
+ while (a != b) {
+ if (a > b) a = a - b;
+ if (b > a) b = b - a;
+ }
+ return a;
+}
+
+print(gcd(12,8));
+
+
+
diff --git a/releases/v1.0/examples/miscelanea/gcd.alk b/releases/v1.0/examples/miscelanea/gcd.alk
new file mode 100644
index 00000000..3962b486
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/gcd.alk
@@ -0,0 +1,22 @@
+/*
+ gcd
+ alki gcd.alk
+ alki gcd.alk gcd.in
+ where, e.g., the gcd.in includes:
+u |-> 42 v |-> 56
+*/
+gcd(a, b)
+{
+ while (a != b) {
+ if (a > b) a = a - b;
+ if (b > a) b = b - a;
+ }
+ return a;
+}
+
+//x = gcd(12, 8);
+//x = gcd(u, v);
+print(gcd(u,v));
+
+
+
diff --git a/releases/v1.0/examples/miscelanea/gcd.in b/releases/v1.0/examples/miscelanea/gcd.in
new file mode 100644
index 00000000..01a0ddaa
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/gcd.in
@@ -0,0 +1 @@
+u |-> 42 v |-> 56
diff --git a/releases/v1.0/examples/miscelanea/gcdrec.alk b/releases/v1.0/examples/miscelanea/gcdrec.alk
new file mode 100644
index 00000000..83964d36
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/gcdrec.alk
@@ -0,0 +1,16 @@
+/*
+ gcd recursiv
+ alki gcdrec.alk
+*/
+gcd(a, b)
+{
+ if (a > b) return gcd(b, a - b);
+ if (b > a) return gcd(a, b - a);
+ return a;
+}
+
+x = gcd(32, 20);
+print(x);
+
+
+
diff --git a/releases/v1.0/examples/miscelanea/log.alk b/releases/v1.0/examples/miscelanea/log.alk
new file mode 100644
index 00000000..8fa77fa2
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/log.alk
@@ -0,0 +1,20 @@
+/*
+ @input: a positive integer n
+ @output: x = [log n] + 1
+*/
+
+print(n);
+x = 0;
+while (n > 0) {
+ n = n / 2;
+ x = x + 1;
+}
+print(x);
+
+/*
+ Example of command line:
+ alki log.alk log.in
+ where log.in includes:
+n |-> 78
+
+*/
diff --git a/releases/v1.0/examples/miscelanea/log.in b/releases/v1.0/examples/miscelanea/log.in
new file mode 100644
index 00000000..aa33394b
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/log.in
@@ -0,0 +1 @@
+n |-> 78
diff --git a/releases/v1.0/examples/miscelanea/platou.alk b/releases/v1.0/examples/miscelanea/platou.alk
new file mode 100644
index 00000000..5b758528
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/platou.alk
@@ -0,0 +1,26 @@
+/*
+ @input: an array a of length n with the elements sorted in ascending order
+ @output: the length lg of the longest plateau in a
+*/
+
+lg = 1; // the length of the longest plateau found
+i = 1; // the end position of the current plateau
+while (i < n) {
+ if (a[i] == a[i -lg]) lg = lg+1;
+ i = i + 1;
+}
+print(lg);
+
+/* Examples of command line:
+ krun programs/platou.alk platou1.in
+ where, e.g., platou1.in includes
+n |-> 6
+a |-> [ 1, 1, 3, 3, 3, 7 ]
+
+ alki platou.alk platou2.in
+ where, e.g., platou2.in includes
+n |-> 6
+a |-> [ 1212121212121212121212, 1212121212121212121212, 2323232323232323232323, 2323232323232323232323, 2323232323232323232323,
+ 6767676767676767676767 ]
+
+*/
\ No newline at end of file
diff --git a/releases/v1.0/examples/miscelanea/platou1.in b/releases/v1.0/examples/miscelanea/platou1.in
new file mode 100644
index 00000000..704cdb1f
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/platou1.in
@@ -0,0 +1,2 @@
+n |-> 6
+a |-> [ 1, 1, 3, 3, 3, 7 ]
diff --git a/releases/v1.0/examples/miscelanea/platou2.in b/releases/v1.0/examples/miscelanea/platou2.in
new file mode 100644
index 00000000..3c276446
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/platou2.in
@@ -0,0 +1,4 @@
+n |-> 6
+a |-> [ 1212121212121212121212, 1212121212121212121212, 2323232323232323232323, 2323232323232323232323, 2323232323232323232323,
+ 6767676767676767676767 ]
+
diff --git a/releases/v1.0/examples/miscelanea/prime.alk b/releases/v1.0/examples/miscelanea/prime.alk
new file mode 100644
index 00000000..24db3007
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/prime.alk
@@ -0,0 +1,27 @@
+/*
+ the first N primes
+ alki prime.alk
+*/
+
+isPrime(x) {
+ if (x < 2) return false;
+ for (i= 2; i*i <= x; ++i)
+ if (x % i == 0) return false;
+ return true;
+}
+
+firstNPrimes(n) {
+ x = 2;
+ l = emptyList;
+ while ( l.size() < n) {
+ if (isPrime(x)) {
+ l.pushBack(x);
+ }
+ ++ x;
+ }
+ return l;
+}
+
+print(firstNPrimes(23));
+
+
\ No newline at end of file
diff --git a/releases/v1.0/examples/miscelanea/qsort.alk b/releases/v1.0/examples/miscelanea/qsort.alk
new file mode 100644
index 00000000..402b3aab
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/qsort.alk
@@ -0,0 +1,55 @@
+
+swap(out a, i, j) {
+ temp = a[i];
+ a[i] = a[j];
+ a[j] = temp;
+}
+
+/*
+@input: a[p..q]
+@output: k si a[p..q] partitionat de k
+*/
+partition(out a, p, q) {
+ x = a[p] ;
+ i = p + 1; j = q;
+ while (i <= j) {
+ if (a[i] <= x) i = i+1;
+ else if (a[j] >= x) j = j-1;
+ else if (a[i] > x && x > a[j]) {
+ swap(a, i, j);
+ i = i+1;
+ j = j-1;
+ }
+ }
+ k = i-1; a[p] = a[k]; a[k] = x;
+// if (k == q) --k;
+ return k;
+}
+
+/*
+@input: a[p..q]
+@output: a[p..q] sortat
+*/
+qsort(out a, p, q) {
+ if (p < q) {
+ k = partition(a, p, q);
+ qsort(a, p, k-1);
+ qsort(a, k+1, q);
+ }
+}
+
+print(b);
+qsort(b, 0, n-1);
+print(b);
+
+
+/*
+alki qsort.alk qsort.in
+where, e.g., qsort.in includes:
+n |-> 5
+b |-> [5,1,3,2,4]
+*/
+
+
+
+
diff --git a/releases/v1.0/examples/miscelanea/qsort.in b/releases/v1.0/examples/miscelanea/qsort.in
new file mode 100644
index 00000000..a0d62ce1
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/qsort.in
@@ -0,0 +1,2 @@
+n |-> 5
+b |-> [5,1,3,2,4]
diff --git a/releases/v1.0/examples/miscelanea/sum.alk b/releases/v1.0/examples/miscelanea/sum.alk
new file mode 100644
index 00000000..368fabe3
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/sum.alk
@@ -0,0 +1,18 @@
+/*
+ @input: a positive integer n
+ @output: s = 1 + 2 + ... + n
+*/
+
+s = 0 ;
+while (n > 0) {
+ s = s + n;
+ n = n - 1;
+}
+print(s);
+
+/*
+ Example of command line:
+ alki sum.alk sum.in
+ where, e.g., sum.in includes:
+n |-> 23
+*/
\ No newline at end of file
diff --git a/releases/v1.0/examples/miscelanea/sum.in b/releases/v1.0/examples/miscelanea/sum.in
new file mode 100644
index 00000000..145e7914
--- /dev/null
+++ b/releases/v1.0/examples/miscelanea/sum.in
@@ -0,0 +1 @@
+n |-> 23
diff --git a/releases/v1.0/examples/nondeterministic/choose.alk b/releases/v1.0/examples/nondeterministic/choose.alk
new file mode 100644
index 00000000..2a8ba367
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/choose.alk
@@ -0,0 +1,9 @@
+choose x1 in { 1 .. 5 };
+/*
+choose x2 in { 1 .. 5 };
+choose x3 in { 1 .. 5 };
+choose x4 in { 1 .. 5 };
+choose x5 in { 1 .. 5 };
+choose x6 in { 1 .. 5 };
+choose x7 in { 1 .. 5 };
+*/
\ No newline at end of file
diff --git a/releases/v1.0/examples/nondeterministic/choosest.alk b/releases/v1.0/examples/nondeterministic/choosest.alk
new file mode 100644
index 00000000..096e9240
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/choosest.alk
@@ -0,0 +1,13 @@
+odd(x) {
+ return x % 2 == 1;
+}
+
+choose x1 in { 1 .. 5 } s.t. odd(x1);
+choose x2 in { 1 .. 5 } s.t. !odd(x2);
+/*
+choose x3 in { 1 .. 5 } s.t. odd(x3);
+choose x4 in { 1 .. 5 } s.t. odd(x4);
+choose x5 in { 1 .. 5 } s.t. odd(x5);
+choose x6 in { 1 .. 5 } s.t. odd(x6);
+choose x7 in { 1 .. 5 } s.t. odd(x7);
+*/
diff --git a/releases/v1.0/examples/nondeterministic/failure.alk b/releases/v1.0/examples/nondeterministic/failure.alk
new file mode 100644
index 00000000..8f455ee1
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/failure.alk
@@ -0,0 +1,9 @@
+odd(x) {
+ return x % 2 == 1;
+}
+
+s = emptyList;
+for (i = 0; i < 8; i = i+2)
+ s.pushBack(i);
+choose x in s s.t. odd(x);
+
diff --git a/releases/v1.0/examples/nondeterministic/nqsort.alk b/releases/v1.0/examples/nondeterministic/nqsort.alk
new file mode 100644
index 00000000..b80662af
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/nqsort.alk
@@ -0,0 +1,52 @@
+
+swap(out a, i, j) {
+ temp = a[i];
+ a[i] = a[j];
+ a[j] = temp;
+}
+
+/*
+@input: a[p..q]
+@output: k si a[p..q] partitionat de k
+*/
+partitioneaza(out a, p, q) {
+ m = p + random(q-p);
+ swap(a, p, m);
+ x = a[p] ;
+ i = p + 1; j = q;
+ while (i <= j) {
+ if (a[i] <= x) i = i+1;
+ else if (a[j] >= x) j = j-1;
+ else if (a[i] > x && x > a[j]) {
+ swap(a, i, j);
+ i = i+1;
+ j = j-1;
+ }
+ }
+ k = i-1; a[p] = a[k]; a[k] = x;
+// if (k == q) --k;
+ return k;
+}
+
+/*
+@input: a[p..q]
+@output: a[p..q] sortat
+*/
+nqsort(out a, p, q) {
+ if (p < q) {
+ k = partitioneaza(a, p, q);
+ nqsort(a, p, k-1);
+ nqsort(a, k+1, q);
+ }
+}
+
+nqsort(b, 0, n-1);
+
+
+/*
+alki nqsort.alk "n |-> 5 b |-> [3,1,5,2,7]"
+*/
+
+
+
+
diff --git a/releases/v1.0/examples/nondeterministic/nqueens.alk b/releases/v1.0/examples/nondeterministic/nqueens.alk
new file mode 100644
index 00000000..e78c3f71
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/nqueens.alk
@@ -0,0 +1,27 @@
+/*
+@input: o tabla de sah n x n.
+@output: o asezare a n piese de tip regina pe tabla a.i.
+ nicio regina nu ataca o alta regina.
+
+alki nqueens.alk "n |-> 4"
+*/
+
+attacked(i, j, b) {
+ attack = false;
+ for (k = 0; k < i; ++k)
+ if ((b[k] == j) || ((b[k] - j) == (k - i)) || ((b[k] - j) == (i-k)))
+ attack = true;
+ return(attack);
+}
+
+nqueens (n) modifies b {
+ for (i = 0; i < n; ++i) {
+ choose j in { 0 .. n-1 } s.t. ! (attacked(i, j, b));
+ b[i] = j;
+ }
+}
+
+/* b[i] = the row of the queen in the i-th column; -1 initially */
+b = [-1 | i in 0..n-1];
+nqueens(n);
+
diff --git a/releases/v1.0/examples/nondeterministic/sat.alk b/releases/v1.0/examples/nondeterministic/sat.alk
new file mode 100644
index 00000000..e99bd233
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/sat.alk
@@ -0,0 +1,28 @@
+/*
+Instance: A finite set of n boolean variables and a propositional
+formula F in conjunctive normal form
+Question: Is F true for some assignment of values to the
+variables? I.e. is F satisfiable?
+
+*/
+
+f(x) {
+ return (x[0] || x[1]) &&
+ (!x[0] || x[3] || x[2]) &&
+ (x[2] || !x[3]) &&
+ (!x[1] || !x[2] || x[3]);
+}
+
+x = [ false | i in 0 .. n-1 ];
+for (i = 0; i < n; ++i) {
+ choose z in {false, true};
+ x[i] = z;
+}
+if (f(x)) print("success");
+else print("failure");
+
+/*
+
+alki sat.alk "n |-> 4"
+
+*/
\ No newline at end of file
diff --git a/releases/v1.0/examples/nondeterministic/ssd.alk b/releases/v1.0/examples/nondeterministic/ssd.alk
new file mode 100644
index 00000000..dfed6edb
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/ssd.alk
@@ -0,0 +1,23 @@
+/*
+Input: O multime S de numere intregi, M numar intreg pozitiv.
+Output: O submultime S cu sum{x | x in S} = M.
+
+*/
+
+PM = 0;
+/* chhose a maximal size for the subset */
+choose k in {1 .. S.size()};
+/* try to choose at most k-1 elements */
+for(i = 0; i < k-1; ++i) {
+ choose x in S s.t. PM + x <= M;
+ S = S \ singletonSet(x);
+ PM = PM + x;
+}
+/* try to choose the k-th element, if needed */
+if (PM != M)
+ choose x in S s.t. PM + x == M;
+/*
+
+alki ssd.alk "S |-> {1, 3, 4, 7, 9} M |-> 14"
+
+*/
\ No newline at end of file
diff --git a/releases/v1.0/examples/nondeterministic/ssd3.alk b/releases/v1.0/examples/nondeterministic/ssd3.alk
new file mode 100644
index 00000000..2e22e7ee
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/ssd3.alk
@@ -0,0 +1,20 @@
+/*
+Instance: O multime S de numere intregi, M numar intreg pozitiv.
+Question: Exista o submultime S cu sum{x | x in S} = M?
+
+*/
+
+PM = 0;
+choose k in {1 .. S.size()};
+for(i = 0; i < k; ++i) {
+ choose x in S;
+ S = S \ singletonSet(x);
+ PM = PM + x;
+}
+if (PM == M) print("success");
+else print("failure");
+/*
+
+alki ssd3.alk "S |-> {1, 3, 4, 7, 9} M |-> 14"
+
+*/
\ No newline at end of file
diff --git a/releases/v1.0/examples/nondeterministic/success.alk b/releases/v1.0/examples/nondeterministic/success.alk
new file mode 100644
index 00000000..f83b7f04
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/success.alk
@@ -0,0 +1,7 @@
+odd(x) {
+ return x % 2 == 1;
+}
+
+choose x in { 1 .. 8 };
+if (odd(x)) print("success");
+else print("failure");
diff --git a/releases/v1.0/examples/nondeterministic/xcover.alk b/releases/v1.0/examples/nondeterministic/xcover.alk
new file mode 100644
index 00000000..c8d70ece
--- /dev/null
+++ b/releases/v1.0/examples/nondeterministic/xcover.alk
@@ -0,0 +1,52 @@
+/*
+@input: A set O and a collection C of subsets of O.
+@output: A subcollection D of C such that every element of O is in exactly one set in D.
+(In other words, the union of the sets in D is O and the intersection of any two sets in D is empty.)
+
+*/
+
+thereAreInAandNotInB(A, B) {
+ forall x in A
+ if (! (x in B))
+ return true;
+ return false;
+}
+
+xcover(O, C) modifies D {
+ DU = emptySet; /* union of elements in D */
+ while (thereAreInAandNotInB(O, DU)) {
+ choose X in C s.t. ! thereAreInAandNotInB(X, DU);
+ D.pushBack(X);
+ DU = DU U X;
+ }
+}
+
+D = emptyList;
+xcover(O, C);
+
+
+/*
+O = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
+C = { C1, C2, C3, C4, C5, C6, C7, C8 } where
+ C1 = {1, 2, 3}
+ C2 = {1, 4}
+ C3 = {2, 3, 4, 5}
+ C4 = {2, 3, 8, 11}
+ C5 = {3, 6, 7}
+ C6 = {5, 7, 9}
+ C7 = {6, 10, 12}
+ C8 = {6, 11}
+
+alki xcover.alk "
+ O |-> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
+ C |-> {
+ {1, 2, 3},
+ {1, 4},
+ {2, 3, 4, 5},
+ {2, 3, 8, 11},
+ {3, 6, 7},
+ {5, 7, 9},
+ {6, 10, 12},
+ {6, 11}
+ }"
+*/
\ No newline at end of file
diff --git a/releases/v1.0/examples/probab/choc-bar.alk b/releases/v1.0/examples/probab/choc-bar.alk
new file mode 100644
index 00000000..2bab6d27
--- /dev/null
+++ b/releases/v1.0/examples/probab/choc-bar.alk
@@ -0,0 +1,25 @@
+CB(n)
+{
+ i = random(n-1) + 1;
+ s1 = float(i) / float(n);
+ s2 = float(n - i) / float(n);
+ if (s1 > s2 ) return s1;
+ return s2;
+/*
+ if (i > n - i) return i;
+ return n - i;
+*/
+}
+
+exp (n) {
+ sum = 0;
+ for (j = 0; j < n; ++j)
+ sum = sum + CB(31);
+ return sum / float(n);
+}
+
+print(exp(n));
+
+/*
+alki choc-bar.alk "n |-> 100"
+*/
diff --git a/releases/v1.0/examples/probab/compos.alk b/releases/v1.0/examples/probab/compos.alk
new file mode 100644
index 00000000..f9966253
--- /dev/null
+++ b/releases/v1.0/examples/probab/compos.alk
@@ -0,0 +1,137 @@
+/*
+ Solovay and Strassen's algorithm for compositionality
+*/
+
+gcd(a, b)
+{
+ while (a != 0 && b != 0) {
+ if (a > b) a = a % b;
+ else b = b % a;
+ }
+ return a + b;
+}
+
+swap(out a, out b)
+{
+ temp = a;
+ a = b;
+ b = temp;
+}
+
+
+jacobi(a,n)
+/*
+ n is odd and 0 < a < n
+*/
+{
+ j = 1;
+ while (a != 0) {
+ while (a % 2 == 0) { // a is even
+ a = a / 2;
+ if (n % 8 == 3 || n % 8 == 5) j = 0-j;
+ }
+ swap(a, n);
+ if (a % 4 == 3 && n % 4 == 3) j = 0-j;
+ a = a % n;
+ }
+ if (n == 1) return j;
+ else return 0;
+}
+
+/*
+j1 = jacobi(8, 15); // 1
+j2 = jacobi(9, 15); // 0
+j3 = jacobi(2, 9); // 1
+j4 = jacobi(2, 15); // 1
+j5 = jacobi(2, 11); // -1
+j6 = jacobi(2, 13); // -1
+
+j7 = jacobi(4, 9); // 1
+j8 = jacobi(8, 9); // 1 = j3*j7
+j9 = jacobi(1001, 9907); // -1
+j10 = jacobi(21, 59); // 1
+j11 = jacobi(21, 57); // 0
+j12 = jacobi(1236, 20003); // 1
+*/
+
+/*
+input: a, n, p - positive integers
+output: a^n (mod p)
+*/
+power(a, n, p)
+{
+/*
+// recursive version
+ if (n == 0) return 1;
+ else if(n == 1) return a % p;
+ else {
+ x = power(a, n/2, p);
+ if (n % 2 == 0) return (x * x) % p;
+ return (a*x*x) % p;
+ }
+*/
+// non-recursive version
+ x = 1;
+ while (n > 0)
+ if (n % 2 == 0) {
+ a = (a * a) % p ;
+ n = n / 2;
+ }
+ else {
+ x = (a * x) % p;
+ n = n - 1;
+ }
+ return x;
+}
+
+/*
+a1 = power(3, 15060/2, 15061); // 1
+a2 = power(2358, 15060/2, 15061); // 1
+*/
+
+isComp(n)
+{
+ a = random(n-3) + 2;
+ if (gcd(a, n) != 1) return "composite";
+ x = jacobi(a, n);
+ if (x < 0) x = x + n;
+ if (x != power(a, (n-1)/2, n)) return "composite";
+ return "may be prime";
+}
+
+/*
+m1[0] = 2147483647*457241;
+m1[1] = isComp(m1[0]);
+
+m2[0] = 2147483647;
+m2[1] = isComp(m2[0]);
+*/
+
+isProbPrime(n, k) {
+ while (k > 0 && isComp(n) != "composite")
+ --k;
+ if (k == 0) return "probably prime";
+ return "composite";
+}
+
+/*
+x = 1;
+for (i = 1; i < 120; ++i) x *= 2;
+
+for (i = 120; i < 130; ++i) {
+ x *= 2;
+ m3[0] = x - 1;
+ m3[1] = isProbPrime(m3[0], 100);
+ print(m3);
+}
+
+*/
+
+/*
+m3[0] = 170141183460469231731687303715884105727;
+m3[1] = isProbPrime(m3[0], 100);
+*/
+
+
+m4[0] = 2305843009213693951;
+m4[1] = isProbPrime(m4[0], 100);
diff --git a/releases/v1.0/examples/probab/isPrime.alk b/releases/v1.0/examples/probab/isPrime.alk
new file mode 100644
index 00000000..2e1e98e7
--- /dev/null
+++ b/releases/v1.0/examples/probab/isPrime.alk
@@ -0,0 +1,60 @@
+isPrime1(x) {
+ if (x < 2) return false;
+ for (i = 2; i <= x/2; ++i)
+ if (x % i == 0) return false;
+ return true;
+}
+
+
+
+
+isPrime2(x) {
+ if (x < 2) return false;
+ for (i = 2; i*i <= x; ++i)
+ if (x % i == 0) return false;
+ return true;
+}
+
+print(isPrime1(2147483647));
+/*
+$ time alki.sh isPrime.alk
+^C
+real 41m3.065s
+user 40m45.849s
+sys 0m15.643s
+*/
+//print(isPrime1(2147483647*457241));
+/*
+$ time alki.sh isPrime.alk
+false
+
+real 0m3.562s
+user 0m6.173s
+sys 0m0.273s
+*/
+//print(isPrime1(457241));
+/*
+$ time alki.sh isPrime.alk
+true
+
+real 0m2.284s
+user 0m4.243s
+sys 0m0.337s
+*/
+//print(isPrime2(2147483647));
+/*
+$ time alki.sh isPrime.alk
+true
+
+real 0m1.465s
+user 0m3.385s
+sys 0m0.155s
+*/
+//print(isPrime2(2305843009213693951));
+/*
+$ time alki.sh isPrime.alk
+^C
+real 50m14.407s
+user 49m18.198s
+sys 0m20.615s
+*/
diff --git a/releases/v1.0/examples/probab/jacobi.alk b/releases/v1.0/examples/probab/jacobi.alk
new file mode 100644
index 00000000..118232de
--- /dev/null
+++ b/releases/v1.0/examples/probab/jacobi.alk
@@ -0,0 +1,22 @@
+jacobi(a, n)
+{
+ j = 1;
+ while (a != 0) {
+ while (a % 2 == 0) { // a is even
+ a = a / 2;
+ if (n % 8 == 3 || n % 8 == 5) j = 0-j;
+ }
+ aux = n;
+ n = a;
+ a = aux;
+ if (a % 4 == 3 && n % 4 == 3) j = 0-j;
+ a = a % n;
+ }
+ if (n == 1) return j;
+ else return 0;
+}
+
+x = jacobi(2, 4);
+x1 = jacobi(2, 5);
+x2 = jacobi(3, 5);
+x3 = jacobi(4, 5);
\ No newline at end of file
diff --git a/releases/v1.0/examples/probab/random.alk b/releases/v1.0/examples/probab/random.alk
new file mode 100644
index 00000000..75399df8
--- /dev/null
+++ b/releases/v1.0/examples/probab/random.alk
@@ -0,0 +1,5 @@
+a = [0, 0, 0, 0];
+for (i = 0; i < 100000; ++i) {
+ j = random(4);
+ a[j] = a[j] + 1;
+}
diff --git a/releases/v1.0/examples/probab/randomized-select.alk b/releases/v1.0/examples/probab/randomized-select.alk
new file mode 100644
index 00000000..e0620319
--- /dev/null
+++ b/releases/v1.0/examples/probab/randomized-select.alk
@@ -0,0 +1,71 @@
+swap(out a, i, j) {
+ if (i != j) {
+ temp = a[i];
+ a[i] = a[j];
+ a[j] = temp;
+ }
+}
+
+/*
+ Lomuto partition scheme that
+ partition a[p..q] around x = a[q]
+*/
+partition(out a, p, q)
+{
+ pivot = a[q];
+ i = p - 1;
+ for (j = p; j < q; ++j)
+ if (a[j] < pivot) {
+ i = i + 1;
+ swap(a, i , j);
+ }
+ swap(a, i+1, q);
+ return i + 1;
+}
+
+
+a1 = [3, 2, 5, 4, 7, 1, 8, 6];
+k1 = partition(a1,0, 7);
+
+a2 = [3, 2, 5, 4, 7, 1, 6, 8];
+k2 = partition(a2,0, 7);
+
+a3 = [3, 2, 5, 4, 7, 6, 8, 1];
+k3 = partition(a3,0, 7);
+
+
+/*
+ randomized partition
+*/
+randPartition(out a, p, q) {
+ if (p < q) {
+ i = p + random(q - p);
+ swap(a, i, q);
+ return partition(a, p, q);
+ }
+}
+
+/*
+a = [3, 2, 5, 4, 7, 1, 8, 6];
+k4 = randPartition(a,0, 7);
+*/
+
+/*
+ randomized select
+*/
+randSelectRec(out a, p, q, k)
+{
+ j = randPartition(a, p, q);
+ if (j == k) return a[j];
+ if (j < k) return randSelectRec(a, j+1, q, k);
+ return randSelectRec(a, p, j-1, k);
+}
+
+randSelect(out a, k)
+{
+ return randSelectRec(a, 0, a.size()-1, k);
+}
+/*
+a = [3, 2, 5, 4, 7, 1, 8, 6];
+k4 = randSelect(a, 4);
+*/
\ No newline at end of file
diff --git a/releases/v1.0/examples/regexp/ast.alk b/releases/v1.0/examples/regexp/ast.alk
new file mode 100644
index 00000000..b1862a0a
--- /dev/null
+++ b/releases/v1.0/examples/regexp/ast.alk
@@ -0,0 +1,149 @@
+// the root of an AST
+root(ast) {
+ if (ast.size() > 0) return ast[0];
+}
+
+
+// the number of children
+chldNo(ast) {
+ if (ast.size() > 0) return ast[1].size();
+ return 0;
+}
+
+// the i-th child of an AST
+chld(ast, i) {
+ if (ast.size() > 0 && i < ast[1].size()) {
+ return ast[1].at(i);
+ }
+}
+
+// updates a child
+updatedChld(ast, i, newchld) {
+ if (ast.size() > 0 && ast[1].size() > 0)
+ if (i >= 0 && i < ast[1].size()) {
+ ast[1].update(i, newchld);
+ return ast;
+ }
+}
+
+// removes a child
+removedChld(ast, i) {
+ if (ast.size() > 0 && ast[1].size() > 0)
+ if (i >= 0 && i < ast[1].size()) {
+ ast[1].removeAt(i);
+ return ast;
+ }
+}
+
+/* tests:
+print(updatedChld(["_+_", <["a", <>], ["", <>]>], 1, ["b", <>]));
+print(updatedChld(["_+_", <["a", <>], ["", <>]>], 0, ["b", <>]));
+print(updatedChld(["_+_", <["a", <>], ["", <>]>], 2, ["b", <>]));
+*/
+
+/*
+ Simplifies an AST using the unit/domination law
+ for empty and eps
+ TODO: add the associativity law for _+_ and _._
+*/
+simplify1(ast) {
+ if (ast == []) // empty
+ return ast;
+ if (len(root(ast)) <= 1) // eps or in Sigma
+ return ast;
+ if (root(ast) == "_+_" ) { // a sum expression
+ for (i = 0; i < chldNo(ast); ++i) {
+ if (chld(ast, i) == []) //i-th child is empty
+ ast = removedChld(ast, i);
+ else //i-th child is non-empty
+ ast = updatedChld(ast, i, simplify1((chld(ast, i))));
+ }
+ if (chldNo(ast) == 0)
+ return [];
+ else if (chldNo(ast) == 1)
+ return chld(ast,0);
+ else
+ return ast;
+ }
+ if (root(ast) == "_._" ) { // a product expression
+ for (i = 0; i < chldNo(ast); ++i) {
+ if (chld(ast, i) == []) //i-th child is empty
+ return [];
+ else if (root(chld(ast, i)) == "") //i-th child is eps
+ ast = removedChld(ast, i);
+ else //i-th child is non-empty or eps
+ ast = updatedChld(ast, i, simplify1((chld(ast, i))));
+ }
+ if (chldNo(ast) == 0) // removed all children
+ return ["", <>];
+ else if (chldNo(ast) == 1) // just one child remained
+ return chld(ast,0);
+ else // at least two children
+ return ast;
+ }
+ if (root(ast) == "_*") // a star expression
+ if (chld(ast, 0) == []) // empty
+ return [];
+ else
+ return ["_*", < simplify1(chld(ast, 0)) >];
+ return ast;
+}
+
+
+/*
+tests:
+print(simplify1(["_+_", <["a", <>], []>]));
+print(simplify1(["_+_", <[], ["b", <>]>]));
+print(simplify1(["_+_", <[], []>]));
+print(simplify1(["_._", <[], ["", <>]>]));
+print(simplify1(["_._", <["", <>], []>]));
+print(simplify1(["_._", <["a", <>], ["", <>]>]));
+print(simplify1(["_._", <["", <>], ["b", <>]>]));
+*/
+
+simplify(ast) {
+ do {
+ ast1 = ast;
+ ast = simplify1(ast1);
+ } while (ast != ast1);
+ return ast;
+}
+
+
+/*
+tests:
+*/
+print(["_._", < ["_+_", <[], []>], ["_._", < ["a", <>], ["_._", <["", <>], ["", <>]>] >]>]);
+print(simplify(["_._", < ["_+_", <[], []>], ["_._", < ["a", <>], ["_._", <["", <>], ["", <>]>] >]>]));
+ print(simplify1(simplify (["_._", < ["_+_", <[], []>], ["_._", < ["a", <>], ["_._", <["", <>], ["", <>]>] >]>])));
+
+
+// the string representation of an AST
+ast2string(ast) {
+ if (ast == []) str = "";
+ else if (chldNo(ast) == 0) str = root(ast);
+ else if (root(ast) == "_+_") {
+ str = "(" + ast2string(chld(ast,0));
+ n = chldNo(ast);
+ for (i = 1; i < n; ++i)
+ str = str + " + " + ast2string(chld(ast, i));
+ str = str + ")";
+ }
+ else if (root(ast) == "_._") {
+ str = ast2string(chld(ast,0));
+ n = chldNo(ast);
+ for (i = 1; i < n; ++i)
+ str = str + ast2string(chld(ast, i));
+ }
+ else if (root(ast) == "_*")
+ str = ast2string(chld(ast, 0)) + "*";
+ else
+ return "undefined";
+ return str;
+}
+
+/* tests:
+print(ast2string(["_._", <["a", <>], ["b", <>]>]));
+print(ast2string(["_._", <["a", <>], ["_*", <["_+_", <["a", <>], ["b", <>]>]>], ["_._", <["a", <>], ["b", <>]>]>]));
+*/
+
diff --git a/releases/v1.0/examples/regexp/detaut.alk b/releases/v1.0/examples/regexp/detaut.alk
new file mode 100644
index 00000000..06984103
--- /dev/null
+++ b/releases/v1.0/examples/regexp/detaut.alk
@@ -0,0 +1,401 @@
+// ***begin of copy-paste from ast.alk***
+
+// the root of an AST
+root(ast) {
+ if (ast.size() > 0) return ast[0];
+}
+
+
+// the number of children
+chldNo(ast) {
+ if (ast.size() > 0) return ast[1].size();
+ return 0;
+}
+
+// the i-th child of an AST
+chld(ast, i) {
+ if (ast.size() > 0 && i < ast[1].size()) {
+ return ast[1].at(i);
+ }
+}
+
+// updates a child
+updatedChld(ast, i, newchld) {
+ if (ast.size() > 0 && ast[1].size() > 0)
+ if (i >= 0 && i < ast[1].size()) {
+ ast[1].update(i, newchld);
+ return ast;
+ }
+}
+
+
+// removes a child
+removedChld(ast, i) {
+ if (ast.size() > 0 && ast[1].size() > 0)
+ if (i >= 0 && i < ast[1].size()) {
+ ast[1].removeAt(i);
+ return ast;
+ }
+}
+
+
+/*
+ Simplifies an AST using the unit/domination law
+ for empty and eps
+ TODO: add the associativity law for _+_ and _._
+*/
+simplify1(ast) {
+ if (ast == []) // empty
+ return ast;
+ if (len(root(ast)) <= 1) // eps or in Sigma
+ return ast;
+ if (root(ast) == "_+_" ) { // a sum expression
+ for (i = 0; i < chldNo(ast); ++i) {
+ if (chld(ast, i) == []) //i-th child is empty
+ ast = removedChld(ast, i);
+ else //i-th child is non-empty
+ ast = updatedChld(ast, i, simplify1((chld(ast, i))));
+ }
+ if (chldNo(ast) == 0)
+ return [];
+ else if (chldNo(ast) == 1)
+ return chld(ast,0);
+ else
+ return ast;
+ }
+ if (root(ast) == "_._" ) { // a product expression
+ for (i = 0; i < chldNo(ast); ++i) {
+ if (chld(ast, i) == []) //i-th child is empty
+ return [];
+ else if (root(chld(ast, i)) == "") //i-th child is eps
+ ast = removedChld(ast, i);
+ else //i-th child is non-empty or eps
+ ast = updatedChld(ast, i, simplify1((chld(ast, i))));
+ }
+ if (chldNo(ast) == 0) // removed all children
+ return ["", <>];
+ else if (chldNo(ast) == 1) // just one child remained
+ return chld(ast,0);
+ else // at least two children
+ return ast;
+ }
+ if (root(ast) == "_*") // a star expression
+ if (chld(ast, 0) == []) // empty
+ return [];
+ else
+ return ["_*", < simplify1(chld(ast, 0)) >];
+ return ast;
+}
+
+simplify(ast) {
+ do {
+ ast1 = ast;
+ ast = simplify1(ast1);
+ } while (ast != ast1);
+ return ast;
+}
+
+
+
+// the string representation of an AST
+ast2string(ast) {
+ if (ast == []) str = "";
+ else if (chldNo(ast) == 0) str = root(ast);
+ else if (root(ast) == "_+_") {
+ str = "(" + ast2string(chld(ast,0));
+ n = chldNo(ast);
+ for (i = 1; i < n; ++i)
+ str = str + " + " + ast2string(chld(ast, i));
+ str = str + ")";
+ }
+ else if (root(ast) == "_._") {
+ str = ast2string(chld(ast,0));
+ n = chldNo(ast);
+ for (i = 1; i < n; ++i)
+ str = str + ast2string(chld(ast, i));
+ }
+ else if (root(ast) == "_*")
+ str = ast2string(chld(ast, 0)) + "*";
+ else
+ return "undefined";
+ return str;
+}
+
+// ***end of copy-paste from ast.alk***
+
+/*
+ epsIn(E) stands for true if L(E) contains the empty string;
+ otherwise, espIn(E) stands for 0.
+*/
+epsIn(ast) {
+ if (ast == []) return false;
+ if (root(ast) == "") // eps
+ return true;
+ if (root(ast) == "_+_") {
+ answ = epsIn(chld(ast, 0));
+ for (i = 1; i < chldNo(ast); ++i) {
+ asw = answ || epsIn(chld(ast, i));
+// if (epsIn(chld(ast, i)))
+// answ = true;
+ }
+ return answ;
+ }
+ if (root(ast) == "_._") {
+ answ = epsIn(chld(ast, 0));
+ for (i = 1; i < chldNo(ast); ++i) {
+ asw = answ && epsIn(chld(ast, i));
+// if (!epsIn(chld(ast, i)))
+// answ = false;
+ }
+ return answ;
+ }
+ if (root(ast) == "_*")
+ return true;
+ return false;
+}
+
+
+
+
+
+/*
+tests:
+print(epsIn(["_._", <["a", <>], ["a", <>]>]));
+print(epsIn(["_+_", <["a", <>], ["", <>]>]));
+*/
+// teste care arata aparitia bug-ului (a se vedea mesajele printate)
+//((ab + b)*ba)
+//print(epsIn(["_._", <["_*", <["_+_", <["_._", <["a", <>], ["b", <>]>], ["b", <>]>]>], ["b", <>], ["a", <>]>]));
+//(b(ab + b)*ba + )
+//print(epsIn(["_+_", <["_._", <["b", <>], ["_*", <["_+_", <["_._", <["a", <>], ["b", <>]>], ["b", <>]>]>], ["b", <>], ["a", <>]>], ["", <>]>]));
+
+
+/*
+ Brzozowski's derivatives:
+ lang(der(E,a)) = {w | aw in lang(E)}
+*/
+der(ast, a) {
+ if (ast == []) astder = [];
+ else if (chldNo(ast) == 0) {
+ if (root(ast) == a) astder = ["", <>];
+ else astder = [];
+ }
+ else if (root(ast) == "_+_") {
+ chlds = <>;
+ for (i = 0; i < chldNo(ast); ++i)
+ chlds.pushBack(der(chld(ast,i), a));
+ astder = ["_+_", chlds];
+ }
+ else if (root(ast) == "_._") {
+ epsInPref = true;
+ chlds = < >;
+ i = 0;
+ while (epsInPref && i < chldNo(ast) - 1 ) {
+ chldsi = < der(chld(ast,i), a) >;
+ for (j = i + 1; j < chldNo(ast); ++j)
+ chldsi.pushBack(chld(ast,j));
+ chlds.pushBack(["_._", chldsi]);
+ epsInPref = epsIn(chld(ast, i));
+ i++;
+ }
+ if (chlds.size() == 1)
+ astder = chlds.at(0);
+ else
+ astder = ["_+_", chlds];
+ }
+ else if (ast[0] == "_*")
+ astder = ["_._", < der(chld(ast, 0), a), ast >];
+ return astder;
+}
+
+/*
+tests:
+print(ast2string(["_._", <["a", <>], ["b", <>]>]));
+print(ast2string(der(["_._", <["a", <>], ["b", <>]>], "a")));
+print(ast2string(["_._", <["a", <>], ["_*", <["_+_", <["a", <>], ["b", <>]>]>], ["_._", <["a", <>], ["b", <>]>]>]));
+print(ast2string(der(["_._", <["a", <>], ["_*", <["_+_", <["a", <>], ["b", <>]>]>], ["_._", <["a", <>], ["b", <>]>]>], "a")));
+print(ast2string(["_+_", <["a", <>], ["b", <>]>]));
+print(ast2string(der(["_+_", <["a", <>], ["b", <>]>], "a")));
+print(ast2string(["_*", <["_+_", <["a", <>], ["b", <>]>]>]));
+print(ast2string(der(["_*", <["_+_", <["a", <>], ["b", <>]>]>], "a")));
+*/
+
+
+/*
+tests:
+print(der(["_._", <["a", <>], ["b", <>]>], "a"));
+print(simplify(der(["_._", <["a", <>], ["b", <>]>], "a")));
+print(der(["_+_", <["a", <>], ["b", <>]>], "a"));
+print(simplify1(der(["_+_", <["a", <>], ["b", <>]>], "a")));
+print(der(["_*", <["_+_", <["a", <>], ["b", <>]>]>], "a"));
+print(simplify(der(["_*", <["_+_", <["a", <>], ["b", <>]>]>], "a")));
+*/
+
+/*
+print((simplify (der(["_._", <["_*", <["_+_", <["_._", <["a", <>], ["b", <>]>], ["b", <>]>]>], ["b", <>], ["a", <>]>], "a"))));
+print((simplify (der(["_._", <["_*", <["_+_", <["_._", <["a", <>], ["b", <>]>], ["b", <>]>]>], ["b", <>], ["a", <>]>], "b"))));
+print((simplify (der(["_._", <["_*", <["_+_", <["_._", <["a", <>], ["b", <>]>], ["b", <>]>]>], ["b", <>], ["a", <>]>], "c"))));
+*/
+
+/*
+print(["_._", < ["_+_", <[], []>], ["_._", < ["a", <>], ["_._", <["", <>], ["", <>]>] >]>]);
+print(simplify(["_._", < ["_+_", <[], []>], ["_._", < ["a", <>], ["_._", <["", <>], ["", <>]>] >]>]));
+print(der(["_*", <["_+_", <["a", <>], ["b", <>]>]>], "a"));
+print(simplify(der(["_*", <["_+_", <["a", <>], ["b", <>]>]>], "a")));
+*/
+
+getState (map, str) {
+ forall pair in map
+ if(pair[1] == str)
+ return pair[0];
+}
+
+
+/*
+ Brzozowski's automaton
+*/
+detAut(ast, Sigma) {
+ state = 0;
+ ast = simplify(ast);
+ if (epsIn(ast))
+ map = < [state, ast, "acc"] >;
+ else
+ map = < [state, ast, ""] >;
+ derSet = { ast };
+ do {
+ derSet1 = derSet;
+ forall s in Sigma
+ forall ast in derSet1 {
+ ast1 = simplify(der(ast, s));
+ if (!(ast1 in derSet) && ast1 != []) {
+ derSet = derSet U { ast1 };
+ state++;
+ if (epsIn(ast1)) {
+ map.pushBack([state, ast1,"acc"]);
+ }
+ else
+ map.pushBack([state, ast1, ""]);
+ }
+ }
+ } while (derSet != derSet1);
+ aut = {};
+ forall p in map
+ forall q in map
+ forall s in Sigma
+ if (q[1] == simplify(der(p[1], s)))
+ aut = aut U { < p[0], s, q[0] > };
+ forall p in map
+ p[1] = ast2string(p[1]);
+ return [aut, map];
+}
+
+/* tests:
+am = detAut(["a", <>], ["a", "b", "c"]);
+print(am[0]);
+forall p in am[1]
+ print(p);
+am = detAut(["_+_", <["_*", <["_+_", <["_._", <["a", <>], ["c", <>]>], ["c", <>]>]>], ["_*", <["_+_", <["_._", <["a", <>], ["a", <>]>], ["b", <>]>]>]>], ["a", "b", "c"]);
+print(am[0]);
+forall p in am[1]
+ print(p);
+*/
+am = detAut(["_._", <["_*", <["_+_", <["_._", <["a", <>], ["b", <>]>], ["b", <>]>]>], ["b", <>], ["a", <>]>], ["a", "b", "c"]);
+/*
+print(am[0]);
+forall p in am[1]
+ print(p);
+*/
+
+
+/*
+ if aut = am[0] may consume a in the state,
+ then returns an array consists of
+ - the new state
+ - and a string = "acc" if the new state
+ is an accepting state, = "" otherwise
+ otherwise returns [-1] (invalid state)
+*/
+expected(am, state, a)
+{
+ aut = am[0];
+ map = am[1];
+ forall trans in aut {
+ if (trans.at(0) == state && trans.at(1) == a) { // expected
+ newState = trans.at(2);
+ return [newState, map.at(newState)[2]];
+ }
+ }
+ return [-1];
+}
+
+/* tests:
+print(expected(am, 0, "a"));
+print(expected(am, 2, "a"));
+print(expected(am, 3, "a"));
+*/
+
+/*
+ @input: a string s[0..n-1],
+ a pair am consisting of
+ an automaton am[0] and a map am[1] with the states
+ (computed by detAut),
+ a position i, 0 <= i < n
+ @output: true, if s[i..i+m-1] is accepted by aut,
+ false, otherwise
+*/
+occAtPos(s, am, i)
+{
+ n = s.size();
+ aut = am[0];
+ state = 0; // the current state is the initial state
+ for (j = 0; true; ++j) {
+ exp = expected (am, state, s[i+j]);
+ if (i + j < n && exp[0] >= 0) { // expected
+ state = exp[0];
+ if (exp[1] == "acc") // accepted
+ return true;
+ // else: expected but not accepted
+ }
+ else
+ return false; // not expected
+ }
+}
+
+/* tests:
+subj = "cbbaaabbacc";
+s = subj.split();
+print(occAtPos(s, am, 0));
+print(occAtPos(s, am, 1));
+print(occAtPos(s, am, 2));
+print(occAtPos(s, am, 3));
+print(occAtPos(s, am, 4));
+print(occAtPos(s, am, 5));
+print(occAtPos(s, am, 6));
+*/
+
+/*
+ @input: strings s[0..n-1],
+ a pair am consisting of
+ an automaton am[0] and a map am[1] with the states
+ (computed by detAut),
+ @ouput: the first occurence of p in s, if any
+ -1, otherwise
+*/
+firstOcc(s, am)
+{
+ n = s.size();
+ for (i = 0; i < n; ++i) {
+ if (occAtPos(s, am, i)) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+/* tests:
+*/
+subj = "cbbaaabbacc";
+s = subj.split();
+print(firstOcc(s, am));
+
diff --git a/releases/v1.0/examples/regexp/lang.alk b/releases/v1.0/examples/regexp/lang.alk
new file mode 100644
index 00000000..acde2bdb
--- /dev/null
+++ b/releases/v1.0/examples/regexp/lang.alk
@@ -0,0 +1,84 @@
+
+// the root of an AST
+root(ast) {
+ if (ast.size() > 0) return ast[0];
+}
+
+// the number of children
+chldNo(ast) {
+ if (ast.size() > 0) return ast[1].size();
+ return 0;
+}
+
+// the i-th child of an AST
+chld(ast, i) {
+ if (ast.size() > 0 && i < ast[1].size()) {
+ return ast[1].at(i);
+ }
+}
+
+
+/*
+anast = ["_*", <["_+_", <["_._", <["a", <>], ["a", <>]>], ["b", <>]>]>];
+print(root(anast));
+print(chld(anast, 0));
+print(chld(["_+_", <["_._", <["a", <>], ["a", <>]>], ["b", <>]>], 0));
+print(chld (["_+_", <["_._", <["a", <>], ["a", <>]>], ["b", <>]>], 1));
+*/
+
+// the product of two languages
+prod(L1, L2) {
+ L = {};
+ forall s1 in L1
+ forall s2 in L2
+ L = L U { s1 + s2 };
+ return L;
+}
+
+/*
+print(prod({["a", "b"], ["c", "d", "e"]}, {["1", "2"], ["3", "4", "5"]}));
+print(prod({}, {["1", "2"], ["3", "4", "5"]}));
+print(prod({["a", "b"], ["c", "d", "e"]}, {}));
+print(prod({["a"]}, {["1", "2"], ["3", "4", "5"]}));
+print(prod({["a", "b"], ["c", "d", "e"]}, {["1"]}));
+print(prod({[]}, {["1", "2"], ["3", "4", "5"]}));
+print(prod({["a", "b"], ["c", "d", "e"]}, {[]}));
+*/
+
+// the bounded language defined by a regular expression
+lang(ast, k) {
+ if (ast == []) L = {};
+ else if (chldNo(ast) == 0)
+ L = {root(ast)};
+ else if (root(ast) == "_+_") {
+ L = {};
+ for (i = 0; i < chldNo(ast); ++i)
+ L = L U lang(chld(ast, i),k);
+ }
+ else if (root(ast) == "_._") {
+ L = {""};
+ for (i = 0; i < chldNo(ast); ++i)
+ L = prod(L, lang(chld(ast, i),k));
+ }
+ else if (root(ast) == "_*") {
+ L = {""};
+ Li = {""};
+ L1 = lang(chld(ast, 0), k);
+ for (i = 0; i < k; ++i) {
+ Li = prod(Li, L1);
+ L = L U Li;
+ }
+ }
+ else return "undefined";
+ return L;
+}
+
+/* tests:
+print(lang(["a", <>], 2));
+print(lang(["_*", <["a", <>]>], 2));
+print(lang(["_._", <["a", <>], ["a", <>]>], 2));
+print(lang(["_+_", <["a", <>], ["b", <>]>], 2));
+*/
+print(lang(["_*", <["_+_", <["a", <>], ["b", <>]>]>], 3));
+//print(lang(["",<>],1));
+
diff --git a/releases/v1.0/examples/regexp/parser.alk b/releases/v1.0/examples/regexp/parser.alk
new file mode 100644
index 00000000..79bb23c5
--- /dev/null
+++ b/releases/v1.0/examples/regexp/parser.alk
@@ -0,0 +1,146 @@
+/*
+
+ Sigma ::= "a" | "b" | "c"
+
+ expression ::= term ("+" term)*
+ term ::= maybeStar
+ | maybeStar ("." maybeStar)*
+ maybeStar ::= factor ["*"] // equiv to factor | factor "*"
+ factor ::=
+ Sigma
+ | "(" expression ")"
+
+*/
+
+
+// the current position in the input
+index = 0;
+
+// the current symbol
+sym() modifies index, input {
+ if (index < input.size())
+ return input.at(index);
+ return "\0";
+}
+
+// goes to the next symbol
+nextSym() modifies index, input {
+ if (index < input.size()) {
+ index++;
+/*
+ // skip the spaces
+ while (input.at(index) == " " && index < input.size())
+ index++;
+*/
+ } else
+ error("nextsym: expected a symbol");
+}
+
+// prints an error message
+error(msg) modifies index {
+ print(msg + " at position ");
+ print(index);
+ print("");
+}
+
+/*
+ tests if the current symbol is accepted and
+ if yes, advances in the input
+*/
+accept(s) {
+ if (sym() == s) {
+ nextSym();
+ return true;
+ }
+ return false;
+}
+
+/*
+ test if the current symbol is in the alphabet Sigma and
+ if yes, advances in the input
+*/
+acceptSigma() modifies sigma {
+ for (i = 0; i < sigma.size(); ++i)
+ if (accept(sigma[i])) {
+ return true;
+ }
+ return false;
+}
+
+// test if the current symbol is the exptected one
+expect(s) {
+ if (accept(s))
+ return true;
+ error("expect: unexpected symbol");
+ return false;
+}
+
+// parses a factor and returs its AST
+factor() {
+ s = sym();
+ if (acceptSigma()) {
+ return [s,<>];
+ } else if (accept("(")) {
+ ast = expression();
+ expect(")");
+ }
+ return ast;
+}
+
+// parses a maybeStar and returs its AST
+maybeStar() {
+ ast = factor();
+ if (accept("*"))
+ return < ["_*", ast] >;
+ else
+ return ast;
+}
+
+// parses a term and returs its AST
+/*
+term() {
+ ast = factor();
+ list = < ast >;
+ if (accept("*")) list = < ["_*", list] >;
+ while (accept(".")) {
+ ast1 = factor();
+ if (accept("*")) list.pushBack(["_*", < ast1 >]);
+ else list.pushBack(ast1);
+ }
+ if (list.size() > 1)
+ return ["_._", list];
+ else
+ return list.at(0);
+}
+*/
+term() {
+ ast = maybeStar();
+ list = < ast >;
+ while (accept(".")) {
+ ast1 = maybeStar();
+ list.pushBack(ast1);
+ }
+ if (list.size() > 1)
+ return ["_._", list];
+ else
+ return list.at(0);
+}
+
+// parses an epression and returs its AST
+expression() {
+ ast = term();
+ list = < ast >;
+ while (accept("+")) {
+ ast = term();
+ list.pushBack(ast);
+ }
+ if (list.size() > 1)
+ return ["_+_", list];
+ else
+ return list.at(0);
+}
+// the alphabet
+sigma = ["a","b","c"];
+// the expression
+input = "(a.b+b)*.(b.a)";
+print(expression());
diff --git a/releases/v1.0/examples/scalars/scalars1.alk b/releases/v1.0/examples/scalars/scalars1.alk
new file mode 100644
index 00000000..ea1abcba
--- /dev/null
+++ b/releases/v1.0/examples/scalars/scalars1.alk
@@ -0,0 +1,10 @@
+index = 234;
+isEven = true;
+radius = 21.468;
+name = "john";
+print(index);
+print(isEven);
+print(radius);
+print(name);
+
+
diff --git a/releases/v1.0/examples/string-alg/bm.alk b/releases/v1.0/examples/string-alg/bm.alk
new file mode 100644
index 00000000..56ff11a3
--- /dev/null
+++ b/releases/v1.0/examples/string-alg/bm.alk
@@ -0,0 +1,51 @@
+Sigma = ["a","b","c","d"];
+
+SigmaInv(c) modifies Sigma {
+ j = 0;
+ while (Sigma[j] != c)
+ j++;
+ return j;
+}
+
+detSalt(p, out salt) modifies Sigma {
+ m = p.size();
+ for (i = 0; i < Sigma.size(); ++i)
+ salt[i] = m;
+ for (i = m-1; i >= 0; --i) {
+ j = SigmaInv(p[i]);
+ if (salt[j] == m)
+ salt[j] = (m-1) - i;
+ }
+}
+
+BM(s, p, salt) {
+ n = s.size();
+ m = p.size();
+ i = m-1; j = m-1;
+ // repeat
+ while (j >= 0 && i <= n-1) {
+ k = SigmaInv(s[i]);
+ if (s[i] == p[j]) {
+ i = i-1;
+ j = j-1;
+ }
+ else {
+ if ((m-j) > salt[k]) i = i+m-j; // Sigma[k] = s[i]
+ else i = i + salt[k]; // Sigma[k] = s[i]
+ j = m-1;
+ }
+ }
+ // until (j<0 or i>n-1);
+ if (j<0) return i+1;
+ else return -1;
+}
+
+s = ["a","b", "d", "c", "d", "a", "b", "a", "c", "d"];
+p = ["b", "a", "c"];
+
+saltp = [];
+detSalt(p, saltp);
+print(BM(s, p, saltp));
+
+
+
diff --git a/releases/v1.0/examples/string-alg/kmp.alk b/releases/v1.0/examples/string-alg/kmp.alk
new file mode 100644
index 00000000..5bd9a9fe
--- /dev/null
+++ b/releases/v1.0/examples/string-alg/kmp.alk
@@ -0,0 +1,50 @@
+
+detEsec(p, out f) {
+ m = p.size();
+ f[0] = -1; f[1] = 0;
+ k = 0;
+ for (i = 2; i < m; ++i) {
+ // invariant: k = f[i-1]
+ // while(k >= 0 && p[k] != p[i-1]) {
+ match = p[k] == p[i-1];
+ while(k >= 0 && !match) {
+ // invariant: exista j cu k = f^j[i-1] si
+ // j este cel mai mic cu p[f^j[i-1]+1] != p[i-1]
+ k = f[k];
+ if (k >= 0) match = p[k] == p[i-1];
+ }
+ k = k + 1;
+ f[i] = k;
+ }
+}
+
+/*
+p = ["a", "b", "a", "b", "a", "c", "a"];
+fp = [];
+detEsec(p, fp);
+*/
+
+KMP(s, p, f) {
+ n = s.size();
+ m = p.size();
+ i = 0;
+ k = 0;
+ while (i < n) {
+ while ((k != -1) && (p[k] != s[i]))
+ k = f[k];
+ // k == -1 or p[k] == s[i]
+ if (k == m-1)
+ return i-m+1; /* gasit p in s */
+ else {
+ i = i+1;
+ k = k+1;
+ }
+ }
+ return -1; /* p nu apare in s */
+}
+
+p = ["a", "b", "a", "b", "a", "c", "a"];
+s = ["a", "b", "a", "a", "b", "a", "b", "a", "c", "a", "a", "c", "a"];
+fp = [];
+detEsec(p, fp);
+print(KMP(s, p, fp));
diff --git a/releases/v1.0/examples/string-alg/naiv-search.alk b/releases/v1.0/examples/string-alg/naiv-search.alk
new file mode 100644
index 00000000..d8339876
--- /dev/null
+++ b/releases/v1.0/examples/string-alg/naiv-search.alk
@@ -0,0 +1,45 @@
+/*
+ @input: strings s[0..n-1], p[0..m-1],
+ a position i, 0 <= i < n
+ @output: true, if p <=_pref s[i..n-1]
+ false, otherwise
+*/
+occAtPos(s, p, i)
+{
+ n = s.size();
+ m = p.size();
+ for (j = 0; j < m; ++j) {
+ if (i + j >= n || s[i + j] != p[j]) {
+ return false;
+ }
+ }
+ return true;
+}
+
+/*
+s=["a","b", "a", "c", "b", "a", "b", "a", "c"];
+p = ["b", "a", "c"];
+print(occAtPos(s, p, 2));
+*/
+
+
+/*
+ @input: strings s[0..n-1], p[0..m-1]
+ @ouput: the first occurence of p in s, if any
+ -1, otherwise
+*/
+firstOcc(s, p)
+{
+ n = s.size();
+ m = p.size();
+ for (i = 0; i < n; ++i) {
+ if (occAtPos(s, p, i)) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+s = ["a","b", "a", "c", "b", "a", "b", "a", "c"];
+p = ["b", "a", "c"];
+print(firstOcc (s, p));