NAME
Syntax::Kamelon::Builder - Builds a lexer from an xml file
SYNOPSIS
use Syntax::Kamelon::Builder;
my $lexer = Syntax::Kamelon::Builder->new(%options);
DESCRIPTION
This module inherits Syntax::Kamelon::XMLData.
The constructor does not return an object but a data structure called a lexer. Below more details of what it looks like. You will never have the opportunity to call any of it's methods. It creates a lexer and says bye bye. If fact you never have to create an instance of it. Kamelon does that for you.
OPTIONS
The constructor is called with a paired list or hash of options as parameters. You must use the following options.
- engine => $ref
-
A reference to the main Kamelon object.
- xmlfile => $filename
-
Full path and file name of the xml file to load.
STRUCTURE OF A LEXER
- Global overview
-
my $lexer = { basecontext => 'first', contexts => { first => { }, second => { } }, deliminators => ".|(|)|:|!|+|,|-|<|=|>|%|&|*|/|;|?|[|]|^|{|||}|~|\\", lists => { mycolors => { red => 1, yellow => 1, }, } syntax => 'Name', };
Notice that lists are in fact hashes. This is for faster lookup. After all we only need to know if an entry exists or not.
- The contexts in detail
-
my $context = { attribute => $something, callbacks => [ #the rules in action [\&testMethod, @options, $contextshifter, $attribute, @resultparsers], [\&testMethod2, @options2, $contextshifter2, $attribute2, @resultparsers2], #etcetera ], debug => [ [$reftohash, #all the data that was previously in the items key of the context hash. ], [], #etcetera ], dynamic => 0, #or 1 emptycontext => \&contextshifter, endcontext => \&contextshifter, fallthroughcontext => undef, #or also a context shifter info => { #All of the data from the context hash except the items key (the rules) } };
- Context shifters
- Result parsers
SYSTEM METHODS
- AttributeGet($attribute);
-
Returns the style tag belonging to $attribute in the Attributes hash. If it cannot find it it will log a warning and return the style tag belonging to the current context.
- AttributeGetF($attribute);
-
Uses AttributeGet to obtain the styel tag. Returns the format information belonging to the style tag.
- ContextExists($contextname);
-
Returns true if the context exists in the contexts hash.
- CurContext($contextname);
-
Sets and returns the current context.
- CurContextIsDynamic
-
Returns true if the current context is dynamic.
- CurRuleI(<$rulenumber>);
-
Sets and returns the current rule within the current context.
- DeliminatorsI(<$rulenumber>);
-
Sets and returns the composed deliminators string. It is composed of the general deliminators, the WaekDeliminator and the AdditionalDeliminator.
- Engine
-
Returns a reference to the main Kamelon object.
- LogWarning($message);
-
And exacter Warning mechanism than Kamelon has.
- RuleGetArgs($reftorule, @optionstoretrieve));
-
Returns a list of the values belonging to @optionstoretrieve.
- RuleGetChar($char);
-
Generally a char data type consists of one character. However, an escaped character has two. This methods returns the escaped character also as the real character. so a newline for a \n etc.
- Setup
-
The initiater of the building process.
- SetupContext($lexer, $contextname, $reftodata);
-
Sets up context and stores it in $lexer.
- SetupContextRules($lexer, $contextname, $reftodata);
-
Sets up the rules for $contextname.
- SetupContextShifter($lexer, $contextname);
-
Creates an anonymous sub that does a context shift when executed.
- SetupRuleXXXXX($reftorule);
-
All these methods set up specific rules inside a context.
- SetupRuleAnyChar
- SetupRuleDefault
- SetupRuleDetectChar
- SetupRuleDetect2Chars
- SetupRuleKeyword
- SetupRuleLineContinue
- SetupRuleRangeDetect
- SetupRuleRegMinimal
- SetupRuleRegExpr
- SetupRuleStringDetect
- SyntaxExists
-
Checks if a syntax is available before creating a context shifter that uses it.
AUTHOR AND COPYRIGHT
This module is written and maintained by:
Hans Jeuken < hanje at cpan dot org >
Copyright (c) 2017 - 2023 by Hans Jeuken, all rights reserved.
Published under the same license as Perl.
SEE ALSO
Syntax::Kamelon, Syntax::Kamelon::Debugger, Syntax::Kamelon::Diagnostics, Syntax::Kamelon::Indexer, Syntax::Kamelon::XMLData, Syntax::Kamelon::Format::Base, Syntax::Kamelon::Format::ANSI, Syntax::Kamelon::Format:HTML4