start of yamllexer

This commit is contained in:
rumpf_a@web.de 2010-02-21 23:44:53 +01:00
commit 6da95ed9ca
8 changed files with 397 additions and 2 deletions

View file

@ -0,0 +1,6 @@
# Test a submodule
#type
# TStringArr = array [0.. *] of string
proc exportme* = nil

View file

@ -0,0 +1,67 @@
type
Feature = tuple[name: string, version: string]
PDOMImplementation* = ref DOMImplementation
DOMImplementation = object
Features: seq[Feature] # Read-Only
PNode* = ref Node
Node = object
attributes*: seq[PAttr]
childNodes*: seq[PNode]
FLocalName: string # Read-only
FNamespaceURI: string # Read-only
FNodeName: string # Read-only
nodeValue*: string
FNodeType: int # Read-only
FOwnerDocument: PDocument # Read-Only
FParentNode: PNode # Read-Only
prefix*: string # Setting this should change some values... TODO!
PElement* = ref Element
Element = object of Node
FTagName: string # Read-only
PCharacterData = ref CharacterData
CharacterData = object of Node
data*: string
PDocument* = ref Document
Document = object of Node
FImplementation: PDOMImplementation # Read-only
FDocumentElement: PElement # Read-only
PAttr* = ref Attr
Attr = object of Node
FName: string # Read-only
FSpecified: bool # Read-only
value*: string
FOwnerElement: PElement # Read-only
PDocumentFragment* = ref DocumentFragment
DocumentFragment = object of Node
PText* = ref Text
Text = object of CharacterData
PComment* = ref comment
Comment = object of CharacterData
PCDataSection* = ref CDataSection
CDataSection = object of Text
PProcessingInstruction* = ref ProcessingInstruction
ProcessingInstruction = object of Node
data*: string
FTarget: string # Read-only
proc `namespaceURI=`*(n: var PNode, value: string) =
n.FNamespaceURI = value
proc main =
var n: PNode
new(n)
n.namespaceURI = "test"
main()

View file

@ -0,0 +1,9 @@
# Module A
var
lastId = 0
template genId*: expr =
inc(bind lastId)
lastId

View file

@ -0,0 +1,9 @@
import StrUtils, Math
proc FibonacciA(n: int): int64 =
var fn = float64(n)
var p: float64 = (1.0 + sqrt(5.0)) / 2.0
var q: float64 = 1.0 / p
return int64((pow(p, fn) + pow(q, fn)) / sqrt(5.0))
echo FibonacciA(4) #OUT 10

9
tests/reject/mbind4.nim Normal file
View file

@ -0,0 +1,9 @@
# Module A
var
lastId = 0
template genId*: expr =
inc(lastId)
lastId

5
tests/reject/tinc.nim Normal file
View file

@ -0,0 +1,5 @@
var x = 0
inc(x+1) #ERROR_MSG to var type a variable needs to be passed